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
0ae0b759ed22698f603dc62a1944edafe0bc5ffa
Ruby
Awilmerding1/prime-ruby-v-000
/prime.rb
UTF-8
364
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime?(integer) i = 3 array = (i..integer-1).to_a if integer == 1 return false elsif integer < 0 return false elsif integer == 2 || integer == 3 return true end while integer.even? == true return false end array.all? do |prime| if integer % prime > 0 true ...
true
43cd4950e1af1348ab6dc109015fcbcdad4b88fa
Ruby
ECOtterstrom/IntroToProgRuby
/8_more_stuff/ex_84.rb
UTF-8
136
3.109375
3
[]
no_license
# 8_more_stuff exercise 4 def execute(&block) block.call end execute {puts "Hello from inside the execute method!"}
true
528624e8e62eb1eb48fbb30d46448a866d2b759d
Ruby
ted-scanlan/battle-challenge-new
/spec/player_spec.rb
UTF-8
888
3.296875
3
[]
no_license
require 'player.rb' describe Player do other_player = Player.new('other') it 'returns player name' do tester = Player.new('Ted') expect(tester.name).to eq 'Ted' end it 'returns player hit points' do tester = Player.new('Ted') expect(tester.hit_points).to eq 60 end describe "#attack" do ...
true
53d363b0a2630dc7a67553941a7eb96a2a8172f4
Ruby
dinarka/ruby_lesson3
/quad_equation.rb
UTF-8
639
3.53125
4
[]
no_license
puts 'Введите коэффициент а:' coef_a = gets.chomp.to_f puts 'Введите коэффициент b:' coef_b = gets.chomp.to_f puts 'Введите коэффициент c:' coef_c = gets.chomp.to_f discr = coef_b ** 2 - (4 * coef_a * coef_c) if discr > 0 d_sqrt = Math.sqrt(discr) x1 = (-coef_b + d_sqrt) / 2 * coef_a x2 = (-coef_b - d_sqrt) / ...
true
68335d2c437383e960fa8b9618fb2f6dc7bf9dc2
Ruby
AdamPrusse/metaprogramming
/metaprogramming_example_2.rb
UTF-8
245
4
4
[]
no_license
class String def censor(bad_word) self.gsub! "#{bad_word}", "CENSORED" end def num_of_chars size end end # p "The bunny was in trouble with the king's bunny".censor("bunny") p "Paul is such a bunny bunny bunny bunny bunny".num_of_chars
true
1047f6faeac6aa545ea8243fcb9d73b6881931d5
Ruby
jasmarc/PageRank
/main.rb
UTF-8
2,451
3.25
3
[]
no_license
$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib' require "rubygems" require "PageCollection" require "pp" require "PageRank" require "yaml" # This is the cache file. We don't want to spider if we don't # have to. It takes a long time. FILE = "collection.yaml" # Let's read that file from Dr. Ginsparg collection = Pa...
true
bba4c47c7014c47b25fd938ab8c58db8b3a6a6d8
Ruby
chaochaocodes/ruby-oo-relationships-practice-blood-oath-exercise-seattle-web-120919
/app/models/cult.rb
UTF-8
1,256
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Cult attr_accessor :slogan, :follower, :location, :founding_year attr_reader :name @@all = [] # @@follower_list = [] def initialize(name, location, year, slogan) @name = name @location = location @founding_year = year @slogan = slogan @@all << self ...
true
6079f971f043f65305912a68bb8e81bb6966579a
Ruby
Etsap/my-advent
/adventofcode2016/problem06.rb
UTF-8
683
3.453125
3
[]
no_license
input = "" File.open("input06.txt", 'r') {|f| input = f.read} counter = [{}, {}, {}, {}, {}, {}, {}, {}] input.split(/\s+/).each do |line| (0..7).each do |i| counter[i].has_key?(line[i]) ? counter[i][line[i]] += 1 : counter[i][line[i]] = 1 end end result1 = result2 = "" (0..7).each do |i| ...
true
43e28996337e5bbbddb6336ac53f86a3327b9fec
Ruby
davidmunoz4185/udacitask
/todolist.rb
UTF-8
1,700
3.703125
4
[]
no_license
class TodoList # methods and stuff go here def initialize(list_title) @title = list_title @items = Array.new # Starts empty! No Items yet! end attr_accessor :title, :items def add_item(new_item, priority=0) item = Item.new(new_item,priority) @items.push(item) end def rename(list_title) ...
true
1bbebd95f87a15ecfb4842d44bcae16eb095eb95
Ruby
fanjieqi/LeetCodeRuby
/901-1000/901. Online Stock Span.rb
UTF-8
494
3.421875
3
[ "MIT" ]
permissive
class StockSpanner def initialize() @array, @index, @k = [], [], 0 end =begin :type price: Integer :rtype: Integer =end def next(price) i = @array.bsearch_index { |ele| ele > price } || @array.size @array.insert(i, price) @index.insert(i, @k) @k += 1 maxi = @index[i+1..-1].max ma...
true
1d2a13c6907925768717eedca81b2e5c3eca4176
Ruby
emadb/playground
/hackerrank-meeting-point/app.rb
UTF-8
1,504
3.890625
4
[]
no_license
# https://www.hackerrank.com/challenges/meeting-point class Point < Struct.new(:x, :y, :distance); end class MeetingPoint def evaluate(map) first = map[0] index = 0 map.each do |p1| p1.distance = 0 map.each do |p2| p1.distance = p1.distance + get_distance(p1, p2) ...
true
03ec108cdfeb4bc5ac756bfaa2675d39944f5f9b
Ruby
amenning/RSpec_TutorialsPoint
/spec/comparison_matchers_spec.rb
UTF-8
408
2.703125
3
[]
no_license
describe "An example of the comparison Matchers" do it "should show how the comparison Matchers work" do a = 1 b = 2 c = 3 d = 'test string' # The following Expectations will all pass expect(b).to be > a expect(a).to be >= a expect(a).to be < b expect(b).to be <= b expect(c).to be_between(1,3)....
true
a371d7656f3f87a33af28e99ff5c47db83f86b72
Ruby
davekinkead/ristretto
/specs/ristretto_spec.rb
UTF-8
600
2.53125
3
[ "MIT" ]
permissive
require 'ristretto' require 'minitest/autorun' describe Ristretto do let(:parsed_markdown) { Ristretto.parse('specs/specification.md') } describe "#execute" do it "executes simple ruby code" do Ristretto.execute(parsed_markdown).must_equal 890 end it "parsed required ristretto files" end ...
true
e4ea7bfcaaff8f237249237f2e1e92f40963d19e
Ruby
angusjfw/takeaway-challenge
/lib/takeaway.rb
UTF-8
990
3.578125
4
[]
no_license
require_relative 'menu' require_relative 'order' require_relative 'phone' class Takeaway ERROR = 'Cannot place order: ' TOTAL = 'total does not match pricing!' DISH = ' not available!' def initialize(menu=Menu.new, order_klass=Order, phone=Phone.new) @the_menu = menu @order_klass = order_klass @ph...
true
860d19faf198cb3e288ee68a79b7b3df1052615f
Ruby
vcavallo/flatiron-assignments
/oojukebox.rb
UTF-8
1,421
3.734375
4
[]
no_license
class Jukebox def initialize(songs) @songs = songs @command = "" end def play puts "make a selection (song name) or type 'list' again:" @choice = gets.chomp.downcase puts "--> Now Playing: #{@songs .select {|song| song.downcase.include?(@choice)}}" if @choice == "list...
true
842ed8afedda1470343f0fbcc8964a629216c433
Ruby
Chakaitos/algorithms-sort
/sort.rb
UTF-8
1,339
3.609375
4
[]
no_license
module Sort def self.selection_sort(array) arr = array.clone n = arr.size if arr.size <= 1 return arr end n.times do |index| min_index = index (index+1).upto(n-1) do |i| if arr[i] < arr[min_index] min_index = i end end arr[index], arr[min_index] = arr[min_...
true
0586df9be16f7b756abcd03d8a6915d4c1717b30
Ruby
colleeno/landlord
/db/seeds.rb
UTF-8
1,160
2.609375
3
[]
no_license
require 'active_record' require_relative 'connection' require_relative '../models/apartment' require_relative '../models/tenant' Apartment.destroy_all Tenant.destroy_all Apartment.create(address: '1401 S Street', monthly_rent: 4000, sqft: 1500, num_beds: 2, num_baths: 2) Apartment.create(address: '867 Main Street',...
true
045b931bb537c5da22a8f3364a170d52cd6159f3
Ruby
jbuelna/galleriamacondo
/app/models/location.rb
UTF-8
569
2.515625
3
[]
no_license
class Location < ActiveRecord::Base has_many :paintings validates_presence_of :name, :address_line_1, :city, :state, :zip, :lat, :lng before_validation_on_create :geocode_address before_validation_on_update :geocode_address def address "#{address_line_1} #{address_line_2}, #{city}, #{state}" end ...
true
ded964344b8be99945fc71f45e3cb40dbccb5b24
Ruby
FlipTech9/countdown-to-midnight-online-web-prework
/countdown.rb
UTF-8
454
3.875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#write your code here def countdown (starting_number) phrase = "HAPPY NEW YEAR!" starting_number = 10 while starting_number !=0 puts "#{starting_number} SECOND(S)!" starting_number -=1 end phrase end def countdown_with_sleep(starting_number) phrase = "HAPPY NEW YEAR!" starting_number = 10...
true
72e7028741f1bc8806544716e75e629ebf0584ca
Ruby
davet1985/social-challenges
/api/app/model/user.rb
UTF-8
5,733
2.703125
3
[]
no_license
require 'bcrypt' require 'net/smtp' require 'yaml' $db = SQLite3::Database.open './hashbang.db' class User /USERS =/ CONFIG = YAML.load_file("./config/config.yml") unless defined? CONFIG include BCrypt attr_reader :name attr_reader :id attr_reader :token def initial...
true
5d9ccaa9ab3eb347613c175e6ac29479a0a080f3
Ruby
maschwenk/ruby-sdk
/lib/paymentrails/Client.rb
UTF-8
2,560
2.65625
3
[ "MIT" ]
permissive
# require_relative 'Exceptions.rb' require 'digest' require 'net/http' require 'openssl' require 'uri' require 'json' module PaymentRails class Client def initialize(config) @config = config end def get(endPoint) send_request(endPoint, 'GET') end def post(endPoint, body) body ...
true
9f1f3795c080378eda866bb3796df099f5aa968a
Ruby
Gabbendorf/Ruby-Tic-Tac-Toe
/spec/game_spec.rb
UTF-8
2,965
3.1875
3
[]
no_license
require 'spec_helper' require_relative '../lib/game' require_relative '../lib/ui' require_relative '../lib/grid' RSpec.describe Game do let(:grid) {Grid.new(3)} let(:output) {StringIO.new} let(:input) {StringIO.new("h\n4")} let(:ui) {Ui.new(input, output)} let(:game) {Game.new} let(:human_player) {HumanPl...
true
2a9fdc734ea21bd90edcd58405e5da808853e42d
Ruby
claudia-mccormack/contacts-app
/ruby_practice/oop8.rb
UTF-8
1,589
3.609375
4
[]
no_license
# Create Person class class Person def initialize(first_name, last_name, hair_color, hobbies) @first_name = first_name @last_name = last_name @hair_color = hair_color @hobbies = hobbies end def first_name return @first_name end def last_name return @last_name end def full_name ...
true
6f94732c308581a5af68cba0d7e13a0493724cd5
Ruby
tnypxl/taza
/lib/taza/site.rb
UTF-8
4,673
2.984375
3
[ "MIT" ]
permissive
module Taza # An abstraction of a website, but more really a container for a sites pages. # # You can generate a site by performing the following command: # $ ./script/generate site google # # This will generate a site file for google, a flows folder, and a pages folder in lib # # Example: # # ...
true
f63f9324bc48e01805b4d11af2517cf596c0662b
Ruby
bugsnag/maze-runner
/lib/maze/client/bs_client_utils.rb
UTF-8
6,583
2.5625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Maze module Client # Utils supporting the BrowserStack device farm integration class BrowserStackClientUtils class << self # Uploads an app to BrowserStack for later consumption # @param username [String] the BrowserStack username # @param a...
true
6672134d2c81c1e51571dcd9223542aec6fe1cd2
Ruby
Epigene/nimbler-path
/lib/nimbler_path.rb
UTF-8
5,864
3.28125
3
[ "MIT" ]
permissive
require "nimbler_path/version" require 'ffi' module NimblerPath def self.test # binding.pry string = "yay!" puts string return string end def self.nim_binary_to_use @@nim_binary_to_use ||= case ruby_platfrom_string when %r'64.*linux'i "64-linux" when %r'darwin' ...
true
c67845e5d91b4998dfbcc4c2855815957d39b480
Ruby
dexterfitch/resume-helper
/spec/resume_helper_spec.rb
UTF-8
2,670
2.75
3
[ "MIT" ]
permissive
require('rspec') require('resume_helper') describe("Resume") do before() do Resume.clear() end describe("#employer") do it('reads out the name of the employer') do test_job = Resume.new("Pickleworld","Pickle Farmer","Farmed a lot of cukes","01/01/2001", "07-07-2007") expect(test_job.employer...
true
58c873ffe674fe30861e5cd29c65a35d74263a24
Ruby
archiefielding/Battleships
/spec/board_spec.rb
UTF-8
588
2.71875
3
[]
no_license
require 'board' describe Board do it "can place a single cell ship" do ship = Ship.new expect(subject.place(ship, "A1")).to include(0) end it "can place a multi-cell ship" do ship = Ship_2.new(2) expect(subject.place(ship, 0)).to match_array(%w[0 0 A3 A4 A5 A6 A7 A8 A9 A10 B1 B2 B3 B4 B5 B6 B7 B8 ...
true
5176008c4937f934f674f04d4a060f21f812cef0
Ruby
m-negishi/ruby_training
/TeachYourselfRuby/section7/7.2.2.rb
UTF-8
701
3.71875
4
[]
no_license
# Dogクラス class Dog attr_reader :kind attr_writer :meal def initialize(k = 'Mongrel') @kind = k @meal = nil end # アクセスメソッドで代替 # def kind # @kind # end # def kind=(k) # @kind = k # end # アクセスメソッドで代替できる # def meal=(food) # puts 'エサを与える' # @meal = food # # end def fe...
true
2a5bb764ac2251904a1010d7a313773a715c7757
Ruby
thierrymoudiki/phase-0-tracks
/ruby/gps_2_2.rb
UTF-8
2,007
4.28125
4
[]
no_license
# Method to create a list # input: string of items separated by spaces (example: "carrots apples cereal pizza") # steps: def create_list_items(input_string) hsh = {} # create an array containing each item array_input = input_string.split(' ') # create a hash from the array (iterate), containing the...
true
fff2995bf15aa888159e78029802bb9925362f8d
Ruby
mamiyamahara/DWC-Task
/Ruby/第八章/for.rb
UTF-8
74
3.359375
3
[]
no_license
for i in 1..10 do # 1..10は、1~10までの範囲を表す puts i end
true
d56e72f75a795676813903a3e33f042f745baca7
Ruby
toksaitov/scenario
/lib/scenario/objects/pipe.rb
UTF-8
1,214
2.5625
3
[ "MIT" ]
permissive
# Scenario is a Ruby domain-specific language for graphics. # Copyright (C) 2010 Dmitrii Toksaitov # # This file is part of Scenario. # # Released under the MIT License. module Scenario class Pipe < Generic include Degradable meta_accessor :radius, :level, :update_call => true def initial...
true
e521d66c26b16178e7b70967e73d7f55537906eb
Ruby
cielavenir/procon
/atcoder/tyama_atcoderdwacon2018prelimsB.rb
UTF-8
81
2.796875
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby s=gets.chomp;i=0;i+=1 while s.gsub!('25','');p s.empty? ? i : -1
true
aa01f5771de88c4acef2d4bee14fe3202f3b2e37
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/simple-linked-list/91ef897999984449a9a6084155000d1b.rb
UTF-8
1,068
3.359375
3
[]
no_license
class Element attr_reader :datum, :next def self.to_a(element) element.to_a end def self.from_a(source) source.to_a.reverse.reduce(nil) do |list, datum| self.new datum, list end end def initialize(datum, next_one) @datum = datum @next = next_one end def...
true
73ada39e49ea973ecde1b4cb6608a2aa56f88288
Ruby
hellosweta/poker_assessment
/lib/hand.rb
UTF-8
1,277
3.703125
4
[]
no_license
require_relative 'card' require_relative 'poker_hands' class Hand include PokerHands def initialize(cards) raise "must have five cards" if cards.length != 5 @cards = cards end attr_accessor :cards RANKS = [ :royal_flush, :straight_flush, :four_of_a_kind, :full_house, :flush, ...
true
fbd3917d3dbac5b99f352d2ff2e3c14dc689e84e
Ruby
jordanpoulton/ruby_kickstart
/session2/5-solved/2.rb
UTF-8
3,180
4.125
4
[ "MIT" ]
permissive
#paul fitz def hi_hi_goodbye # your code here puts "Enter a number" #ask user to input a number while answer = gets.chomp #while loop used to keep looping until the user inputs "bye" number = answer.to_i #can't use to_i on same line as gets number.times {|x| puts "hi"} #based on number the user i...
true
c51291bb0181276a655716c580d215b3a4586718
Ruby
jahman07104/programming-univbasics-3-labs-with-tdd-online-web-prework
/calculator.rb
UTF-8
94
2.578125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
dec calculator def first_number 6 second_number 4 puts first_number + second_number end
true
c14ffa63fc46e49ceb0473bfe2df8e0fb86950fc
Ruby
fadieh/BORIS_BIKES_ruby
/spec/bike_container_spec.rb
UTF-8
1,164
3.015625
3
[]
no_license
require 'bike_container' class BikeHolder; include BikeContainer; end describe BikeContainer do let(:bikeholder) { BikeHolder.new } let(:bike) { double :bike, :broken? => false } let(:broken_bike) { double :bike, :broken? => true } it "should have a default capacity" do holder = BikeHolder.new expect(bike...
true
156dcfda4bc1ab753f9dbf202b83360a69b0e8d8
Ruby
jetsgit/set_game
/lib/constants.rb
UTF-8
471
2.515625
3
[ "MIT" ]
permissive
module SetGame ## # Constants used in the Set Game module Constants MASK = 7 BITS = 0 COLOR_MASK = BITS | MASK SHAPE_MASK = BITS | (MASK << 3) PATTERN_MASK = BITS | (MASK << 6) NUMBER_MASK = BITS | ( MASK << 9 ) COLOR = [ {red: 1}, {green: 2 }, {purple: 4}] SHAPE = [ {diamond: 8},...
true
36e6949e9ce0d827033e23710ec9986e11622000
Ruby
ramprabhu-idexcel/bowling-club
/app/models/bowling.rb
UTF-8
4,160
3.046875
3
[ "MIT" ]
permissive
class Bowling include ActiveModel::Model attr_accessor :turns, :bonus, :total_frames_score, :game_bonus validate :cannot_be_greater_than_10 validate :validate_bonus # initialize with bowling attributes def initialize(turns) @total_frames_score = [] @turns = turns ## If the user enter 11 input t...
true
1287e162e2e5dafff47286446014f3ce46109b5d
Ruby
antonror/riskmethods_test
/app/services/companies_list.rb
UTF-8
2,133
2.953125
3
[]
no_license
# frozen_string_literal: true class CompaniesList ValidationError = Class.new(StandardError) def initialize(params) @params = params @errors = [] @companies = nil @filters = {} end def call validate_params! extract_companies supply_data rescue ValidationError { errors: @err...
true
6e0356ff3b001b101b398b1d478486924670f74d
Ruby
Dalf32/EconomicSim
/data/sim_data_builder.rb
UTF-8
3,545
3.015625
3
[]
no_license
# frozen_string_literal: true # sim_data_builder.rb # # Author:: Kyle Mullins require 'json' require_relative 'sim_data' require_relative 'commodity' require_relative 'agent_role_builder' # Builds the SimData class SimDataBuilder # Builds the SimData from a specification file (JSON) # # @param params_file [...
true
9a7613661d464c7f10fa158de6b9f060e4eac47a
Ruby
nyc-squirrels-2016/wanna_watch
/app/models/event.rb
UTF-8
1,010
2.53125
3
[]
no_license
class Event < ActiveRecord::Base belongs_to :host, class_name: :User has_many :requests, dependent: :destroy has_many :guests, through: :requests, dependent: :destroy validates :show, presence: true validates :time, presence: true validates :date, presence: true validates :host, presence: true validate...
true
dcbb67904fc8c5d8cb520b5d46200e9d5dae4c9a
Ruby
recortable/Cuentas
/app/models/year.rb
UTF-8
1,859
2.625
3
[]
no_license
class Year < ActiveRecord::Base before_save :report! serialize :report belongs_to :account def balance after_ammount - before_ammount end def balance_before before_ammount end def balance_after after_ammount end def months Month.where(:year => self.number, :account_id => self.acc...
true
7fab976948ac253edd8c4476475b98f3c3dc369f
Ruby
gitter-badger/heelbot
/lib/heel/bot_manager.rb
UTF-8
1,004
2.734375
3
[ "MIT" ]
permissive
module Heel class BotManager BOT_CONF_NAME = "heelspec/bots.yaml" @new_conf = false attr_reader :bot_list def initialize @bot_list ||= [] load_bots end def add_bot(bot_name) end def remove_bot(bot_name) end def run_bot(bot_name, bot_cmd) require_relativ...
true
37f772e207134eaf783cc3e41bcfff9d24493dbd
Ruby
justinsilvestre/recursion
/mergesort.rb
UTF-8
933
3.609375
4
[]
no_license
def merge_sort_rec(nums) num_chunks = nums.map { |n| [n] } merge_chunks(num_chunks) end def merge_chunks(all_chunks) return all_chunks[0] unless all_chunks.length > 1 sorted_chunks = [] all_chunks.each_slice(2) do |chunks| merged_chunks = merge_pair(chunks[0], chunks[1]) sorted_chunks << merged_chunks end ...
true
ea0dbf7f651b5372fb8bc8577f2eb5d11f8ab043
Ruby
t1gerk1ngd0m/service-practice-app
/app/forms/transfer_money_form.rb
UTF-8
804
2.546875
3
[]
no_license
class TransferMoneyForm include Virtus.model include ActiveModel::Model attribute :transfer_amount, Integer attribute :from_user_id, Integer attribute :to_user_id, Integer attribute :currency, Integer validates_presence_of %i( transfer_amount from_user_id to_user_id ) def run from_...
true
37cc13ad2eba9942057b176a4412fbd85bf8474d
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/grains/0049c96c789f4f6c8dd25c23c417140c.rb
UTF-8
169
3.4375
3
[]
no_license
# 1, 2, 4, 8, 16, ... class Grains def square x (2 ** (x-1)) end def total sum = 0 for i in (1..64) sum += square(i) end sum end end
true
93d1f4a6c98784a8befd8286853f4a0c82e9aef1
Ruby
samlouiscohen/Genesis
/rtests/fail-expr2.god
UTF-8
164
2.8125
3
[]
no_license
void init(){} void update(int f){} int a; bool b; void foo(int c, bool d) { int d; bool e; b + a; /* Error: bool + int */ } int main() { return 0; }
true
ea9899430e8f938ec2c154fa1936004216b4d24f
Ruby
Nroulston/school-domain-onl01-seng-ft-052620
/lib/school.rb
UTF-8
525
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code here! require "pry" class School def initialize(school) @school = school @roster = {} end def roster @roster end def add_student(name, grade) unless @roster.has_key?(grade) @roster[grade] = [] end @roster[grade] << nam...
true
385fa2404588d5e3737e5008d8aae321c71da489
Ruby
dominicsayers/json_validation
/lib/json_validation/validators/items.rb
UTF-8
1,397
2.609375
3
[ "MIT" ]
permissive
module JsonValidation module Validators class Items < Validator type :array def validate(value, value_path) case schema['items'] when Schema value.each_with_index.all? {|item, ix| inner_validator.validate(item, value_path + [ix.to_s])} when Array inner_vali...
true
70885c3da29ee4ce23ba3e0d2b97d07eced07391
Ruby
namespace-team/ruby-core-challenges
/square_each_digit/square_each_digit.rb
UTF-8
519
3.34375
3
[]
no_license
def square_each_digit num # Write your code here end describe "#square_each_digit" do context "it is a number" do it "returns square of each digit" do expect(square_each_digit(3211)).to eq(9411) expect(square_each_digit(654326)).to eq(3625169436) expect(square_each_digit(1111)).to eq(1111) ...
true
e3faa1718b0a6be1d22c428def754f9250b8f90a
Ruby
webclinic017/dxmodel
/app/models/stock.rb
UTF-8
779
2.5625
3
[]
no_license
class Stock < ActiveRecord::Base has_many :stock_dates, :dependent => :destroy has_many :trades, :dependent => :destroy belongs_to :industry validates :ticker, :presence => true, :uniqueness => {:scope => :country} validates :name, :presence => true validates :country, :presence => true validates :curr...
true
6d8055fa2997eef0f055b079580eda0529f676ca
Ruby
savagesnake/flashcard
/controller.rb
UTF-8
1,231
2.953125
3
[]
no_license
require_relative "parser" class Controller attr_reader :view,:deck attr_accessor :score def initialize @view = View.new @deck = Deckmodel.new end def load_game commands = ARGV return view.choose_deck if commands.empty? return view.choose_deck if commands[0].downcase == "help" ...
true
d410dd302e26cd8b6c4d8189ce38cf6d41554c29
Ruby
mtodd/flipper
/spec/flipper/adapter_spec.rb
UTF-8
12,094
2.515625
3
[ "MIT" ]
permissive
require 'helper' require 'flipper/adapter' require 'flipper/adapters/memory' require 'flipper/instrumenters/memory' describe Flipper::Adapter do let(:local_cache) { {} } let(:source) { {} } let(:adapter) { Flipper::Adapters::Memory.new(source) } let(:features_key) { described_class::FeaturesKey } ...
true
969181e4818d3a035ab6e0afe237819a52398b61
Ruby
sds/scss-lint
/lib/scss_lint/linter/property_spelling.rb
UTF-8
1,858
2.75
3
[ "MIT" ]
permissive
module SCSSLint # Checks for misspelled properties. class Linter::PropertySpelling < Linter include LinterRegistry KNOWN_PROPERTIES = File.open(File.join(SCSS_LINT_DATA, 'properties.txt')) .read .split .to_set def visit_r...
true
e66e1ac17cbf1f7be09cf8ef857cdbdc78750849
Ruby
vickyban/rubyBasic
/stdin.rb
UTF-8
406
4.21875
4
[]
no_license
# print "Please put your string here!" # # gets will prompt and ad new line to the input # user_input = gets.chomp # user_input.downcase! puts "Enter a number: " num1 = gets.chomp() # chomp remove the new line at the end of the input puts "Enter another number: " num2 = gets.chomp() puts (num1.to_i + num2.to_i ) ...
true
a1d516ddf76a6b8b94d275fb6bdc9c0c7dc4fca9
Ruby
lee-angela/ThreadFeed
/test/models/shop_post_test.rb
UTF-8
1,012
2.59375
3
[]
no_license
require 'test_helper' class ShopPostTest < ActiveSupport::TestCase def setup @shop = shops(:madewell) # This code is not idiomatically correct. @shop_post = @shop.shop_posts.build(content: "Lorem ipsum") end test "should be valid" do assert @shop_post.valid? end test "user id should be pre...
true
e89144cbfb0695537e95bdaf6396c116b2573f1c
Ruby
lokibyte/myRubycode
/Ruby codes/Ruby Examples/sequel_examples/te.rb
UTF-8
174
2.765625
3
[]
no_license
a=[] name=nil while name !='q' do name=gets.chomp a.push(name) p a # break name =='loki' end # if name =='loki' then # until name =='loki' # a.pop() # p a # end # end
true
ea03d0e6c08ef3fead5eb2e4b2a4f3ad93601b8e
Ruby
mlh758/redis_stream_logger
/lib/redis_stream_logger/log_device.rb
UTF-8
4,143
2.765625
3
[ "MIT" ]
permissive
require 'logger' require "redis_stream_logger/config" module RedisStreamLogger class LogDevice attr_reader :config # # Creates a new LogDevice that can be used as a sink for Ruby Logger # # @param [Redis] conn connection to Redis # @param [String] stream name of key to write to ...
true
e6f65e4ca697c646dc94123b427bc883750be1d9
Ruby
mjwebdev/number_game
/app/controllers/numbers_controller.rb
UTF-8
543
2.65625
3
[]
no_license
class NumbersController < ApplicationController def index if !session[:random] session[:random] = rand(1..100) end end def random end def guess session[:guess] = params[:guess].to_i redirect_to "/result" end def result if session[:guess] > session[:random] flash[:high] = "You gue...
true
cc86212bde59fb0ddce2dfbdda2815adf0a9eacd
Ruby
SnowD0g/adapter_pattern
/rectangle.rb
UTF-8
233
3.828125
4
[ "Apache-2.0" ]
permissive
require_relative 'shape' class Rectangle < Shape def initialize(x1, y1, x2, y2) @x1, @y1, @x2, @y2 = x1, y1, x2, y2 end def draw puts "#{super} primo punto (#{@x1}, #{@y1}) e secondo punto (#{@x2}, #{@y2})" end end
true
d68cce0bf4926ce055619de60e8d3179f990149f
Ruby
OliDM/order-of-the-pixel
/spec/heroes_spec.rb
UTF-8
1,961
2.59375
3
[]
no_license
ENV['RACK_ENV'] = 'test' gem "minitest" require 'rack/test' require 'minitest/autorun' require_relative '../app.rb' require_relative 'helpers.rb' # Custom methods to simulate Rspec’s “expect {}.to change {}.by(x)”. include Rack::Test::Methods def app Sinatra::Application end describe "See all heroes"...
true
a8208c2de16e2df77df4075439811bf013fbf120
Ruby
mattistrading/acts_as_gold
/test/acts_as_gold_test.rb
UTF-8
2,180
2.890625
3
[ "MIT" ]
permissive
require 'test/unit' require 'rubygems' gem 'activerecord', '>= 1.15.4.7794' require 'active_record' require "#{File.dirname(__FILE__)}/../init" ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:") def setup_db ActiveRecord::Schema.define(:version => 1) do create_table :players...
true
31f247639463e2a072cd1ee3281d2479a023ce38
Ruby
Packmanager9/Soil-to-life
/soily.rb
UTF-8
11,507
3.015625
3
[]
no_license
require "TextGrapher" $xrange = 80 $yrange = 80 $steps = 2000 class Fighter attr_accessor :name, :status, :x, :y, :r, :g, :b, :all @@all = [] def initialize(name, x, y, status, r, g, b) @name = name @status = status @x = x.to_i @y = y.to_i @r = r @g = g ...
true
ad2cc6ff69fd93845e0f2bb51aa1b4217a63e299
Ruby
auroralemieux/stacks-queues
/lib/Stack.rb
UTF-8
417
3.671875
4
[]
no_license
class Stack def initialize @store = Array.new end def push(element) @store << element end def pop raise ArgumentError.new "Can't pop from an empty stack!" if @store.empty? @store.pop end def top @store.last end def size @store.length end def empty? if @store.length...
true
019da4b304f10bea1f9089bc86b1a16ff03cdc76
Ruby
scottwedge/coding-refresher
/src/practice/session-1/max_subarray_product.rb
UTF-8
670
3.640625
4
[ "MIT" ]
permissive
=begin Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: Input: [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6. Example 2: Input: [-2,0,-1] Output: 0 Explanation: The result cannot be 2, because [-2,...
true
bb881da26539abbf97ed23ad5a369357e33af631
Ruby
wendy0402/jsm
/lib/jsm/callbacks/callback.rb
UTF-8
616
3.5
4
[ "MIT" ]
permissive
# the purpose of this class is to store the block that will be used as callback # e.g: # Jsm::Callbacks::Callback.new(:before) do # put 'me awesome' # end class Jsm::Callbacks::Callback FILTER_TYPES = [:before, :after] attr_reader :filter_type # the allowed filter_type: :before, :after def initialize(filter...
true
6be783f2fbed821bb50be38f874e084984ad326c
Ruby
hivan/Ruby_Learn
/Programming/ex0016.rb
UTF-8
79
2.9375
3
[]
no_license
def say_goodnight(name) "Good night, #{name}" end puts say_goodnight("Ma")
true
f0093313f7d92afbe22df9f1bebf068d2f531332
Ruby
czycha/recluse
/lib/recluse/cli/roots.rb
UTF-8
1,716
2.59375
3
[ "MIT" ]
permissive
require 'thor' require 'user_config' module Recluse module CLI ## # Roots related commands. class Roots < Thor #:nodoc: all desc 'add profile pattern1 [pattern2] ...', 'add to roots' def add(name, *roots) uconf = UserConfig.new '.recluse' unless uconf.exist?("#{name}.yaml") ...
true
baa3df70a1f28012551c35e816696af6ee1b5a5a
Ruby
NoahZinter/black_thursday
/spec/invoice_item_spec.rb
UTF-8
4,246
2.578125
3
[]
no_license
require './lib/invoice_item' require 'bigdecimal' require 'time' describe InvoiceItem do describe '#initialize' do it 'exists' do ii_details = { id: 6, item_id: 7, invoice_id: 8, quantity: 1, unit_price: BigDecimal(10.99, 4), created_at: Time.now, upd...
true
e5b5bae74a98e5196e8fa4838cbb34fdeb6e90ef
Ruby
thoran/AsxhistoricaldataCom
/lib/Date/betweenQ.rb
UTF-8
323
3.34375
3
[]
no_license
# Date/betweenQ # Date#between? # 20120412 # 0.0.0 # Description: This determines whether a date is between two other dates inclusively, with no particular order to the to arguments. class Date def between?(date_1, date_2) (self <= date_1 && self >= date_2) || (self >= date_1 && self <= date_2) end e...
true
8d2160d7472cd954bd742dc982cd6196cfbfe871
Ruby
daniel-certa-1228/Ruby-TDD-Demo
/magic_ball_test.rb
UTF-8
1,596
3.328125
3
[]
no_license
#Ruby Unit Testing require 'minitest/autorun' require_relative 'magic_ball.rb' #using a gem called minitest - rspec is also common class MagicballTest < MiniTest::Test def test_ask_returns_an_answer magicball = Magicball.new assert_includes Magicball::ANSWERS, magicball.ask("Test?") #the actual test 'assert' is p...
true
d54336c38599b48a7584b86adcd3b678c53da850
Ruby
IanLawson8913/codewar_exercises
/playing_with_digits.rb
UTF-8
272
3.453125
3
[]
no_license
def dig_pow(n, p) digits = n.to_s.chars.map(&:to_i) powers = [] digits.length.times { |x| powers << (digits.shift**(x + p)) } sum = powers.reduce(:+) if (sum % n).zero? sum / n else -1 end end p dig_pow(89, 1) p dig_pow(92, 1) p dig_pow(46288, 3)
true
89556b4168981af844ecf5538e526baaf3c3d034
Ruby
emilianolowe/launch-school-exercises
/Ruby/easy/easy8/double_char2.rb
UTF-8
397
3.515625
4
[]
no_license
def double_consonants(string) result = [] string.chars.each do |elem| if elem.match?(/[b-df-hj-np-tv-z]/i) result << elem << elem else result << elem end end p result.join end p double_consonants('String') == "SSttrrinngg" p double_consonants("Hello-World!") == "HHellllo-WWorrlldd!" p d...
true
ffe690daaa83d73c5d684de44956b8de7221a28a
Ruby
rodders110/week4-project
/seed.rb
UTF-8
1,273
2.6875
3
[]
no_license
require_relative('models/stock') require_relative('models/manufacturer') require_relative('models/inventory') require('pry') sweets = [{'name' => "Acid Drops"}, {'name' => 'Aniseed Balls'}, {'name' => 'American Hard Gums'}, {'name' => 'Apple Bon Bons'}, {'name' => 'Berwick Cockles'}, {'name' => 'Black Jacks'}, {'nam...
true
217c608d0ea8cfa7d2298a6880d5fab29c65bf98
Ruby
maksar/shortener
/app/models/permalink_repo.rb
UTF-8
1,209
2.640625
3
[ "MIT" ]
permissive
class PermalinkRepo include Singleton def initialize uri = URI.parse ENV["REDIS_URL"] @redis = Redis.new host: uri.host, port: uri.port, password: uri.password end def recall short result = @redis.hgetall short return nil if result.empty? Permalink.new result.merge short: short end ...
true
f0a5d51a0b47aabccc048739fe1f59c4bc4ae33c
Ruby
sugi1119/wdi-5
/06-advanced/regexp/ex-2.rb
UTF-8
128
2.59375
3
[]
no_license
# Line reader program ARGF.each do |line| puts line if line =~ /fred/i # //i is a case "i"nsensitive regular expression. end
true
2ad2d3f849192cafcd8792ce97209b2faadbb536
Ruby
akjagadeesh/hw-ruby-intro
/lib/ruby_intro.rb
UTF-8
2,037
3.796875
4
[]
no_license
# When done, submit this entire file to the autograder. # Part 1 def sum arr # YOUR CODE HERE Integer zero = 0 if arr.length == 0 return zero else Integer r_sum = 0 for nums in arr r_sum = r_sum + nums end return r_sum end end def max_2_sum arr # YOUR CODE HERE if...
true
7a7b494ac8d1785a319af47201088e01a42c6906
Ruby
SStrausman/codechallenge
/spec/models/assessment_spec.rb
UTF-8
1,602
2.671875
3
[]
no_license
require 'rails_helper' describe Assessment do it "is valid with a title." do assessment = Assessment.new(title: "Beer Assessment") expect(assessment).to be_valid end it "is invalid without a title" do assessment = Assessment.new(title: nil) assessment.valid? expect(assessment.errors[:title]).to include ...
true
6d635f67b0205ae300e3172a66405f3a88f679b0
Ruby
timeout/cite_convert
/lib/cite_convert/article/expand.rb
UTF-8
971
3.046875
3
[]
no_license
module CiteConvert module Article class Expand def initialize(array) @array = array end attr_reader :array def blow_up while self.contains_range? index = self.range_symbol_index replace = expand_range(self.array.at(index - 1), self.array.at(index + 1)...
true
2d34512c3b6dee600da8cb2202337340671c0043
Ruby
ngenator/werewolf
/bin/script/full_game.rb
UTF-8
1,670
2.546875
3
[ "MIT" ]
permissive
#paste into 'bundle exec bin/console' session SlackRubyBot::Client.logger.level = Logger::INFO game = Werewolf::Game.instance slackbot = Werewolf::SlackBot.new(token: ENV['SLACK_API_TOKEN'], aliases: ['fangbot']) game.add_observer(slackbot) slackbot.start_async sleep 2 seer = Werewolf::Player.new(:name => 'bill',...
true
138abbe7a5bc479f670cd2ca18c080a21ce4a695
Ruby
hcmarchezi/ruby_bank_account_system
/bank_account_system/test/use_cases/current_balance_use_case_test.rb
UTF-8
888
2.5625
3
[]
no_license
require 'test_helper' class CurrentBalanceUseCaseTest < ActiveSupport::TestCase test "check current balance from a bank account" do account_id = FactoryGirl.create(:account, balance: 100, user: FactoryGirl.create(:user)).id current_balance_use_case = CurrentBalanceUseCa...
true
d6a698db2f4d3375a5eb6e7c2b8170eb35b20391
Ruby
TGOlson/rpn
/spec/to_i_spec.rb
UTF-8
1,017
3.453125
3
[]
no_license
require_relative 'spec_helper' assert 'it can handle an empty string' do # nil converts to 0, same as Ruby #to_i method RPNCalculator.to_i('') == 0 end assert 'it can handle a number less than ten' do RPNCalculator.to_i('1') == 1 end assert 'it can handle a number less than 100' do RPNCalculator.to_i('67') =...
true
f279512f31cd2d174216c1ade749c1458ff2946d
Ruby
mozamimy/toolbox
/ruby/list_on_demand_ec2_instances/list.rb
UTF-8
1,485
2.65625
3
[ "CC0-1.0" ]
permissive
require 'aws-sdk-ec2' NORMALIZATION_FACTORS = { 'nano' => 0.25, 'micro' => 0.5, 'small' => 1.0, 'medium' => 2.0, 'large' => 4.0, 'xlarge' => 8.0, '2xlarge' => 16.0, '3xlarge' => 24.0, '4xlarge' => 32.0, '6xlarge' => 48.0, '8xlarge' => 64.0, '9xlarge' => 72.0, '10xlarge' => 80.0, '12xlarge' ...
true
83194e72689ca16f0817d8ff50e278ccf0c7ad00
Ruby
xunma/livecodes-batch-666
/price-is-right/price.rb
UTF-8
1,018
4.75
5
[]
no_license
# Write a game where the player has to guess a random price between 1 and 100 chosen by the program. The program should keep asking until the player guesses the right price. When the guess is right, the program displays how many guesses it took the player to win. # pseudo-code # program picks a random number from 1 t...
true
274d9d13fb24f86e4c99695def0015600e4793ce
Ruby
igorsimdyanov/gb
/part1/lesson7/d.smolsky/6_2.rb
UTF-8
148
3.28125
3
[]
no_license
# frozen_string_literal: true print 'Input nuber:' input = gets if (input.to_f % 2).zero? puts 'Четное' else puts 'Нечетное' end
true
41e83a86ae362ad00292d47b109c20303228ea3d
Ruby
s-shimko/ruby_learn2
/lesson4/task4_5/check_variables.rb
UTF-8
171
2.640625
3
[]
no_license
require_relative 'be_class' a = 100 be = BeClass.new(10) puts "Переменная 'a': #{defined?(a)}" be.check_var puts "Переменная '@b': #{defined?(@b)}"
true
388cf903d1a821808cab2ef71c57e459958f5ddc
Ruby
cmaher92/launch_school
/coursework/rb120/lesson_4/hard_1/question1.rb
UTF-8
1,090
3.421875
3
[]
no_license
# Question 1 # Alyssa has been assigned a task of modifying a class that was initially created # to keep track of secret information. The new requirement calls for adding logging, # when clients of the class attempt to access the secret data. # Here is the class in its current form: class SecretFile def initializ...
true
218c4f8b9c6944ecd4e4837a13f442e8fe68c549
Ruby
DMendez49/Lunch_Lady
/day2.rb
UTF-8
3,244
4.40625
4
[]
no_license
#we have access to pry commands # example require "pry" # @contacts = ["spancer", "Thomas"] #binding.pry used to check code #on were you think there is a problem #this is how to create a class class Person attr_accessor :name, :age #initialize method is being called first def initialize(name, age) #two ins...
true
100381cd3c0653ef1268e02f37d78625003b9970
Ruby
urayoshie/array_practice
/array.rb
UTF-8
339
3.453125
3
[]
no_license
languages = ["Ruby", "PHP", "Java"] puts "様々な言語のHello World" puts "" languages.each do |language| case language when "Ruby" puts "#{language} :" + ' puts "Hello World!"' when "PHP" puts "#{language} :" + ' echo "Hello World!";' when "Java" puts "#{language} :" + ' System.out.println("Hello World!");' e...
true
3ec65b6ea8f157fd0e127b754a8650c424ba46b2
Ruby
souljuse/makersacademy-oop-workshop
/lib/student.rb
UTF-8
450
3.453125
3
[]
no_license
class Student attr_reader :first_name, :last_name, :date_of_birth, :height def initialize(data) #I espect a hash to be passed so data is the hash @first_name = data['first_name'] @last_name = data['last_name'] @date_of_birth = Date.parse(data['date_of_birth']) @height = data['height'] end d...
true
e03d1352be17f3895f7cfdb558997fd8c8414c87
Ruby
Takashi-Na/ruby-drill
/drill-14.rb
UTF-8
189
3.375
3
[]
no_license
def police_trouble(a, b) if (a && b) || (!a && !b) puts "true" else puts "false" end end #容疑者a,bの証言の真偽を決める a = false b = false police_trouble(a, b)
true
23b03d3dffdcb5dabd6e242e5e0b8c62ae7825b7
Ruby
GBouffard/rps-first-attempt
/spec/player_spec.rb
UTF-8
401
3
3
[]
no_license
require 'player' describe Player do let(:player) { described_class.new('Guillaume') } it 'has a name' do expect(player.name).to eq 'Guillaume' end it 'can choose a hand' do expect(player.chose_hand('Rock')).to eq 'Rock' end it 'can only choose a hand that is Rock, Paper or Scissors' do expect...
true
20d00c3d41ec5854117ad20175a4f74671b05bf5
Ruby
jlambert121/evenup-ct2ls
/files/ct2ls.rb
UTF-8
3,939
2.59375
3
[ "Apache-2.0" ]
permissive
#/usr/bin/env ruby require 'rubygems' require 'logger' require 'json' require 'aws-sdk' require 'zlib' require 'redis' require "daemons" require "yaml" class Cloudtrail2Logstash def initialize config # Set up logging @log = Logger.new("#{config[:logpath]}/ct2ls_log.json", 'weekly') @log.level = Logger....
true
db5b527ff76bf628dee2058eb0e6ea7e0203c960
Ruby
Gudarien/WIP-Gudarien
/loops1c.rb
UTF-8
64
3.125
3
[]
no_license
number = 7 10.times do puts number number = number + 1 end
true
e196d538950bd47221b6013f7a01aaabf64ac185
Ruby
ElyKar/Tools
/Ruby/basic/linked_deque.rb
UTF-8
2,896
4.4375
4
[ "MIT" ]
permissive
# LinkedDeque represents a dequeue using a doubly-linked list. # # It supports the add-first, add-last, remove-first, and remove-last operations. # # Iteration via each is done from first element to the last. # # Author:: Tristan Claverie # License:: MIT class LinkedDeque include Enumerable # Size of the deque...
true
ed92bafdbab4ad63a12871d5e85d71e43f4b8ef0
Ruby
ryancalhoun/just-keep-zipping
/spec/just_keep_zipping_spec.rb
UTF-8
2,966
2.71875
3
[ "MIT" ]
permissive
require 'rspec' require 'tempfile' require 'zip' require 'just-keep-zipping' describe JustKeepZipping do it 'adds a file as a string' do subject.add 'file', 'this is a string to be zipped' expect(subject.entries.size).to be == 1 expect(subject.entries.first.name).to be == 'file' expect(subject.curr...
true
3d11111ff87dd5b891975e302ba208cdc2079f7b
Ruby
jgaskins/perpetuity-postgres
/spec/perpetuity/postgres/table_spec.rb
UTF-8
2,085
2.609375
3
[ "MIT" ]
permissive
require 'perpetuity/postgres/table' require 'perpetuity/postgres/table/attribute' module Perpetuity class Postgres describe Table do let(:title) { Table::Attribute.new('title', String, max_length: 40) } let(:body) { Table::Attribute.new('body', String) } let(:author) { Table::Attribute.new('...
true
4cce93aae7bf1db842ab595416b39d28ae5fdfa5
Ruby
asheidan/Greed
/src/lib/rules/ones_and_fives_rule.rb
UTF-8
415
3.6875
4
[]
no_license
module Rules # Implements a rule which gives 100 points for each 1 and # 50 points for each 5. class OnesAndFivesRule def apply(dice) points = 0 rethrow = dice.select do |die| if die == 1 points += 100 false elsif die == 5 points += 50 false ...
true