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
d8e5d937537f355c1851ebbb7732094a3e1843df
Ruby
somyabn/Trip_Report
/lib/driver_trip_stats.rb
UTF-8
1,055
3.125
3
[]
no_license
class DriverTripStats SECONDS_TO_HR = 1.0/3600 attr_accessor :driver_name attr_accessor :total_miles_driven attr_accessor :average_speed def send_info_to_report driver_trips @driver_name = driver_trips.first.driver_name @total_miles_driven = calculate_total_miles_driven driver_trips @total_miles...
true
80404910309ed8ffc169f1239eb35ba3825e5e77
Ruby
Guillaume-CHR/W03-D5_POO_Mass_Emailing
/lib/scrapper.rb
UTF-8
2,362
3.234375
3
[]
no_license
#! /usr/bin/env ruby ##**************************************************************************** # RUBY - Scrapper # **************************************************************************** # Ruby's Program - Scrapper # Written by: THP Tls session 7 # Date: 25-Jan-2019 # # Description: # - # - #...
true
36282d296ec40602fd23e7c2b364b05cee235214
Ruby
jennymalmefeldt/first_ruby_1
/array.rb
UTF-8
1,051
4.6875
5
[]
no_license
# Write a small program to check that the number 3 is in the array arr = [1, 3, 5, 7, 9, 11] puts arr.include?(3) # Integer [1] arr = ["b", "a"] arr = arr.product(Array(1..3)) arr.first.delete(arr.first.last) # Is creating an Array [1, 2, 3] arr = ["b", "a"] arr = arr.product([Array(1..3)]) arr.first.delete(arr.f...
true
2586e51d284c5526f5581436f3d23278716fd253
Ruby
alu0100845808/pract05
/lib/frac.rb
UTF-8
1,243
3.578125
4
[]
no_license
class Fraccion attr_reader :num, :denom def mcd(x, y) ## Algoritmo de Euclides x, y = x.abs, y.abs while y != 0 x, y = y, x % y end x end def initialize(num,denom) #minimiza al construir ^^ raise TypeError, "El denominador debe ser mayor que 0" if denom.eql? 0 raise TypeErr...
true
ede79a27bcba99d875a618fc144230e17a4e5f35
Ruby
thesteady/supportme
/support_me-main/spec/services/chat_service_spec.rb
UTF-8
3,462
2.671875
3
[]
no_license
require 'spec_helper' describe ChatService do def create_chat(id) customer = Customer.create(name: 'Mr. Goat', email: 'example@example.com') service = ChatService.new(id) service.create_chat(customer.id) end context "#initialize" do it "creates a new ChatService with a chat_id" do result ...
true
6bbf2bb6570cd4527a131537ff1fcb025d541193
Ruby
dvwhitem/ln_ruby
/scrincast/prop.rb
UTF-8
203
3.515625
4
[]
no_license
class Item def initialize @price = 100 end def price @price end def price=(price_value) @price = price_value end end item = Item.new p item.price item.price=(200) p item.price
true
470f5486c5f0cebf7cc7416427aa761e9695d5c3
Ruby
jaybones90/ping-pong-ruby-
/spec/ping_pong_spec.rb
UTF-8
1,130
3.8125
4
[]
no_license
require('rspec') require('ping_pong') describe('Fixnum#ping_pong') do it("counts up to the inputted number") do expect(2.ping_pong).to(eq([1,2])) end end # describe('Fixnum#ping_pong') do # it("replaces numbers that are divisible by 15 with the word pingpong, numbers divisible by 5 with pong, and numbers divis...
true
3081bec3d070ba34425592459a80efe3a2e49b08
Ruby
meegido/pragmatic-learn-to-program
/strings.rb
UTF-8
715
3.921875
4
[]
no_license
puts "Hello World" puts "" puts "Good-bye" puts "I like " + "Nutella." puts "blink " * 4 puts "12 and " + "12" puts "12 + 12" puts 12 + 12 puts 2 * 5 puts "2 " * 5 puts "2 * 5" puts 5 * 6 puts "5 " * 6 puts "5 * 6" puts 5 * 6 puts "seis veces cinco" puts "muestra texto 5 * 6" puts "You\'re a swell" puts "" var...
true
fa17ca223eb3bc56716653127dcc172619903c3c
Ruby
mtyy110/readingnotes
/七周七语言/Ruby/1_3.rb
UTF-8
72
2.65625
3
[]
no_license
#!/usr/bin/env ruby i = 0 while i < 10 puts "mtyy110" i = i + 1 end
true
d4355aae7314257570a0ce4026ba347ebe90ec2b
Ruby
pbhandari/ruby-algorithms
/test/sort/test_quicksort.rb
UTF-8
247
2.8125
3
[ "ISC" ]
permissive
#!/usr/bin/env ruby require '../../src/sort/quicksort.rb' require 'test/unit' # class QuickSortTest < Test::Unit::TestCase def test_array arr = [1, 2, 4, 5, 6, 3] sorted = arr.sort arr.qsort! assert_equal arr, sorted end end
true
a3697df8ffe3c4c1a5d0cdb0da9a7183401ab5af
Ruby
watashi/AlgoSolution
/codeforces/ac/2/299/B.rb
UTF-8
92
2.625
3
[]
no_license
k = gets.split[1].to_i puts (gets.chomp.split('.').map(&:size).max || -1) >= k ? :NO : :YES
true
c0b8615ff4738b40557ac912cac096f705286979
Ruby
sudothinker/set.rb
/card.rb
UTF-8
404
3.15625
3
[]
no_license
class Card attr_accessor :color, :shape, :count, :pattern PATTERNS = [:solid, :blank, :striped] COLORS = [:green, :blue, :red] COUNTS = [1, 2, 3] SHAPES = [:oval, :triangle, :squigle] def initialize(color, shape, count, pattern) @color = color @shape = shape @count = count @pattern = patter...
true
740a18eda99683928fe89737177f48766c0b2bee
Ruby
Corey-Miller85/Practice
/App Academy/Recursion/recursion_demo.rb
UTF-8
895
4.09375
4
[]
no_license
def upcase(str) #can only upcase at one letter at a time #basecase return str.upcase if str <= 1 puts str #inductive step p str[0].upcase + upcase(str[1..-1]) end # iterative method def iterative_upcase(str) str.chars.inject("") do |upcased_str,char| upcased_str << char.upcase ...
true
29f5bfab25782bd46feba7fb7125bca94246f0d2
Ruby
Se7endz/Semaine3J4
/game.rb
UTF-8
1,191
3.90625
4
[]
no_license
require_relative "./Player.rb" require_relative "./BoardCase.rb" require_relative "./Board.rb" class Game def initialize # Création des players et du board. On assigne la lettre directement aux joueurs @player1 = Player.new("X") @player2 = Player.new("O") @board = Board.new end def go # Lance la p...
true
2867928f81e7eac308cbcb79124dd7b8dd587c31
Ruby
vtt01uk/tradewize
/app/models/user.rb
UTF-8
2,002
2.71875
3
[]
no_license
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :user_stocks has_many :stocks, through: :us...
true
615e410c306497e091fe0675ba0b33a40162c7fc
Ruby
Phrzsr/phrzsr-ruby
/lib/phrzsr.rb
UTF-8
788
3
3
[ "MIT" ]
permissive
require 'net/http' require 'uri' class Phrzsr VALID_CATEGORIES = [:motivational, :demotivational, :gratitude, :greetings, :farewells] def self.phrzsr(category_or_url = :motivational, args = []) if category_or_url =~ /^#{URI::regexp}$/ url = category_or_url else raise CategoryError unless VALID...
true
198888a96090ec6fe37a2572706dde9a8c88fd29
Ruby
tessgriffin/sales_engine
/lib/customer_repository.rb
UTF-8
2,016
2.921875
3
[]
no_license
require_relative 'customer' class CustomerRepository attr_reader :customers, :sales_engine def initialize(parsed_data, sales_engine) @customers = parsed_data.map do |customer| Customer.new( customer["id"], customer["first_name"], customer["last_name"], customer["created_a...
true
66f65f67d09cca76f27847fa4cd13d44adaed7ea
Ruby
plimhoward123/programming-univbasics-4-array-simple-array-manipulations-online-web-prework
/lib/intro_to_simple_array_manipulations.rb
UTF-8
744
3.3125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def using_push(array,string) up_ar = array.push(string) return up_ar end def using_unshift(array,string) uns_array = array.unshift(string) return uns_array end def using_pop(array) return array1 = array.pop end def pop_with_args(array) return array.pop(2) end def using_shift(array) return array.shift ...
true
f4f631d0cc459a7837316c0c2eb8500bccfbfd62
Ruby
crsven/things_templates
/lib/things_templates/template.rb
UTF-8
486
2.546875
3
[ "MIT" ]
permissive
require 'yaml' class ThingsTemplates::Template attr_reader :items, :project, :tags def initialize(file) yaml = YAML.load(File.open(file)) @items = yaml['items'] @project = yaml.fetch('project', nil) @tags = yaml.fetch('tags', nil) end def build! if project ThingsTemplates::AppContro...
true
24abf2483dbe09ccbce3b8321e1def2cf8451414
Ruby
octokit/octokit.rb
/spec/octokit/repository_spec.rb
UTF-8
7,768
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true describe Octokit::Repository do context 'when passed a string containg a slash' do before do @repository = Octokit::Repository.new('sferik/octokit') end it 'sets the repository name and username' do expect(@repository.name).to eq('octokit') expect(@reposit...
true
dbd2cf315508355a56a84c6477a06852fc97a42e
Ruby
kyoshida-aim/RubyTraining
/PlayGround/hello_class.rb
UTF-8
338
3.8125
4
[ "MIT" ]
permissive
# frozen_string_literal: true # this class will return text with someones name. class HelloWorld def initialize(myname = 'Ruby') @name = myname end def hello puts("Hello, world. I am #{@name}.") end end bob = HelloWorld.new('Bob') alice = HelloWorld.new('Alice') ruby = HelloWorld.new bob.hello alice...
true
4bef72fbc01cfede3d2db53e65fb2e8b130b4391
Ruby
unixengineer/inspec
/lib/inspec/resources/platform.rb
UTF-8
2,316
2.65625
3
[ "Apache-2.0" ]
permissive
require "inspec/resource" module Inspec::Resources class PlatformResource < Inspec.resource(1) name "platform" desc "Use the platform InSpec resource to test the platform on which the system is running." example <<~EXAMPLE describe platform do its('name') { should eq 'redhat' } end ...
true
ae31d64b7df7dcebe4d075041d404ae0c84ca014
Ruby
JunzeHe/AdventOfCode
/2021/spec/day7_spec.rb
UTF-8
4,218
3.09375
3
[ "Apache-2.0" ]
permissive
require 'spec_helper' describe Day7 do describe '#part1' do describe Day7::ColoredBag do let(:input) do <<~ABC light red bags contain 1 bright white bag, 2 muted yellow bags. dark orange bags contain 3 bright white bags, 4 muted yellow bags. bright white bags contain 1...
true
8e3a6856705c145e8f883537b8be3db97d36f74a
Ruby
jeremyevans/sacruby
/2017-01-ruby-2.4/24/17.rb
UTF-8
67
2.640625
3
[]
no_license
f = 12.35678 p f.ceil(1) p f.floor(2) p f.round(3) p f.truncate(4)
true
649a5e3dcc5fafc5241b5d507e7d1ebeefc1f0f6
Ruby
flowkater/RefactoringRuby
/first/spec/refactoring_spec.rb
UTF-8
2,411
2.765625
3
[]
no_license
# encoding: UTF-8 require 'customer' require 'rental' require 'movie' require 'spec_helper' describe "Refactoring" do let(:movie_regular) {Movie.new("프리퀀시", RegularPrice.new)} let(:movie_new_release) {Movie.new("나우유씨미",NewReleasePrice.new)} let(:movie_childrens) {Movie.new("드래곤볼",ChildrensPrice.new)} let(:rental_...
true
db48f7129bc8af622aa0ee7003bf4e7f09d91989
Ruby
smurf9852/game_ruby_ai
/board.rb
UTF-8
4,455
3.703125
4
[]
no_license
class Board attr_accessor :table,:table_pieces,:n def initialize(n) #makes board @table = Hash.new @table_pieces = Hash.new @n = n (1..n).each do |x| @table[x] = Hash.new (1..n).each do |y| @table[x][y] = PointOnBoard.new(x,y) end end end def set_piece(object,...
true
7d807735c737f2e7d3c0a8433519ae8a08e3ed17
Ruby
Ricartho/ruby-collaborating-objects-lab-noukod-000
/lib/artist.rb
UTF-8
692
3.25
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist attr_accessor :name @@all = [] def initialize(name) @name = name @songs = [] end def songs @songs end def add_song(song_name) @songs << song_name song_name.artist = self end def save @@all << self end def self.all @@all end ...
true
0799ff0d4aa7c01b9890d0d4a8844105b9581089
Ruby
pawan9489/TeachingRuby
/DemoCode/Session5/3.StringsMethods/3.Join.rb
UTF-8
205
3.546875
4
[ "Unlicense" ]
permissive
=begin joins all the strings in an array of strings By default the delemeter is empty string =end x = ["apple", "orange", "pear", "strawberry", "banana"] p x.join p x.join("") p x.join(" , ")
true
01181d7b854fb72242dec63346c192feabc28fef
Ruby
edmundonajera4/odin-ruby-exercises
/01_temperature/temperature.rb
UTF-8
93
3.203125
3
[]
no_license
def ftoc(fahrenheit) (fahrenheit - 32) * 5/9 end def ctof(celcius) (celcius * 1.8) + 32 end
true
45c96858ff3873f4af7006e817dab5df3adbfcb2
Ruby
JonathanAceroM/Herramientas-de-Codigo-Abierto
/6case.rb
UTF-8
204
3.25
3
[]
no_license
puts "Ingresa tu calificacion" cal=gets nota = case cal.to_i when 0..59 then b=gets a=gets when 60..79 then "Nota regular" when 80..89 then "Nota buena" when 90..100 then "Nota excelente" end puts nota
true
2d710125a775aa4f0489600cc83bb99e8c2e12e4
Ruby
janmilosh/exercises_for_programmers
/ch2_input_processing_output/counting_characters.rb
UTF-8
379
3.84375
4
[]
no_license
class CountingCharacters def prompt text print text gets.chomp end def output str if str.size == 0 puts 'You must enter something!' run else puts "\n#{ str } has #{ str.size } characters.\n\n" end end def run output(prompt "\nWhat is the input string? ") end end ...
true
e50858e0d0893f36334e4bf620091518cae87416
Ruby
Bodacious/genderize
/lib/genderize.rb
UTF-8
2,280
3.15625
3
[ "MIT" ]
permissive
require "genderize/gender" require "genderize/engine" unless Rails raise "Genderize is a Rails gem and expects to used in a Rails (3 or higher) application" end module Genderize def self.included(base) base.extend(ClassMethods) end module ClassMethods def genderize(col_name = "gender", opts = {}) ...
true
c24d654bec78d67ac1844dfe5ddd259ba0ccc5d9
Ruby
eduardoscovino/delivery-cafe
/ordem.rb
UTF-8
390
2.78125
3
[]
no_license
class Ordem attr_accessor :id, :entregue attr_reader :cafe, :empregado, :cliente def initialize(attributes = {}) @id = attributes[:id] @cafe = attributes[:cafe] @empregado = attributes[:empregado] @cliente = attributes[:cliente] @entregue = attributes[:entregue] || false end def entregue...
true
fff9497b516742d879ad2600c1ec735fa0661942
Ruby
i/Miscellaneous
/oldanagram.rb
UTF-8
421
3.671875
4
[]
no_license
def oldway (s1, s2) hash = {} s1.chars.each do |c| if hash[c].nil? hash[c] = 1 else hash[c] += 1 end end s2.chars.each do |c| if hash[c].nil? or hash[c] <= 0 return false elsif hash[c] == 1 hash.delete c els...
true
d1d15016a4afdb737ea1fb34253d2ec5df04f443
Ruby
siruguri/case_manager
/app/models/form_structure.rb
UTF-8
1,136
2.5625
3
[ "MIT" ]
permissive
class FormStructure < ActiveRecord::Base has_many :form_structure_entries belongs_to :author, class_name: 'User' has_many :multiple_choice_questions, through: :form_structure_entries, source: :question, source_type: 'MultipleChoiceQuestion' has_many :free_text_questions, through: :form_structure_entries, sourc...
true
0fd0caa2249c1eb45c823712f25b7af570eec941
Ruby
pbaker2018/Codewar_Katas
/Level_5_katas/rot13.rb
UTF-8
561
4.375
4
[]
no_license
# QUESTION # ROT13 is a simple letter substitution cipher that replaces a letter # with the letter 13 letters after it in the alphabet. # ROT13 is an example of the Caesar cipher. # # Create a function that takes a string and returns the string ciphered with Rot13. # If there are numbers or special characters included ...
true
7973ba19307709565b4394ea6a503e8a330472a9
Ruby
appirio-tech/cs-website-cms
/app/models/preference.rb
UTF-8
927
2.703125
3
[]
no_license
class Preference # Each attribute is an array of either ['email'], ['popup'], or ['email', 'popup'] # We use an array to give us flexibility when we need to add other notification types # (e.g. 'sms' or 'private_message') attr_accessor :id, :do_not_notify, :event, :notification_method, :type def initialize(...
true
609333d603411c48a8b8aee218cb7f38bc65bfbd
Ruby
TTS-NewOrleans/2017-tts-spring-full-time-ruby
/classes/class_examples.rb
UTF-8
1,899
4.15625
4
[]
no_license
class Person attr_accessor :name, :age def initialize(name, age) @name = name @age = age end def birthday @age += 1 end def change_name(new_name) @name = new_name end def jump puts "#{self.name} just jumped" end end class Product attr_accessor(:name, :price, :quantity, :b...
true
32ae54d61e1f66901a9216f2e2b1491ee70bea4d
Ruby
LondonBielicke/Calculator.rb
/calculator.rb
UTF-8
2,328
4
4
[]
no_license
puts "Welcome to The Klossy Kalculator" def name(user) "Hello #{user}! Please enter password" end puts "please enter name" user = gets.chomp puts name(user) password = "Lmb1229*" user_pass = gets.chomp def password_check(user_pass) if user_pass == "Lmb1229*" puts "Access granted" puts "What would ...
true
5d5a1410134c746d90d155adede879657d833dc6
Ruby
c0nspiracy/advent-of-code-2019
/day_15/day_15.rb
UTF-8
2,561
3.578125
4
[]
no_license
# frozen_string_literal: true require_relative '../lib/intcode' require_relative '../lib/grid' memory = File.read('input.txt').chomp.split(',').map(&:to_i) computer = Intcode.new(memory) NEIGHBOURS = { north: [-1, 0], south: [1, 0], west: [0, -1], east: [0, 1] }.freeze DELTAS = [[-1, 0], [1, 0], [0, -1], [0,...
true
caea670dfc840daa2dac6ccee600337da41715d6
Ruby
sebastialonso/page_adams
/lib/page_adams.rb
UTF-8
740
2.734375
3
[ "MIT" ]
permissive
require "page_adams/engine" module PageAdams mattr_accessor :page_size @@page_size = 10 def self.setup yield self end def self.included klass klass.extend ClassMethods end module ClassMethods def page page, page_size = PageAdams.page_size page = 1 if page.nil? or not page.is_a? I...
true
4094fc921d373eff50072a47caba428488219d8b
Ruby
leoc/rwave
/lib/rwave/devices/node.rb
UTF-8
1,008
2.5625
3
[]
no_license
module RWave class Node def initialize node_id, manager @node_id = node_id @driver = driver @driver.on_message do |sent, received| puts "call handler for 0x#{@node_id.to_s(16)}: #{received}" unless received.ack? or received.length <= 2 case received.bytes[2] ...
true
64de3a7b8eb5fdbed67864ca714e7a72df66699a
Ruby
space150/rmov
/lib/quicktime/track.rb
UTF-8
1,450
3.015625
3
[ "MIT" ]
permissive
module QuickTime # see ext/track.c for additional methods class Track # Returns the length of this track in seconds # using raw_duration and time_scale. def duration raw_duration.to_f/time_scale end # The average frame_rate for this track. May not be exact. def frame_rate # what a...
true
0e3cff0cc365fed19543ad819152fa96e02dadf6
Ruby
SujayHV/sujayrepo2
/back-end/Ruby/qwinix.rb
UTF-8
238
2.8125
3
[]
no_license
class Qwinix # def initialize(a,b,c) # @a=a # @b=b # @c=c # end def details(a,b,c) print "Name:" puts a print "id:" puts b print "mailid:" puts c end end x1=Qwinix.new x1.details("Sujay","QT1137","svijay@qwinix.io")
true
cae6e0d97ca4b51206eb9b79b3c8535f9d129a09
Ruby
martty/symbolic
/lib/symbolic/equation.rb
UTF-8
750
3.390625
3
[]
no_license
module Symbolic class Equation include Symbolic class << self end attr_accessor :rhs, :lhs def initialize(rhs, lhs) @rhs, @lhs = rhs, lhs end def +(var) Equation.new @rhs + var, @lhs + var end def -(var) Equation.new @rhs - var, @lhs - var end def ...
true
724dbfa9d0fee6f940e8eb4e474bb2e01e0b57e1
Ruby
mooreryan/length_cutoff
/scripts/make-them-cone-jawns.rb
UTF-8
1,474
2.640625
3
[]
no_license
#!/usr/bin/env ruby Signal.trap("PIPE", "EXIT") require 'trollop' opts = Trollop::options do banner <<-EOS Make the file for the cone jawns. Options: EOS opt :top_hits, "File name", type: :string opt :recruitment_info, "File name", type: :string end if opts[:top_hits].nil? Trollop.die :top_hits, "Yo...
true
7780e967a4ff24e9100189f945d4febd9dd057ae
Ruby
Mia-J-Russell/LaunchSchool
/RB101/lesson_6/MyTwentyOne.rb
UTF-8
4,317
4.03125
4
[]
no_license
require 'pry' SUITS = ['H', 'S', 'C', 'D'] VALUE = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] CONVERSION = {'H' => 'Hearts', 'S' => 'Spades', 'C' => 'Clubs', 'D' => 'Diamonds', '2' => 'Two', '3' => 'Three', '4' ...
true
72041cda84e057ffa9de78a9499a81d583a2df47
Ruby
ianbbqzy/InternalPortal
/app/controllers/schedules_controller.rb
UTF-8
3,308
2.609375
3
[]
no_license
class SchedulesController < ApplicationController def index @schedules = Schedule.all end def new @schedule = Schedule.new # assignShifts() end def destroy @schedule = Schedule.find(params[:id]) @schedule.delete redirect_to schedules_path end ...
true
092fff55107b7b3b13882338fd284ad6e9793a65
Ruby
ian-1/battle_game
/lib/player.rb
UTF-8
161
3.34375
3
[]
no_license
class Player attr_reader :name, :hit_points def initialize(name) @name = name @hit_points = 100 end def deduct @hit_points -= 10 end end
true
b5c1d4bbede88764b93dec7ed67ff2820777e671
Ruby
fatimaberazi/tic-tac-toe-rb-re-coded-000
/lib/tic_tac_toe.rb
UTF-8
2,051
3.890625
4
[]
no_license
WIN_COMBINATIONS=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]] def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end def inp...
true
71a3cae84e6817b19c24b18248dc3a685ff76b18
Ruby
OSC/ood_core
/spec/job/array_ids_spec.rb
UTF-8
2,336
2.734375
3
[ "MIT" ]
permissive
require "spec_helper" require "ood_core/job/array_ids" # Note that while all tests should pass not all passing inputs are valid for # all Resource Managers describe OodCore::Job::ArrayIds do context "when the spec is for a range" do it "returns the correct IDs" do expect( described_class.new('1-4').ids )....
true
48e5810b4413e0a40a76d1ec802f503126969547
Ruby
garnieretienne/stamper
/lib/stamper/account.rb
UTF-8
535
2.59375
3
[ "MIT" ]
permissive
module Stamper class Account attr_reader :address, :adapter def initialize(address: nil, adapter: nil) raise "No address provided" unless address raise "No adapter provided" unless adapter @address = address @adapter = adapter end def subscribed_mailboxes if @mailboxe...
true
a0e2cdd5f4d1faa4802c2ca92172776931a42683
Ruby
ashishra0/Rdoc
/album.rb
UTF-8
519
4.03125
4
[]
no_license
# Album class class Album include Enumerable # Setter and getter method attr_reader :songs # creates empty songs array upon instantiation of new object. def initialize @songs = [] end # Adds new song to the songs array def add_song(song) songs << song end # iterates over songs in the songs arra...
true
3b6c56f82c10219dd7ea3ae22a204912206990ad
Ruby
pathouse/generation_cacheable
/lib/gen_cache/expiry.rb
UTF-8
1,080
2.734375
3
[]
no_license
module GenCache def expire_model_cache GenCache.expire(self) end # Manual expiry initiated by an object after commit # only has to worry about key_cache, attribute_cache, and class_method_cache def self.expire(object) expire_instance_key(object) if object.persisted? expire_class_method_keys(obje...
true
de11fcf9519e260a427b145e2142f84a820a6ae0
Ruby
Sethoscope1/Project-Euler
/Problems/14_largest_collatz.rb
UTF-8
421
3.765625
4
[]
no_license
def collatz(num) count = 1 until num == 1 if num % 2 == 0 num /= 2 else num = num * 3 + 1 end count +=1 end count end def largest_collatz(num) largest_count = 0 largest = 0 (1..num).each do |num| if collatz(num) > largest_count largest = num ...
true
1b3fd2e050a26ea4d4ed041a2a32e64afa705457
Ruby
hellobrian/learn_ruby
/08_book_titles/timer.rb
UTF-8
168
2.859375
3
[]
no_license
class Timer attr_accessor :timer, :seconds def initialize(seconds=0) @seconds = seconds end def time_string(seconds=0) "00:00:00" if seconds = 0 end end
true
c7e86990ee236706b76c155365351c33e19b6921
Ruby
WThiersLucena/turma7
/Ruby/07-ifs-exercicios.rb
UTF-8
5,018
3.5
4
[]
no_license
# Estamos vivendo uma pandemia e o governador pediu um sistema para indicar qual a cor da fase pandêmica em que está o Estado. # A cor da fase pandêmica é definida baseada em três valores: # 1) A taxa de vacinação da população. # 2) O fator de transmissão do vírus. # 3) A taxa de ocupação dos leitos de UTI. # As reg...
true
dce9a366bdd4a2eb17d13455144ac5cc879b032d
Ruby
avtrujillo/RubyChess
/classes/pawn.rb
UTF-8
5,853
3.171875
3
[]
no_license
class Pawn < Piece @white_symbol = "♟" @black_symbol = "♙" attr_accessor :orientation def initialize(color, tilename, serial, game, depth = 0) super(color, tilename, serial, game, depth) @orientation = 1 #which way is this pawn moving? @orientation = (-1) if color == "black" end def one_tile_ahead(destinati...
true
a014c9ddbc4cf8c6f97fa2ebf39c40feccf39829
Ruby
spoccomp/0831Algos
/buble_sort.rb
UTF-8
376
3.890625
4
[]
no_license
array =[5,9,3,2,6,1,8,10,7,4] def bubble_sort(array) range = (0..array.size-1) puts range for i in range for j in 0..array.size - 2 if array[i] < array[j] temp = array[i] array[i] = array[j] array[j] = temp end end ...
true
07ac81f14ab5110afbbb94c78d3e83e4102ad659
Ruby
Ian9802/Hex
/tc_battle.rb
UTF-8
6,308
2.796875
3
[]
no_license
require_relative 'being' require_relative 'battle' require "test/unit" class TestBattle < Test::Unit::TestCase def test_initialize battle = Battle.new() assert(!battle.getCreatures().nil?) assert_equal(7, battle.getCreatures.length) for i in (0..7) assert(battle.getCreatures[i].nil?) end end...
true
2e6533095e8b7811590f558426feb354adbe6d59
Ruby
kgriswo1/OO-mini-project-nyc-web-080519
/tools/console.rb
UTF-8
1,211
2.59375
3
[]
no_license
require_relative '../config/environment.rb' kunxi = User.new("Kunxi") dan = User.new("Dan") bob = User.new("Bob") burger_recipe = Recipe.new("burger") salad_recipe = Recipe.new("salad") fries_recipe = Recipe.new("fries") soda_recipe = Recipe.new("soda") sandwich_recipe = Recipe.new("sandwich") burger1 = RecipeCard.n...
true
685afce93e05e413df1919155b93f020de05d70d
Ruby
kmclean-old/intro_week_2
/oo_tictactoe.rb
UTF-8
3,162
4
4
[]
no_license
class Game def initialize @human = Human.new @computer = Computer.new @board = Board.new @current_player = @human end def alternate_player if @current_player == @human @current_player = @computer else @current_player = @human end end def wants_to_play_again? puts ...
true
b15149af06248d4682636f176e96a41ce78698fc
Ruby
taw/magic-search-engine
/search-engine/bin/test_order
UTF-8
1,529
2.859375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require_relative "../lib/card_database" class TestOrder def initialize @db = CardDatabase.load end def call @db.sets.each do |set_code, set| printings = set .printings .reject{|c| c.secondary?} # backside of DFC/meld/flip cards .reject{|c| c.layout == "...
true
c01f6b1ad8ebbccf2c3a4ccde4a9b9e5e40b4bf1
Ruby
io8r/VR
/test/models/product_test.rb
UTF-8
1,361
2.703125
3
[]
no_license
require 'test_helper' class ProductTest < ActiveSupport::TestCase fixtures :products def new_product(image_url) Product.new(title: "r", description: "r", price: 1, image_url: image_url) end test "image url" do ok = %w{fred.gif fred.jpg fred.png FRED.JPG fRed.Jpg http://a.b.c/x/w/q/fred.gif } ...
true
98495ad474b6954d1750544d446da8515a427096
Ruby
breamware/sidekiq-batch
/spec/integration/simple.rb
UTF-8
857
2.703125
3
[ "MIT" ]
permissive
require 'integration_helper' # Simple nested batch without callbacks # Batches: # - Overall (Worker1) # - Worker2 class Worker1 include Sidekiq::Worker def perform Sidekiq.logger.info "Work1" batch = Sidekiq::Batch.new batch.jobs do Worker2.perform_async end end end class Worker2 incl...
true
47b24fc7a92710879b58a9fc04c9a1d5914a6fc4
Ruby
micalexander/squishygrid
/lib/squid/generator.rb
UTF-8
4,886
2.734375
3
[ "MIT" ]
permissive
module Squid class Generator def generate_grid_styles columns, gutter, at, output grid = <<-eos .grid { width: #{100 + gutter}%; margin-left: -#{gutter}%; &.compact { width: 100%; margin-left: 0; } } eos (1..columns).each do |column| (column..columns).each do |span| com...
true
010783683d592fb4da4930243dabcde422df65bc
Ruby
Chryus/todos
/todo13/version.sort.rb
UTF-8
3,137
3.21875
3
[]
no_license
# # Version Sort # * from rubeque http://www.rubeque.com/problems/version-sort * # ## Objectives: # Implement the version_sort method # ### Inspiration: # http://www.gnu.org/software/coreutils/manual/html_node/More-details-about-version-sort.html # ## Skills: # reg exp, split, sort, each # ## Instructions: #...
true
cb24c3617d960f6248901ffa268e7a62e8398aa0
Ruby
marcwright/WDI_ATL_1_Instructors
/REPO - DC - Students/w01/d03/Inhak/03_lunch_orders/lunch_orders.rb
UTF-8
1,010
3.484375
3
[]
no_license
<<<<<<< HEAD orders = {}; while true puts "Name for order:" name = gets.chomp puts "#{name} wants to order:" order = gets.chomp orders[name] ||= [] orders[name].push(order) puts "Add another item to the order? (y/n)" break if !gets.index('y') end puts "\nAll orders:" #puts orders orders.each_pair...
true
b88d73cce12b6f9be8d1178f68936a3c0b0dd2d8
Ruby
prashantchauhan627/numbered_list
/code.rb
UTF-8
1,379
3.265625
3
[]
no_license
array_of_hash = [ { 'id': 1, 'title': 'Heading1', 'heading_level': 0 }, { 'id': 2, 'title': 'Heading2', 'heading_level': 2 }, { 'id': 3, 'title': 'Heading3', 'heading_level': 2 }, { 'id': 5, 'title': 'Heading4', 'heading_level': 1 }, { 'id': 6, 'title': 'Heading5', 'heading_level': 1 }, { 'id': 7, 'title':...
true
379cd4fa7ee0d3bc9b6049ba565eacd965621253
Ruby
sambuddhac/OPF
/Two_Bus/code/src/rb_cvxgen/cvxgen_add_namespace.rb
UTF-8
2,907
2.71875
3
[ "BSD-2-Clause" ]
permissive
#!/usr/bin/env ruby def insert_namespace filename, namespace tmp = File.open("tmp", 'w') File.open(filename, 'r') do |f| while(line = f.gets) if line.match(/^\/\*|^\n|^#(.*)+/) tmp.puts line else break end end tmp.puts "namespace #{namespace} {" tmp.puts line ...
true
99b9f85bd7c057b8eb02819086cfa1a4657aef45
Ruby
sirvin-dev/euler
/001/01.rb
UTF-8
580
3.859375
4
[]
no_license
#/bin/ruby ############################################################################ # # Project Euler - Problem 001 # # If we list all the natural numbers below 10 that are multiples of 3 or 5, # we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. # # An...
true
08a1f7ff823109aa48ae936fd81f8c6f48592cc2
Ruby
nnakagaki/code-eval
/moderate/find_a_square.rb
UTF-8
590
3.1875
3
[]
no_license
File.open(ARGV[0]).each_line do |line| line.chomp! split = line.split(", ") points = [] ans = "true" split.each do |el| points << el[1..-2].split(",").map! { |el| el.to_i} end dists = Hash.new(0) 3.times do |i| dist = (points[0][0] - points[i+1][0]) ** 2 + (points[0][1] - points[i+1][1]) ** 2 dists[dist...
true
85d849a13772be15d6eadc66e05f54c75ef9e39e
Ruby
Deuf97/mario
/exo_11f.rb
UTF-8
78
2.71875
3
[]
no_license
puts "choisissez un nombre" la=gets.to_i la.times do puts "salut sa farte" end
true
9f50b0564685504706c2bc62578532293f7f4bab
Ruby
le-s/W2D3
/TDD/lib/towers_of_hanoi.rb
UTF-8
109
2.515625
3
[]
no_license
class TowersOfHanoi attr_reader :towers def initialize @towers = [[1,2,3], [], []] end end
true
2682608a6cd6ab2316a69f08d40b289796cfa866
Ruby
awslabs/cloud-templates-ruby
/lib/aws/templates/utils/parametrized/constraint/condition.rb
UTF-8
2,473
2.890625
3
[ "Apache-2.0" ]
permissive
require 'aws/templates/utils' module Aws module Templates module Utils module Parametrized class Constraint ## # Condition # # Condition is a strategy which decides if some particular constraint should be enforced # or not. class Condition...
true
90c74f43d1e4717852b99d0e0418733a7391c642
Ruby
deedubsau/plugin-scan
/lib/stats/traffic.rb
UTF-8
246
2.671875
3
[ "MIT" ]
permissive
module Stats class Traffic attr_reader :date, :hit, :outdated def initialize(args={}) @date = args.fetch(:date, Time.now.utc.to_date) @hit = args[:hit].to_i @outdated = args[:outdated].to_i end end end
true
57954843de35d85b4e4d626b488d7d2efdffb49a
Ruby
ARahaman/Test
/case.rb
UTF-8
272
3.859375
4
[]
no_license
(1..50).each do |num| case[num%2==0, num%3==0] when [true,true] then print "#{num} : hush hush\n" when [true,false] then print "#{num} : hush\n" when [false,true] then print "#{num} : huff\n" when [false,false] then print "#{num} : huff huff\n " end end
true
fbb8be82398d64256c3be470411d9b1e2f0769ef
Ruby
surbhiguptasai/surbhi
/test-first-ruby/lib/09_timer.rb
UTF-8
510
3.765625
4
[]
no_license
class Timer def initialize(seconds = 0) #initilize seconds to zero @seconds = seconds end def seconds=(new_sec=0) @seconds = new_sec end def seconds @seconds end def time_string hh = @seconds/3600 mm = @seconds%3600/60 ss = @secon...
true
16fd0cc87db7e623d881263cfb6643863a88ecb0
Ruby
jguice/zerigo-dns-checker
/check_dns.rb
UTF-8
1,460
2.546875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require_relative 'zerigo_dns' require_relative 'stupid_things' require 'pp' require 'net/ping' Zerigo::DNS::Base.user = ENV['ZERIGO_USER'] Zerigo::DNS::Base.api_key = ENV['ZERIGO_API_KEY'] unless ARGV[0] && ENV['ZERIGO_USER'] && ENV['ZERIGO_API_KEY'] puts "Checks a zerigo dns zone (domain) for...
true
3af00999f08fe266bdaa29eac5abddda8f1b56ae
Ruby
hiroshi3016/hello_world
/hash2.rb
UTF-8
83
2.75
3
[]
no_license
woman = { :height => 160, :weight => 50} p woman p woman[:height] p woman[:weight]
true
104cc9eb9eb91eb31af3b0bd6b6b838420278c17
Ruby
robertSahm/foundTemp
/app/controllers/o_auth_controller.rb
UTF-8
5,752
2.5625
3
[]
no_license
class OAuthController < ApplicationController ERROR = { fsqdown: "Foursquare appears to be down now. Please try logging in with Foursquare later.", fbdown: "Facebook appears to be down now. Please try logging in with Facebook later.", notauth: "You didn't authorize the app, so we can't log you in. Try...
true
52a6bd0765fae2e0b8b7172199c797007dfc9d8c
Ruby
Dyakova/lab_3
/app/models/country.rb
UTF-8
923
2.734375
3
[]
no_license
require 'state_machine' class Country < ActiveRecord::Base validates :name, :presence => true, :uniqueness => true, :format => { :with => /^([A-Z]){1}([a-z]){1,}$/, :message => "should start with capital char"} validates :language, :presence => true, :length => { :minimum => 2 }, :format => { :with => /^([a-z]...
true
94e31f1d73515f93f911708a34199cc590aeb892
Ruby
utkarsh9/apl-week4
/Eleven.rb
UTF-8
2,084
3.5625
4
[]
no_license
class DataStorageManager attr_accessor :data def initialize @data=[] end def init(file_path) file=File.open(file_path,"r") file.each_line do|line| line.split(/[\W_]+/).each do |word| self.data.push(word.downcase) end end self.data.delete_if {|elemen...
true
5eba6191e3cb4323bd5caf4b853d0d4e881802f3
Ruby
delosiliana/thinknetica
/lesson_2/massive.rb
UTF-8
150
3.15625
3
[]
no_license
=begin Заполнить массив числами от 10 до 100 с шагом 5 =end def array arr = (10..100).step(5).to_a end p array
true
61226ef9442c52d20b44551750c1366f7fada4f1
Ruby
digitalh2o2/project-euler-even-fibonacci-q-000
/lib/oo_even_fibonacci.rb
UTF-8
409
3.59375
4
[]
no_license
# Implement your object-oriented solution here! class EvenFibonacci def initialize(limit) @limit = limit end def limit @limit end def sum array = [1,2] sum = 0 n = 2 while (array[n - 2] + array[n - 1]) < @limit array << (array[n - 2] + array[n - 1]) n += 1 end array.ea...
true
c42d580a0884915a0964068963ddcccfaa7d7925
Ruby
NexusClash/NexusClash
/opal/adventurer.rb
UTF-8
6,275
2.515625
3
[]
no_license
require 'opal' require 'browser' require 'browser/socket' require 'browser/console' require 'browser/dom' require 'browser/dom/document' require 'browser/http' require 'browser/delay' require 'native' require 'magellan' class Adventurer attr_accessor :id, :name, :hp, :hp_fuzzy, :hp_max, :mp, :mp_max, :xp, :level, ...
true
6a6c6fd8adc029bb7d4239b2fbe0ea6e5e7de467
Ruby
mmabraham/Games
/towers-of-hanoi/lib/computer_player.rb
UTF-8
1,959
3.109375
3
[]
no_license
module TowersOfHanoi class ComputerPlayer def initialize(game) @game = game @towers = game.towers @moves = [] end def get_move sleep(0.2) @moves << target_move if @moves.empty? @moves << add_next_move(@moves.last) until valid?(@moves.last) move = @moves.pop ...
true
62cf76a8b194e1edc260e565ba17895aa571e5f0
Ruby
funeace/Project-Euler
/Problem028.rb
UTF-8
638
3.515625
4
[]
no_license
# 1から初めて右方向に進み時計回りに数字を増やしていき, 5×5の螺旋が以下のように生成される: # 21 22 23 24 25 # 20 7 8 9 10 # 19 6 1 2 11 # 18 5 4 3 12 # 17 16 15 14 13 # 両対角線上の数字の合計は101であることが確かめられる. # 1001×1001の螺旋を同じ方法で生成したとき, 対角線上の数字の和はいくつか? # 差分2nを4回ずつ繰り返す # 結果を格納するs,現在の値を格納するn、増幅値を格納するstepを用意 a = 1 n = 1 step = 2 while n < 1001 * 1001 4.times ...
true
723362f6911e5c0ddf47b995cdf6e9750c26a9e1
Ruby
sergiomauz/Ruby-Bubble-Sort
/bubble_sort_by.rb
UTF-8
218
3.375
3
[ "MIT" ]
permissive
def bubble_sort_by(arr) k = arr.length while k > 1 i = 0 while i < k - 1 arr[i], arr[i + 1] = arr[i + 1], arr[i] if yield(arr[i], arr[i + 1]).positive? i += 1 end k -= 1 end arr end
true
359500a5e92da1b4810644831daec85cbba44d8c
Ruby
rafaelgauderio/ruby-basico
/orientacao_objetos/getter_and_setter.rb
UTF-8
1,127
4.125
4
[]
no_license
# coding: utf-8 class Pessoa attr_accessor :nome # getter and setter attr_reader :idade # apenas getter attr_writer :idade # apenas setter # construtor em ruby se chama initialize def initialize(nome) @nome = nome end def initialize(nome,idade) @nome = nome @idade = idade end def...
true
f3b9b879b912a197be95c6f5857b187f8204a2af
Ruby
learn-co-students/web-042417-code
/Module-2/Intro-Rack/montana.rb
UTF-8
512
2.78125
3
[]
no_license
require "erb" class Montana def call(env) # env.each { |k,v| puts "#{k}=>#{v}"} request = Rack::Request.new(env) case request.path when "/" then Rack::Response.new(render("index.html.erb")) when "/about" then Rack::Response.new(render("about.html.erb")) else Rack::Response....
true
8d08edfed767c3872c5d09a1e44060c393ec8ea6
Ruby
CounterSeal/ruby-newbie
/binary-tree.rb
UTF-8
2,297
4.15625
4
[]
no_license
# Binary Tree class Node attr_accessor :value, :left, :right def initialize(value) @value = value end =begin #Alternate Method def insert(new_node) if new_node < @value left.nil? ? self.left = Node.new(new_node) : left.insert(new_node) else right.nil? ? self.right = Node.new(new_node) : right.insert(...
true
81e7a47a62cd3f4743dd9afca98a7ed09cb2cc6f
Ruby
leadtune/workbench
/lib/workbench/string_helpers.rb
UTF-8
724
2.84375
3
[ "MIT" ]
permissive
module Workbench # A collection of needed String methods. They are here to remove a dependency on ActiveSupport. You can use them if you want... but you probably should use ActiveSupport or copy them into your project. module StringHelpers # takes :User, "user", or :user and returns User def self.constantiz...
true
c67d8e766d0694837648406006ee1c998ac87413
Ruby
Magehawks/ruby-colearning-warmup-exercises
/max_warmup-002/max_warmup-002.rb
UTF-8
387
3.609375
4
[]
no_license
require "date" def generate_dates(quantity) array = [] 0.upto(quantity).each do |number| inside = Date.today + number array.push inside end array end array = generate_dates(2) var_shuffle = array.shuffle var_random_element = shuffle[0] var_today = Date.today if var_random_element == var_today puts ...
true
9f68c6c718cf876cc72264f73e247b40222f1f02
Ruby
DGDegrassi/imageblur1
/imageblur.rb
UTF-8
487
3.75
4
[]
no_license
class Image #initializes image with the input def initialize(a) @image = a end #joins each array into a string and adds each string to a new array def twodimensional twod = [] @image.each do |i| @twodimensional = i.join @twod = twod << @twodimensional end end #outputs def ...
true
8f4833360daf03c9453e5b76c1e8c6fd457f5c1d
Ruby
Dpalazzari/HTTP
/lib/server.rb
UTF-8
1,866
3.015625
3
[]
no_license
require 'pry' require 'socket' require_relative 'router.rb' require_relative 'parser.rb' require_relative 'dictionary.rb' require_relative 'game.rb' class Server attr_reader :tcp_server, :router, :count def initialize @tcp_server = TCPServer.new(9292) @router = Router.new @count = 0 end def loop...
true
930253b68bbe9a6ce8eb125c45afa17b0539341a
Ruby
ftuyama/stations-human-diff
/lib/shd/logger.rb
UTF-8
676
2.703125
3
[ "MIT" ]
permissive
require "singleton" module SHD class Logger include Singleton class << self def method_missing(name, *args, &block) if instance.respond_to?(name) instance.public_send(name, *args, &block) else super end end def respond_to_missing?(name, *_args) ...
true
5b775052c72f1bc6b5586715ea9f677ce5476a3b
Ruby
DaveGamble/cJSON
/tests/unity/test/spec/generate_module_existing_file_spec.rb
UTF-8
4,386
2.703125
3
[ "MIT" ]
permissive
require '../auto/generate_module.rb' require 'fileutils' def touch_src(file) FileUtils.touch "sandbox/src/#{file}" end def touch_test(file) FileUtils.touch "sandbox/test/#{file}" end def create_src_with_known_content(file) File.open("sandbox/src/#{file}", "w") {|f| f.write("the original #{file}")} end def cr...
true
764d81dd72961be6d89ba9fe506d0bac5afbddbb
Ruby
matteo07/bowling
/lib/tasks/bowling.rb
UTF-8
950
3.3125
3
[]
no_license
require_relative 'divide_shots.rb' require_relative 'frame.rb' class Bowling include Frame include DivideShots def start_game @total_pins = 10 @total_frames = 10 @score = 0 @is_spare = false @is_strike = false @is_two_strike = false @is_martian_rule = false @is_venusian_rule = fa...
true
e67f7da1cec97e3bf611ba83071c5501d00f5641
Ruby
nguyenhmp/ruby-september-2016
/AdamJ/TDD/project/project.rb
UTF-8
261
2.953125
3
[]
no_license
class Project attr_accessor :name, :description def initialize(name, description) @name = name @description = description self end def elevator_pitch "#{@name}, #{@description}" end def add_to_team(team_member) team_member=team_member end end
true