blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 4 137 | path stringlengths 2 355 | src_encoding stringclasses 31
values | length_bytes int64 11 3.9M | score float64 2.52 5.47 | int_score int64 3 5 | detected_licenses listlengths 0 49 | license_type stringclasses 2
values | text stringlengths 11 3.93M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
d527aba3161eb694389376f7c7908b9c8a58b779 | Ruby | jtlemkin/chess | /Desktop/odin/chess/lib/board.rb | UTF-8 | 1,268 | 3.796875 | 4 | [] | no_license | require './lib/piece'
class Board
attr_accessor :coord
def initialize
@coord = Hash.new
add_pieces
end
def add_pieces
build_king_row(8, :black)
build_pawn_row(7, :black)
build_pawn_row(2, :white)
build_king_row(1, :white)
end
def build_pawn_row(row, color)
(1..8).each do |s|
@coord[[s, row]]... | true |
ff7b4e9c0b9d8a3c84e2165df0f12e103b552ffb | Ruby | RobertDober/lab42_streams | /lib/lab42/stream/empty.rb | UTF-8 | 1,614 | 2.625 | 3 | [
"MIT"
] | permissive | require 'forwarder'
module Lab42
class Stream
class Empty < Stream
extend Forwarder
# It is the nature of the EmptyStream instance to return itself for a plethora of methods
# this can be expressed as follows:
forward_all :combine, :__combine__,
:drop, :drop_unitl, :drop_... | true |
ebc78ce306488ea03eed141dd38f287639457339 | Ruby | sykaeh/wikipedia_wrapper | /lib/wikipedia_wrapper/page.rb | UTF-8 | 3,756 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'wikipedia_wrapper/exception'
require 'wikipedia_wrapper/image'
require 'wikipedia_wrapper/util'
module WikipediaWrapper
class Page
attr_reader :title, :revision_time, :url, :extract
def initialize(term, redirect: true)
@term = term
@redirect = redirect
@images = nil
@img_... | true |
55b755c60368c5bc1890316b5e9ceb988f96e715 | Ruby | yvesdu/check-in | /app/serializers/api/standup_serializer.rb | UTF-8 | 896 | 2.546875 | 3 | [] | no_license | module Api
class StandupSerializer
def initialize(standup)
@standup = standup
end
def as_json
full_standup
end
private
def full_standup
{
id: standup.id,
standup_date: standup.standup_date,
user: {
name: s... | true |
4a9affb9a06d79efdbdba74575b05328ace28c8e | Ruby | plonk/100knock | /q58.rb | UTF-8 | 1,276 | 3.421875 | 3 | [] | no_license | =begin
58. タプルの抽出
Stanford Core NLPの係り受け解析の結果(collapsed-dependencies)に基づき,
「主語 述語 目的語」の組をタブ区切り形式で出力せよ.ただし,主語,述語,
目的語の定義は以下を参考にせよ.
述語: nsubj関係とdobj関係の子(dependant)を持つ単語
主語: 述語からnsubj関係にある子(dependent)
目的語: 述語からdobj関係にある子(dependent)
=end
require_relative 'q57'
# 文を表わすグラフから「主語-動詞-直接目的語」の例を抽出する。
def svo_ins... | true |
1c90ecf04c1a21f7fd05e4012a9fbfdff510993f | Ruby | nataliecodes/phase-0 | /week-4/calculate-grade/my_solution.rb | UTF-8 | 1,160 | 4.28125 | 4 | [
"MIT"
] | permissive | # Calculate a Grade
# I worked on this challenge by with Bernice.
# Your Solution Below
=begin
pseudocode
1. get a number (input)
2. relate that number to a letter grade
2.a. a = 90-100
2.b. b = 80-89
2.c. c = 70-79
2.d. d = 60-69
2.e. f = <60
3. output the letter grade (output)
=end
def get_grade(avg)... | true |
e2166bee12758b327f463da62ea29f753b63f680 | Ruby | yaobao5354/ruby-objects-has-many-lab-online-web-sp-000 | /lib/artist.rb | UTF-8 | 448 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Artist
attr_accessor :name, :songs
@@AllArtists = []
def initialize(name)
@name = name
@songs = []
@@AllArtists << self
end
def add_song(song)
song.artist = self
end
def add_song_by_name(title)
title = Song.new(title)
title.artist = self
end
... | true |
384827519f0e967058c564fdd8a4fe6f852048ed | Ruby | Narnach/data247 | /lib/data247.rb | UTF-8 | 3,262 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'open-uri'
require 'timeout'
require 'active_support'
class Data247
attr_accessor :operator_name, :operator_code, :msisdn, :status
def initialize(attributes={})
attributes.each do |key, value|
self.send("#{key}=", value)
end
end
class << self
attr_accessor :username, :password, :tim... | true |
7d04db0a29363055f2f544889219200a10669d25 | Ruby | lambyy/projects | /week2/w2d4/time_differences.rb | UTF-8 | 935 | 3.5 | 4 | [] | no_license | require 'byebug'
class Array
#time complexity O(n**2)
def my_min
each do |el1|
min = true
each do |el2|
if el2 < el1
min = false
end
end
return el1 if min == true
end
end
#time complexity O(n)
def my_better_min
min = first
each do |el|
m... | true |
254280fea0e730093ada384af8c4e1330aee85f0 | Ruby | theRingleman/schoolProjects | /learnToProgram/exampleName.rb | UTF-8 | 450 | 3.984375 | 4 | [] | no_license | puts "Hi there, what is your first name?"
firstName = gets.chomp
puts "Great! Now what is your middle name?"
middleName = gets.chomp
puts "Awesome! Now last one I promise! What is your last name?"
lastName = gets.chomp
fnLength = firstName.length
mnLength = middleName.length
lnLength = lastName.length
fullNameLength ... | true |
012d4d6dd097881a75c2d21a391e49ece721da1e | Ruby | iijijii/pazzles | /3-2.rb | UTF-8 | 145 | 2.96875 | 3 | [] | no_license | data = [1,4,2,4,5,6,10,6,5,4,3,8,7,9,4,6,2,4]
count = []
(1..10).each do |n|
count[n - 1] = data.count(n)
end
puts count.index(count.max) + 1
| true |
78a7baa07391d89b8178645cb4a789a82a955b74 | Ruby | RobertDober/lab42_core | /spec/memoization/memoize_no_params_spec.rb | UTF-8 | 1,105 | 2.78125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0",
"MIT"
] | permissive | require 'spec_helper'
describe Module do
context 'undefined methods remain undefined' do
let :klass do
Class.new do
memoize :beta
end
end
it 'raises a NoMethod error' do
expect{ klass.new.beta }.to raise_error NameError, %r{undefined method .beta.}
end
end # context ... | true |
40f1b495dacfd1bed328251af95d0db84639f924 | Ruby | jguyet/piscine-ruby-on-rails | /j01/ex01/croissant.rb | UTF-8 | 372 | 3.203125 | 3 | [] | no_license | #! /usr/bin/ruby -W0
def read_file(file_name)
if File.exist?(file_name) == false
return ""
end
file = File.open(file_name, "r")
data = file.read
file.close
return data
end
def ___MAIN()
data = read_file("./numbers.txt")
split = data.split(",")
split = data.split(",\n")
split = split.sort_by! {|s| s[/\d+/]... | true |
4265650664c9056ac2da2dc2faa005738c36c6c1 | Ruby | s3844286/QuizPlus | /app/controllers/quizs_controller.rb | UTF-8 | 5,721 | 2.9375 | 3 | [] | no_license | class QuizsController < ApplicationController
require 'json'
def new
params[:numOfQuestions] != nil ? @numOfQuestions = params[:numOfQuestions].to_i : @numOfQuestions = 4
# array stores Question objects
@questionsForQuiz = Array.new
if params[:questions] != nil
# drops fi... | true |
425e63a4ac3c39f5ef17920dca6dffefa495f1f6 | Ruby | shameem356/illuminati | /scripts/lims_fc_info.rb | UTF-8 | 2,121 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
# fetch data from lims
require 'optparse'
require 'net/http'
require 'uri'
require 'json'
API_TOKEN = '1c5b55787c806548'
NGS_LIMS = "http://limskc01/zanmodules/molbio/api/ngs/"
getFlowcell = NGS_LIMS + 'flowcells/getFlowcell'
getSamples = NGS_LIMS + 'flowcells/getSamples'
def get_connection(ur... | true |
723214af52bbaaed9a9b42733caafa11c047677d | Ruby | Alux77/Ruby-3 | /1_linear-search.rb | UTF-8 | 1,249 | 4.5625 | 5 | [] | no_license | # Escribe un método llamado linear_search que tome como argumento un número y un arreglo.
# Este método debe regresar el índice del primer elemento que sea igual al valor del número,
# revisando dentro del arreglo cada valor secuencialmente.
# En caso de no encontrar el número debe regresar nil.
# No podrás utili... | true |
a4ea00fe49affc88d1fa882546084dc9f0bea512 | Ruby | cnorm35/InterviewExercises | /difference-of-squares/difference_of_squares.rb | UTF-8 | 120 | 2.546875 | 3 | [] | no_license | class Squares
def initialize(n); end
def sum_of_squares; end
def difference; end
def square_of_sums; end
end
| true |
92dde66ba7ee535b295b88872def6b64f564d80a | Ruby | onthespotqa/seed_list | /lib/seed_list/cli.rb | UTF-8 | 3,335 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'thor'
module SeedList
class CLI < Thor
namespace :seed_list
desc 'edit TOURNAMENT_ID', 'Reposition seeds using EDITOR (interactive)'
def edit(tournament_id)
@tournament_id = tournament_id
trap_signals
say "Using #{ENV['EDITOR']} (set $EDITOR to change)", :green
say 'Load... | true |
b9e43e843631cd36d0318ca5851fb1c84f9b3692 | Ruby | Jose-N/Launch-Academy-Week-1 | /emergency-brussels-sprouts/lib/ingredient.rb | UTF-8 | 273 | 3.5 | 4 | [] | no_license | class Ingredient
attr_reader :name, :weight
def initialize(name, weight)
@name = name
@weight = weight
end
def self.create_from_grams(name, weight_in_grams)
weight_in_kilos = weight_in_grams / 1000
Ingredient.new(name, weight_in_kilos)
end
end
| true |
9ec17e5e62f2211eddc5580e1ed286ae147a55ac | Ruby | hmaarek/assign-deployment | /app/models/fiberstrand.rb | UTF-8 | 3,561 | 2.59375 | 3 | [] | no_license | class Fiberstrand < ActiveRecord::Base
belongs_to :cable
validates_presence_of :name, :porta, :portb, :cable_id
after_save :set_devport_fiber_id
#run a query to build a list of all availbale ports in the
#location of the Point A of the cable...
#addition (23 June): build only the free ports list
... | true |
7d3b5377bc026ad6397f502db7a9dec179ef74d0 | Ruby | technohippy/Kaleidoscope.rb | /src/compat.rb | UTF-8 | 369 | 3.140625 | 3 | [] | no_license | EOF = nil
$buf = []
def getchar
$buf += ($stdin.gets || '').split('') if $buf.empty?
$buf.shift
end
def isspace c; c =~ /^\s$/ end
def isalpha c; c =~ /^[a-zA-Z]$/ end
def isalnum c; c =~ /^[a-zA-Z0-9]$/ end
def isdigit c; c =~ /^[0-9]$/ end
def isascii c
if c.is_a? String
code = c.bytes.to_a.first
0 <= ... | true |
76f0459758822ec9fba03f72e5bfafea567fb03c | Ruby | Matoone/THP_S2_J2 | /spec/find_multiples_spec.rb | UTF-8 | 1,172 | 3.5625 | 4 | [] | no_license | require_relative '../lib/find_multiples.rb'
describe "the is_multiple_of_3_or_5? method" do
it "should return TRUE when an integer is a multiple of 3 or 5" do
expect(is_multiple_of_3_or_5?(3)).to eq(true)
expect(is_multiple_of_3_or_5?(5)).to eq(true)
expect(is_multiple_of_3_or_5?(51)).to eq(true)
exp... | true |
451313e968a475e70f9616a37c936ec4219adf4d | Ruby | danieltoppin/appliances | /lib/dishwasher.rb | UTF-8 | 359 | 2.953125 | 3 | [] | no_license | require './lib/appliances.rb'
class Dishwasher < Appliances
#instance methods
def initialize(door:, power:)
super(door: door, power: power)
end
def start
if (door_closed? && power_on?)
'Dishwasher is starting...'
else
'Dishwasher could not start'
end
end
def self.create(door:, power:)
Dishwasher... | true |
86c11c66f3e45e54a215182c9c7ef7dd8cf9e1f4 | Ruby | ryerayne/oo-my-pets-v-000 | /lib/owner.rb | UTF-8 | 1,437 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Owner
attr_accessor :pets, :name, :mood
attr_reader :species, :fishes, :cats, :dogs
attr_writer
@@owner = []
def initialize(name)
@name = name
@pets = {:fishes => [], :cats => [], :dogs => []}
@@owner << self
@species = "human"
end
def self.all
@@owner
... | true |
c566d1529fb7227f98722272c7873dc54812abd0 | Ruby | ncalibey/Launch_School | /130_ruby_foundations/lesson_01/select.rb | UTF-8 | 369 | 3.953125 | 4 | [] | no_license | # select.rb
def select(arr)
counter = 0
return_arr = []
while counter < arr.size do
value = yield(arr[counter])
if value
return_arr << arr[counter]
end
counter += 1
end
return_arr
end
array = [1, 2, 3, 4, 5]
p select(array) { |num| num.odd? }
p select(array) { |num... | true |
147289beb01eb9777551a42b14fefdbf08f8fa23 | Ruby | makotz/CodeCore-Exercises | /4week/10JuneDay20/a1_student_class/student.rb | UTF-8 | 341 | 3.375 | 3 | [] | no_license | class Student
attr_accessor :first_name, :last_name, :score
def initialize(first_name, last_name, score)
@first_name = first_name
@last_name = last_name
@score = score
end
def full_name
"#{@first_name} #{@last_name}"
end
def grade
if @score.to_i > 90
"A"
else
"F"... | true |
6306efabd37cef809eb0dec39e18302b52b096f7 | Ruby | netguru-hackathon/bandicoot | /lib/bandicoot/processor.rb | UTF-8 | 1,259 | 2.578125 | 3 | [
"MIT"
] | permissive | module Bandicoot
module Processor
attr_accessor :browser, :content
def boot_browser
self.browser = Watir::Browser.new
self.browser.goto config.url
parse_content
end
def crawl
boot_browser
result = Hash.new
loop do
config.scopes.each do |scope|
re... | true |
0a6bdc9098a2f16bdf942e2b389fff310d236153 | Ruby | thekompanee/chamber | /lib/chamber/file_set.rb | UTF-8 | 8,259 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'pathname'
require 'chamber/namespace_set'
require 'chamber/file'
require 'chamber/settings'
###
# Internal: Represents a set of settings files that should be considered for
# processing. Whether they actually *are* processed depends on their extension
# (only *.yml and *.yml.er... | true |
af964c968bbf27a9d6217e6eca780e366d80b71e | Ruby | whatcodehaveyougit/10th_dec_sinatra_homework | /models/films.rb | UTF-8 | 1,514 | 3.203125 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Film
attr_reader :id
attr_accessor :title, :price
def initialize ( options )
@id = options['id'].to_i if options ['id']
@title = options['title']
@price = options['price']
end
# =========== CREATE =============
def save()
sql="INSERT INTO films
(title, price)
... | true |
f4ff00a017b949ec998f040844d2fe017e5161d0 | Ruby | i8hamburgrz/bewd_homework | /homework-04/pants/pants.rb | UTF-8 | 984 | 2.84375 | 3 | [] | no_license | require 'sinatra'
require 'httparty'
forcast_url = 'https://api.forecast.io/forecast/8deef2835fd7736a6afd302168019c4c/'
get '/' do
erb :home
end
post '/results' do
# zip code parsing
zip_code = params['zip_code']
zip_url = "http://api.zippopotam.us/us/#{ zip_code }"
zip = HTTParty.get( zip_url )
parsed_z... | true |
0be2011b40666004702799eaf45e9549514fe55c | Ruby | azet/http_sec_headers | /headers.rb | UTF-8 | 2,440 | 2.53125 | 3 | [
"CC0-1.0"
] | permissive | #!/usr/bin/env ruby -W0
#
# check for HTTP security headers
#
require 'open-uri'
def scan_headers field, page
field.map! &:downcase
case
when field.first == "strict-transport-security"
puts "[+] #{page} supports HSTS."
when field.first == "public-key-pins"
puts "[+] #{page} supports HPKP."
when field... | true |
0b50e1e9adb45cc41d53542a1ad8b761a928324b | Ruby | yalanin/201902_rspec_practice | /spec/array_spec.rb | UTF-8 | 249 | 2.546875 | 3 | [] | no_license | RSpec.describe Array do
it 'should be empty after created' do
puts subject
puts subject.class
expect(subject.length).to eq(0)
subject.push 'hello world'
end
it 'length of array' do
expect(subject.length).to eq(1)
end
end | true |
b24d950fd500d6b17889c82b54145ccf5016ad2d | Ruby | fraterrisus/advent2018 | /day02/part1.rb | UTF-8 | 271 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env ruby
lines = IO.readlines(ARGV[0])
num2 = 0
num3 = 0
lines.map(&:strip).each do |l|
freq = l.chars.inject(Hash.new(0)) { |p,v| p[v] += 1; p }
counts = freq.values
num2 += 1 if counts.include? 2
num3 += 1 if counts.include? 3
end
puts num2 * num3
| true |
c53dcfa69ce6eadc8726a080981d6d3961d864e2 | Ruby | ofrost617/Bank | /lib/transaction_log.rb | UTF-8 | 381 | 2.765625 | 3 | [] | no_license | require_relative './transaction_formatter.rb'
class TransactionLog
attr_reader :transaction_log
def initialize(transaction = TransactionFormatter.new)
@transaction = transaction
@transaction_log = []
end
def add_transaction(type, amount, balance)
new_transaction = @transaction.add(type, amount, ... | true |
5e7a227e99fba5b3842075d25e4ed4fde72c9185 | Ruby | linhdangduy/ruby-learning | /wednesday/redflag.rb | UTF-8 | 284 | 2.90625 | 3 | [] | no_license | # solution
# save block passed to setup in a place
# then when event is call, it will call those object
@setups = []
def setup(&setting)
@setups << setting
end
def event(description)
@setups.each { |setting| setting.call }
puts description if yield
end
load 'setup_event.rb'
| true |
b6c0e02e477f4b885829ce031cff2c71581a3ab8 | Ruby | vlasisPit/ruby-training | /chapter_2/constants.rb | UTF-8 | 386 | 3.390625 | 3 | [] | no_license | =begin
Named using all uppercase letters
=end
# constant
MAX_SCORE = 100
# variable
max_score = 50
puts MAX_SCORE.class
puts MAX_SCORE == max_score
# Ruby lets you to change the value of a constant. But gives you a warning
MAX_SCORE = 50
puts MAX_SCORE == max_score
# If the first letter is capital, then Ruby consi... | true |
4b0b000aa0ef211cafa2a231bab11b77cf58954a | Ruby | lintci/laundromat | /app/models/access_token.rb | UTF-8 | 1,015 | 2.59375 | 3 | [] | no_license | # API Token
class AccessToken < ActiveRecord::Base
belongs_to :user, required: true
validates :access_token, presence: true, uniqueness: true
validates :expires_at, presence: true
before_validation :set_access_token, :set_expires_at, on: :create
default_scope{order(:created_at)}
scope :active, ->{where('... | true |
ad4f00a71fccc04922e84de68d3a4839ead02785 | Ruby | seif-allaya/ASC-ReportParsingLib | /ASC-StatsReport.rb | UTF-8 | 2,155 | 2.875 | 3 | [] | no_license | require './ASC-CSVParselib'
require 'optparse'
require 'sqlite3'
#########################################################
# By: seif.allaya@gmail.com
#########################################################
# Connect to sqlite3 database
#
# NOt Ready Yet
#
# Print the stats... | true |
38da0f401cc60e6680ee23a0dc0abb0ff4975c7f | Ruby | jessegan/collections_practice-onl01-seng-ft-052620 | /collections_practice.rb | UTF-8 | 919 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(arr)
arr.sort do |a,b|
a <=> b
end
end
def sort_array_desc(arr)
arr.sort do |a,b|
b<=>a
end
end
def sort_array_char_count(arr)
arr.sort do |a,b|
a.length <=> b.length
end
end
def swap_elements(arr)
if arr.length >= 3
arr[1],arr[2] = ar... | true |
943b7fd5b24eab9267d9e67915f329acaef8d5e4 | Ruby | thomasrogers03/thomas_utils | /spec/shared_examples/key_comparison.rb | UTF-8 | 1,295 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | shared_examples_for 'a method comparing two keys' do |method|
describe "##{method}" do
let(:key) { Faker::Lorem.word }
let(:value) { Faker::Lorem.word }
let(:lhs) { klass.new(key, value) }
let(:rhs) { klass.new(key, value) }
subject { lhs.public_send(method, rhs) }
it { is_expected.to eq(tru... | true |
a268e7afac3e089de1b0fccbe95110decd688bd1 | Ruby | adeshjohnson/MX3 | /app/models/tax.rb | UTF-8 | 11,569 | 2.609375 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
class Tax < ActiveRecord::Base
has_one :user
has_one :cardgroup
has_one :invoice
before_save :tax_before_save
=begin rdoc
Validates tax.
=end
def initialise(params = nil)
super(params)
self.compound ||= 1
end
def tax_before_save()
self.total_tax_name = "TAX" if s... | true |
69a4b47cf970f7070c41f1e54209824ac1a84bd1 | Ruby | anitaf/classrubyproject | /ibs_to_kg.rb | UTF-8 | 87 | 2.84375 | 3 | [] | no_license | # 1 lb = 0.453592 kg
puts " How much does that duck weigh?"
weight = gets.chomp.to_i
| true |
a24cbe1238e6816b2e6841be50286bf5257329d9 | Ruby | Mloweedgar/eloquent_ruby_code | /19/ex_2_doc_with_on_save_spec.rb | UTF-8 | 1,451 | 3.28125 | 3 | [] | no_license | require '../code/doc3'
require '../utils/rspec_utils'
class Document ##(main
# Most of the class omitted...
def load( path )
@content = File.read( path )
on_load(path)
end
def save( path )
File.open( path, 'w') { |f| f.print( @content ) }
on_save(path)
end
def on_l... | true |
38bf4b431318faa0fb5350d1d953e0623738f248 | Ruby | stevehook/checkout-kata | /spec/checkout_spec.rb | UTF-8 | 1,551 | 2.671875 | 3 | [] | no_license | require_relative '../lib/checkout'
require 'bigdecimal'
RSpec.describe Checkout do
let(:rules) { {} }
subject { Checkout.new(rules) }
it 'initial total is zero' do
expect(subject.total).to eql BigDecimal('0.0')
end
context 'without rules' do
it 'can scan items' do
subject.scan('001')
ex... | true |
b5b1a1d877010c23f61ae108c8769e25cca8a56b | Ruby | lrotschy/Ruby-Exercises | /Basics/advanced_12_9.rb | UTF-8 | 1,571 | 3.640625 | 4 | [] | no_license |
# array = [Rational(1, 2), Rational(2, 1)]
# p array.sum < 3
require 'pry'
require 'pry-byebug'
def egyptian(num)
counter = 1
rationals = []
loop do
# binding.pry
next_frac = Rational(1, counter)
if rationals.sum + next_frac <= num
rationals.push(next_frac)
end
counter += 1
break if rationals.sum >= ... | true |
a755d96685c38dae7e5009c997b1c46bc1ffb9fd | Ruby | tardate/ebook-toolchains | /epubbery/bin/epubbery | UTF-8 | 1,901 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
@gem_dir = File.expand_path(File.dirname(__FILE__) + '/..')
$: << File.join(@gem_dir, 'lib')
require 'fileutils'
require File.join(@gem_dir, 'lib', 'epubbery')
@epub = Epub.new
if ARGV[0]
@destination = ARGV[0]
@base_dir = File.expand_path(File.dirname(__FILE__) + '/..')
puts "Creating t... | true |
f1e531e5f0faaa55ca3ed7a31689aa6cae6f83b7 | Ruby | jimmyle414/key-for-min-value-online-web-sp-000 | /key_for_min.rb | UTF-8 | 230 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
return nil if name_hash.empty?
name_hash.max_by {|k, v| 0-v}[0]
end | true |
d0209a5be4bb1866331ee485e80c14a831051a0f | Ruby | JaniceYR/002_aA | /w1d2/01_project/match/humanplayer.rb | UTF-8 | 501 | 3.53125 | 4 | [] | no_license | class HumanPlayer
attr_reader :name, :board
attr_accessor :score
def initialize(name, board)
@name = name
@score = 0
@board = board
end
def guess
render
puts "Please enter the position of the card"
puts "Example x,y "
gets.chomp.split(",").map(&:to_i)
end
def render (pos = ni... | true |
6a05f66ebe5bc777a532dfa4a82e254ffb9de586 | Ruby | samirahmed/bonmetruck.com | /lib/copy/bin/copy | UTF-8 | 671 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
begin
require 'copy'
rescue LoadError
require 'rubygems'
require 'copy'
end
require 'copy/version'
require 'optparse'
OptionParser.new do |opts|
opts.banner = "Usage: copy [options]"
opts.on('-n', '--new [DIR]', 'Create a new Copy site in DIR') do |dir|
dir ||= '.'
site = File.d... | true |
0e8f566708198d1baf4aa389ab2ae4caf1dba13d | Ruby | joelramsey/raven | /db/seeds.rb | UTF-8 | 2,126 | 2.515625 | 3 | [] | no_license | require 'faker'
require 'yajl'
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name... | true |
95b51f8a968dcb1d0fb84a1815797c91cce655e3 | Ruby | fog/fog-aws | /lib/fog/aws/requests/rds/create_db_parameter_group.rb | UTF-8 | 1,942 | 2.546875 | 3 | [
"MIT"
] | permissive | module Fog
module AWS
class RDS
class Real
require 'fog/aws/parsers/rds/create_db_parameter_group'
# create a database parameter group
# http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_CreateDBParameterGroup.html
# ==== Parameters
# * DBParameterG... | true |
aea0fd0fa55652c67e7a40074a48e8a0fffb80dd | Ruby | idokko/cally | /app/forms/message_form.rb | UTF-8 | 673 | 2.5625 | 3 | [] | no_license | class MessageForm
include ActiveModel::Model
# attr_accessorメソッド
# クラス外部からインスタンス変数を参照、変更可能にする
attr_accessor :content, :user_id, :room_id, :photos
validates :content_or_photo, presence: true
private
def content_or_photo
self.content.present? || MessageImage.photos.present?
e... | true |
4adb3bde6be1720bd287e7aa89998a6ecb23f565 | Ruby | domitian/blackjack | /app/models/game.rb | UTF-8 | 4,198 | 2.8125 | 3 | [] | no_license | class Game < ActiveRecord::Base
# State machine for controlling the state of the game
include AASM
cattr_accessor :card_stack
@@num_card_decks = 6
# Storing the all 6 deck of card objects in this array
@@card_stack = Array.new(@@num_card_decks , CardDeck.new(%w{ 11 2 3 4 5 6 7 8 9 10 10 10 10}).... | true |
30c6402fb231aea7760416dec1824ccda123f7aa | Ruby | DouglasAllen/code-Metaprogramming_Ruby | /raw-code/PART_II_Metaprogramming_in_Rails/gems/activesupport-2.3.2/lib/active_support/core_ext/array/extract_options.rb | UTF-8 | 979 | 3.140625 | 3 | [] | no_license | #---
# Excerpted from "Metaprogramming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http:/... | true |
d63c711337040289f88d39a7a406a7d67c1d2ad8 | Ruby | BottosWorld/triangle-classification-onl01-seng-pt-012120 | /lib/triangle.rb | UTF-8 | 882 | 3.59375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
def initialize(side1, side2, side3)
@triangle_sides = []
@triangle_sides << side1
@triangle_sides << side2
@triangle_sides << side3
end
def valid?
sum_1_2 = @triangle_sides[0] + @triangle_sides[1]
sum_1_3 = @triangle_sides[0] + @triangle_sides[2]
sum_2_3 = @triangle_s... | true |
027965ba735b70ec3046df0aeafd740a91077c2d | Ruby | anthonyhamou/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 863 | 2.65625 | 3 | [] | no_license | puts 'Cleaning database...'
Restaurant.destroy_all
puts 'Creating restaurants...'
restaurants_attributes = [
{
name: 'Dishoom',
address: '7 Boundary St, London E2 7JE',
phone_number: '0618493012',
category: 'japanese'
},
{
name: 'Pizza East',
address: '56A Shore... | true |
2d9ad2f1d923530fb7a881a6d7b10bace16b1ec1 | Ruby | johnschoeman/AppAcademyProjects | /W2D3/first_tdd/lib/first_tdd.rb | UTF-8 | 749 | 3.265625 | 3 | [] | no_license | class Array
def my_uniq
self.uniq
end
def two_sum
res = []
(0...length-1).each do |i|
(i+1..length-1).each do |j|
res.push([i,j]) if self[i] + self[j] == 0
end
end
res
end
def my_transpose
self.transpose
end
end
def stock_picker(arr)
curr_prof_days = nil
... | true |
5a7a3351f270eb9995fa24b5624bd6c5d251bf1e | Ruby | rhoml/Portus | /spec/helpers/teams_helper_spec.rb | UTF-8 | 1,406 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | require "rails_helper"
RSpec.describe TeamsHelper, type: :helper do
let(:admin) { create(:admin) }
let(:owner) { create(:user) }
let(:viewer) { create(:user) }
let(:contributor) { create(:user) }
let(:team) do
create(:team,
owners: [owner],
contributors: [con... | true |
02038bf817fd10b9cc97650c2a29c528346b7377 | Ruby | danielkwon7/Algorithms | /skeleton/lib/assessment01.rb | UTF-8 | 2,680 | 4 | 4 | [] | no_license | require 'byebug'
class Array
# Monkey patch the Array class and add a my_inject method. If my_inject receives
# no argument, then use the first element of the array as the default accumulator.
def my_inject(accumulator = nil, &prc)
prc ||= Proc.new{|x,y| x + y}
ev = accumulator
accumulator ||= self[... | true |
271ac0987cf4146222ee17906653632a72f4bdaf | Ruby | brannerchinese/RubySlides | /mvc_coffeecup_example/coffee_cup.rb | UTF-8 | 491 | 3.609375 | 4 | [] | no_license | class CoffeeCup
attr_reader :amount_left
def initialize
fill
end
def fill
@amount_left = 100 # Percent full
end
def empty
@amount_left = 0
end
def gulp
@amount_left -= Random.rand(17..35)
end
def sip
@amount_left -= 5
end
def to_s
if @amount_left == 100
... | true |
f9116ccd337aef2f01cf9938e69fb82d04545555 | Ruby | joe-hamilton/RB_101 | /rb_small_problems/medium_2/3.rb | UTF-8 | 3,447 | 4.6875 | 5 | [] | no_license | # Lettercase Percentage Ratio
=begin
(Understand the Problem)
Problem:
Write a method that takes a string, and then returns a hash that contains 3 entries:
- one represents the percentage of characters in the string that are lowercase letters
- one the percentage of characters that are uppercase lett... | true |
9ad1f86e6099cbb15600f88b96c7ae83cf20b68f | Ruby | CDR2003/Brotorift | /src/lib/generators/bot_generator.rb | UTF-8 | 13,944 | 2.921875 | 3 | [] | no_license | require 'erb'
require_relative '../case_helper'
class EnumTypeDef
def bot_name
@name.underscore
end
def bot_read_name
"read_#{self.bot_name}"
end
def bot_write_name
"write_#{self.bot_name}"
end
def bot_read
"#{self.bot_read_name}(data)"
... | true |
6c4bd185cbc68ebc209a435c02ff4c349dcdab13 | Ruby | mejibyte/chords | /lib/chords/html_formatter.rb | UTF-8 | 1,192 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'chords/png_formatter'
require 'base64'
module Chords
# Formats fingerings as <img/> tags (base64-encoded data URIs)
class HTMLFormatter
class NonCache
def fetch(key); yield end
end
attr_accessor :cache
def initialize(fretboard, cache=NonCache.new)
@fretboard = fre... | true |
d5a4ea283a1712656f28bba5823173d82f0c0c5b | Ruby | fardeen9983/Ultimate-Dux | /Languages/Ruby/Basics/files.rb | UTF-8 | 2,868 | 4.375 | 4 | [] | no_license | # File I/O
# In ruby we have an inbuilt collection of classes with features taht enable us to manipulate files
# The main calss amongst these is File. It has variety of options to open a file, read from it and write as well
# Opening a file - Make sure the file is provided in the same folder as the ruby file or el... | true |
706b3852fa3b3acbd2ea4251d21f52518ac7a302 | Ruby | redbone1983/launch_school | /01_Pre_Course/08_More_Stuff/inline_exception_example.rb | UTF-8 | 1,145 | 4.5 | 4 | [] | no_license | # zero = 0
# puts "Before each call"
# zero.each { |element| puts element} rescue puts "Can't do that!"
# puts "After each call"
=begin
Before each call
Can't do that!
After each call
=end
# => without the <rescue> this returns a syntax error
# zero = 0
# puts "Before each call"
# zero.each { |element| puts element... | true |
b9cf613648258892d24240a20aed743b45a214e8 | Ruby | Olive7ee/RubyS1 | /lib/01_pyramids.rb | UTF-8 | 440 | 3.75 | 4 | [] | no_license | puts "Comment souhaitez-vous d'etage dans votre magnifique pyramide ? "
count = gets.chomp.to_i
#compte à rebourd de 1 jusqu'au chiffre
1.upto(count) do |i|
i.upto(count - 1) { print " " }
i.times { print "# " }
print "\n"
end
# -1 sur le milieu pour eviter le doublon
count = count - 1
# décompte du ch... | true |
0f4f7a41c6dded6061a51a74fac2b84619cd13f8 | Ruby | gaar4ica/humanized_full_messages | /lib/humanized_full_messages/hash.rb | UTF-8 | 147 | 2.703125 | 3 | [
"MIT"
] | permissive | class Hash
def rekey(h)
dup.rekey! h
end
def rekey!(h)
h.each { |k, newk| store(newk, delete(k)) if has_key? k }
self
end
end
| true |
b9f9e42d0d45f0e59cdf3119c1bb9c41a7df8094 | Ruby | Dimesky/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 4,278 | 4.5625 | 5 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# Allow for the method to take a string argument
# set default quantity - take the number of items in the string and create a quantity separated by spaces
# print the list to the console [can... | true |
9693836ae275bbd646982262a010718501f80e9d | Ruby | G5/backups-manager | /lib/app_list.rb | UTF-8 | 1,151 | 2.84375 | 3 | [
"MIT"
] | permissive | class AppList
APP_TYPES = [ :cau, :cls, :clw, :cms, :cpas, :cxm, :dsh, :nae, :other ]
def self.get
app_list_uri = "https://api.heroku.com/apps"
headers = HerokuApiHelpers.default_headers(range: "name ..; max=1000;")
response = HTTPClient.get app_list_uri, nil, headers
data = JSON.parse response.bod... | true |
4d134d9b6f05187508c8c72ca7a30989e99b61b0 | Ruby | anoam/customers_locations | /lib/domain/point.rb | UTF-8 | 1,968 | 3.6875 | 4 | [] | no_license | # frozen_string_literal: true
module Domain
# Geo-point
class Point
RAD_PER_DEG = Math::PI / 180
EARTH_RADIUS = 6_371 # in kilometers
attr_reader :latitude, :longitude
# Check arguments and creates new instance
# @param latitude [Numerical] geo latitude
# @param longitude [Numerical] geo ... | true |
1ff0376952fbfdfc15a45258c4b6c5b34e2743f6 | Ruby | RITBreakingBread/EffortLog | /lib/util/week_mapper.rb | UTF-8 | 458 | 3 | 3 | [
"MIT"
] | permissive | class Util::WeekMapper
#a map of the week number to a range of dates surrounding that week
@@mapper = {
1 => ["2015-08-25 15:00", "2015-08-31 23:59"],
2 => ["2015-09-01 15:00", "2015-09-07 23:59"],
3 => ["2015-09-08 00:00", "2015-09-14 23:59"],
4 => ["2015-09-15 00:00", "2015-09-21 23:59"]
}
... | true |
3fdf6ea94d6aa748762eb7e757d0b4ac8a14263f | Ruby | rdavidreid/ruby_chess | /lib/pieces/bishop.rb | UTF-8 | 486 | 3.234375 | 3 | [] | no_license | require_relative 'sliding_piece.rb'
class Bishop < Sliding_Piece
def initialize(color,board)
super(color,board)
if color == "white"
@icon = " ♝ "
else
@icon = " ♗ "
end
@slider = true
end
def moves(current_pos)
arr = []
arr += diagonal_moves(current_pos, 1, 1)
ar... | true |
ff473fd30302ab839b81f7f670b8986d3513b657 | Ruby | tatsiana-makers/domain-modelling | /do_not_look_until_after_workshop/book_library_starter_code.rb | UTF-8 | 265 | 3.171875 | 3 | [] | no_license | class Book
def initialize(name, author)
@name = name
@author = author
@damaged = false
end
end
class Library
def initialize
@books = []
end
def add(book)
end
def count_damaged_books
end
def books_by(author)
end
end
| true |
b82cf88a6011ac34f48cf8133b1486dff016d1ff | Ruby | mraspberry/learning_ruby | /src/ruby_in_20_min/ex2.rb | UTF-8 | 425 | 4.125 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
class Greeter
def initialize(name = "world")
@name = name.capitalize # this is an instance variable
end
# don't have to put the 'self' arg or even parens. This is sus
def greet
puts "Hello, #{@name}!"
end
def bye
puts "Goodbye #{@name}. Don't ... | true |
1fe7a1295a94d59aa56e5fa625b074add2843ec7 | Ruby | jhedden/jackhammer | /web/app/lib/common/models/wp_item/vulnerable.rb | UTF-8 | 1,140 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # encoding: UTF-8
class WpItem
module Vulnerable
attr_accessor :db_file, :identifier
# Get the vulnerabilities associated to the WpItem
# Filters out already fixed vulnerabilities
#
# @return [ Vulnerabilities ]
def vulnerabilities
return @vulnerabilities if @vulnerabilities
@vu... | true |
16faa032bef17de022236806ec35cd3323875dee | Ruby | sumedhpendurkar/rottenpotatoes-rails-intro | /app/models/movie.rb | UTF-8 | 192 | 2.578125 | 3 | [] | no_license | class Movie < ActiveRecord::Base
def self.get_all_ratings
temp = Array.new
self.select('rating').uniq.each {|ele| temp.push(ele.rating)}
temp.sort.uniq
end
end
| true |
c1868abe29277c0f8a161dfc0f6ada128b5f04ab | Ruby | amanelis/netdna2 | /spec/core_ext/hash_spec.rb | UTF-8 | 1,465 | 2.90625 | 3 | [] | no_license | require 'spec_helper'
require File.join(File.dirname(__FILE__), '../../', 'lib/core_ext/hash')
describe Hash do
context "to_q" do
before(:all) do
@hash_0 = {}
@hash_1 = {"page"=>1, "pages"=>10, "page_size"=>"50", "current_page_size"=>50, "total"=>494}
@hash_2 = {page: 1, pages: 10, page_size: ... | true |
c319a4546bfa05aa9ce9b1f1762ff2a974a56f85 | Ruby | ashucoding/programming-univbasics-3-build-a-calculator-lab-online-web-prework | /lib/math.rb | UTF-8 | 313 | 3.09375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def addition(num1, num2)
return num1 + num2
end
def subtraction(num1, num2)
return num1 - num2
end
def division(num1, num2)
return num1 / num2
end
def multiplication(num1, num2)
return num1 * num2
end
def modulo(num1, num2)
return num1 % num2
end
def square_root(num)
Math.square_root (num1, num2)
end
| true |
f779baac0fa7557e6b5c1a0a3811d8e42696b618 | Ruby | colinbull/get-into-teaching-app | /lib/acronyms.rb | UTF-8 | 865 | 3.09375 | 3 | [
"MIT"
] | permissive | class Acronyms
ABBR_REGEXP = %r{\b([A-Z][A-Z]+)\b}.freeze
def initialize(content, acronyms)
@document = parse_html(content)
@acronyms = acronyms || {}
end
def render
@document.tap(&method(:replace_acronyms)).to_html
end
private
def parse_html(content)
Nokogiri::HTML::DocumentFragment.par... | true |
259db24feb8f115aadf5f20186ec4ccd908f0ce4 | Ruby | HopeFrost/ruby_challenges | /love_loop.rb | UTF-8 | 74 | 3.28125 | 3 | [] | no_license |
love = "love"
while (love == "love")
puts "I'll love you forever"
end
| true |
65b17aad18b9fa983f02cf5ea10e95b80d46419f | Ruby | Blaked84/mork | /lib/mork/mimage.rb | UTF-8 | 4,955 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'mork/npatch'
require 'mork/magicko'
module Mork
# @private
class Mimage
include Extensions
attr_reader :rm
attr_reader :choxq # choices per question
attr_reader :status
def initialize(path, grom)
@mack = Magicko.new path
@grom = grom.set_page_size @mack.width, @mack.he... | true |
17f7c866a94ccdb3d7bb2f1fce4525b250a25b1c | Ruby | CalebKnox/ruby-music-library-cli-v-000 | /lib/music-library-controller.rb | UTF-8 | 1,650 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class MusicLibraryController
attr_accessor :path
def initialize(path = "./db/mp3s")
@path = path
MusicImporter.new(@path).import
end
def call
input = ""
while input != "exit"
input = gets.strip
case input
when "list songs"
songs
when "list artists"
artists
when... | true |
47dc04f9febc7014d831379bac0f1c9eab1b7f0f | Ruby | alvesdan/dummy-api | /app/models/dummy_api/response.rb | UTF-8 | 1,387 | 2.640625 | 3 | [] | no_license | require 'active_support/inflector'
require 'ffaker'
module DummyApi
class Response
attr_reader :settings
def initialize(settings)
@settings = settings
end
def to_hash
@to_hash ||= generate_hash
end
private
def generate_hash
{}.tap do |hash|
settings[:data].eac... | true |
628eefb06ae8a4916df1d4ec81d6c71cda71ce19 | Ruby | johngrayau/jg_piawe | /spec/rule_set_spec.rb | UTF-8 | 11,923 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
describe Piawe::RuleSet::Rule do
let (:valid) do
Piawe::RuleSet::Rule.played_by ( {
"applicableWeeks" => "1-26",
"percentagePayable" => 90,
"overtimeIncluded" => true
} )
end
let (:invalid) do
Piawe::RuleSet::Rule.played_by ( {
"applicableWeeks" => "foo",
"percentag... | true |
4f1eb77b8cb81960b2a7ae774ab6f6aa3c5e065c | Ruby | PatrickArthur/profit_margin_generators | /revenue_calculator.rb | UTF-8 | 898 | 3.375 | 3 | [] | no_license | ## ruby class that imports csv of gift cards sold to a business and generates key business
## indicators like cost, income, average spint per order etc....., checks that business
## card value isnt more then the revenue recieved for it and makes sure that
## cards are not redeemed before they are purchased or sold befo... | true |
6737b5ed1303a14709849c36be92d46fbfff39d6 | Ruby | yuichi-1208/vendingmachine | /vending_6.rb | UTF-8 | 2,288 | 3.734375 | 4 | [] | no_license | class VendingMachine
attr_reader :items, :slot_money, :sales_money
def initialize(items:)
@items = items
@slot_money = 0
@sales_money = 0
end
MONEY = [10, 50, 100, 500, 1000].freeze
def slot_money(money)
unless MONEY.include?(money)
puts "お取り扱いできません"
@slot_money += money
r... | true |
b49e40f625220d70e562dcca7b06912bea16bf4c | Ruby | devonhackley/algorithms | /Dynamic Programming/longest_increasing_seqence.rb | UTF-8 | 345 | 3.609375 | 4 | [] | no_license |
def longest_increasing_seq(line)
ary = line.split(", ").map{|i| i.to_i }
res = [ary[0]]
(1...ary.size).each do |i|
if ary[i] > res[-1]
res << ary[i]
elsif ary[i] < res[-1] && ary[i] > res[-2]
res.pop
res << ary[i]
end
end
res
end
a = "15, 27, 14, 38, 26, 55, 46, 65, 0, 85"
p l... | true |
dda8f07889b05ccaa6f2d3b157f58f420fce5d27 | Ruby | pinedevelop/zenvia-sms | /lib/zenvia/sms.rb | UTF-8 | 1,865 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'rest-client'
require 'zenvia/configuration'
require 'zenvia/sms/detail_code'
require 'zenvia/sms/error'
require 'zenvia/sms/status_code'
require 'zenvia/sms/version'
module Zenvia
class SMS
BASE_URL = 'https://api-rest.zenvia.com/services'.freeze
def initialize(from: nil, to:, message:, callback: n... | true |
9aa2feead463b290d25b98b4a440d8253fa318da | Ruby | rgpass/talkative_robot | /talkative_robot.rb | UTF-8 | 1,007 | 4.0625 | 4 | [] | no_license | require 'pry'
# puts "Test message"
# puts "We're running this in the Terminal"
# puts "What is your name?"
# user_name = gets.chomp
# puts "Hey #{user_name}"
# puts "How are you doing?"
# mood = gets.chomp.downcase
# puts "Glad to hear you're #{mood}?"
if 5 > 6
puts "first response"
else
puts "default response... | true |
d5a9ea014d90af06c281381cf9548cf24d850488 | Ruby | tiev/respanol | /lib/respanol/examenes/conjugacion_examen.rb | UTF-8 | 495 | 2.671875 | 3 | [] | no_license | module Respanol
module Examen
class ConjugacionExamen < ExamenBase
def initialize(verbos = nil)
@verbos = Array(verbos)
end
def conjugado(klase = nil)
klases = @verbos
klases = klases | Array(klase) unless klase.nil?
kl = klases.sample
pro = Pronombre.tod... | true |
c3c1f9411308e7eb31c863cf071141ee940a1022 | Ruby | moralesalberto/trebuchet | /trebuchet/trebuchet.rb | UTF-8 | 314 | 2.8125 | 3 | [] | no_license |
class Trebuchet
attr_reader :game_window
def initialize(game_window)
@game_window = game_window
end
def base
@base ||= Base.new(self)
end
def lever
@lever ||= Lever.new(self)
end
def draw
base.draw
lever.draw
end
def update
lever.update
end
end
| true |
135e86a67d0403e54e7d034c41420f05fdb909b5 | Ruby | CodeCoreYVR/awesome_answers_mar_21 | /db/seeds.rb | UTF-8 | 2,571 | 2.796875 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# ... | true |
7f117f648d52ca6ab6613f070c38f2f01ae02852 | Ruby | emattei/BEAR_MBR | /old_ruby/caricaRfamSeed.rb | UTF-8 | 12,007 | 2.765625 | 3 | [] | no_license | class String
def is_upper?
!!self.match(/\p{Upper}/)
end
def is_lower?
!!self.match(/\p{Lower}/)
# or: !self.is_upper?
end
end
IUPAC=["R","Y","M","K","S","W","B","D","H","V","N"]
ACCEPTED=[">","<","."]
def caricaAllineamento(file)
h={}
File.open(file,"r") do |f|
while line=f.gets
if line... | true |
5ea9e1b726709fe97e3b47c6f0b807db9d5f1db4 | Ruby | nitinkumarsagtani/My_Training_Repo | /Assignment-1/pyramid.rb | UTF-8 | 637 | 4.3125 | 4 | [] | no_license | #Program to print Star Pyramid
class Pyramid
def initialize(no_of_lines)
@no_of_lines = no_of_lines
end
def validate_input
@no_of_lines > 1
end
def show
puts "The pyramid of #{@no_of_lines} lines is : "
@no_of_lines.times do |index|
((@no_of_lines - 1) - index).times do
prin... | true |
29ee21c869eebe45426c36a66a1f1da50cfe5327 | Ruby | PeytonsProfile/erbcalculate | /calculator.rb | UTF-8 | 634 | 4.3125 | 4 | [] | no_license | def firstNumber
puts 'first number'
first_number = gets.chomp.to_i
first_number
end
def secondNumber
puts 'second number'
second_number = gets.chomp.to_i
second_number
end
def question
puts 'Would you like to [add] or [subtract] or [multiply] or [divide]'
operator = gets.chomp
if operator == 'add'
a... | true |
462d0906c7e7bba456b6725d8c440389d4a9be78 | Ruby | spencereir/SpencerC | /command.rb | UTF-8 | 736 | 3.21875 | 3 | [] | no_license | $commands = {
"variableDeclaration" => "dec",
"print" => "LOUDLYWHISPER",
"input" => "INPUTAVARIABLEPLS"
}
$command_help = {
"#{$commands['variableDeclaration']}" => "Used to declare a variable.\nSyntax: #{$commands['variableDeclaration']} (variable name) = (value)",
"#{$commands['print']}" => "Used to print... | true |
98ac104f46c01be2b7112f1d87bd9836976fadd1 | Ruby | ysdyt/rc2012w_g4 | /howto.rb | SHIFT_JIS | 755 | 2.53125 | 3 | [] | no_license | #encoding: Shift_JIS
class HowTo
def initialize
@setumei = Image.load("images/setumei1.png")
@setumei2 = Image.load("images/setumei2.png")
@bgm = Sound.new("BGM/story.wav")
#$select = 0 #KvȂ
end
def start
@how_flag1 = true
@how_flag2 = false
end
def act
if @how_flag1 == true
Window.dr... | true |
f4770ef7578f0e203e08cd17aed1ff3aeae9ffa3 | Ruby | danvideo/BEWD_NYC_5_Homework | /Dan_Schanler/midterm/wunderground.rb | UTF-8 | 1,160 | 3.078125 | 3 | [] | no_license | # wunderground.rb
require 'rest-client'
require 'JSON'
$API_KEY = ENV['WUNDERGROUND_API_KEY']
# can get an API key from their site and put it into ENV variables as WUNDERGROUND_API_KEY
# http://www.wunderground.com/weather/api
class WeatherQuery
attr_reader :city, :state_country
def initialize city, state_countr... | true |
85c10b0020c5bad11d6061c585f68b5737d3c677 | Ruby | mful/nyc_housing_code_violations | /tasks/export_global_stats.rb | UTF-8 | 3,044 | 3.0625 | 3 | [] | no_license | require 'date'
require 'csv'
require_relative '../init'
require_relative '../models/building'
require_relative '../models/housing_violation'
COLUMNS = [
'Time period',
'Filed',
'Resolved',
'Mean resolution time',
'Median resolution time',
'Resolved overdue',
'Resolved mean overdue time',
'Resolved medi... | true |
179237b7188ae63e319b9feb0856ea7ad5b9e594 | Ruby | shekbagg/Color-My-Hex | /app/models/image.rb | UTF-8 | 1,080 | 3.25 | 3 | [] | no_license | require 'chunky_png'
require 'colorscore'
# Image and color processor for the bot
class Image
# Location to store temporary images created
PATH = 'public/temp/'
IMG_WIDTH = 200
# Return file containing image of the given hex color
def self.get_image_for_hex(hex)
# Creating an image from scratch, save a... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.