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
1dd77065cfab056a7d6409fe0fc9ee49537fb014
Ruby
jwinter/arbybot
/lib/commands/pull_command.rb
UTF-8
1,031
2.609375
3
[]
no_license
require 'optparse' module Commands class PullCommand def initialize(args=[]) @args = args || [] end def messages options = parse_arguments if options[:help] options[:help] else repos.map do |repo| Github.formatted_pull_requests(repo, options[:links]) ...
true
08e0fc3d716d59d5bedce4465e49ea0ae7a83b66
Ruby
burtlo/training-050613
/testing_super/super_example_spec.rb
UTF-8
926
2.953125
3
[]
no_license
# require 'spec_helper' class BaseRenderer def initialize(base,options={}) @base = base @options = options end def data @data ||= fetch_data_from_external_service(@options[:url]) end def fetch_data_from_external_service(url) ExternalService.new(url).fetch_data end def render! puts...
true
71f1d740a691aa93b16e7acfe5d50b2f3af6339f
Ruby
kaineer/ream
/lib/ream/onion.rb
UTF-8
946
3.40625
3
[ "MIT" ]
permissive
#=============================================================== # class: Ream::Onion # date: 2005.11.16 # # brief: Hashes' multylayer wrapper #=============================================================== module Ream # # class Onion # # def initialize @stack = [] end # # ...
true
e78489f068e2ccd854846712fca2dd8d57d52002
Ruby
yuroyoro/lambda_driver
/spec/op_spec.rb
UTF-8
1,704
2.546875
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- require 'spec_helper' shared_examples_for 'method_or_lambda' do |label| let(:method_name) { :+ } context 'given method name (is reciever object responds)' do subject { method } it { should be_a_kind_of Method } it("#{label}.call(args) should be obj.send(method_name, args)"){...
true
d9223d688a675b283faf85199da039499f43a826
Ruby
visu21/TestRubyProject
/features/support/pages/expedia_home_page.rb
UTF-8
2,075
2.625
3
[]
no_license
# require_relative '../modules/utilities' # class ExpediaHomePage # include PageObject # include Utilities # # page_url 'www.expedia.com' # link(:select_flight_tab, :id => 'tab-flight-tab') # label(:select_round_trip_flight, :id => 'flight-type-roundtrip-label') # text_field(:departure_airport, :id => 'flig...
true
13e74e2f0e83790336bc332d3400b63ac0deada9
Ruby
xuxiangyang/ding_ding_robot
/lib/ding_ding_robot.rb
UTF-8
1,374
2.96875
3
[ "MIT" ]
permissive
require "ding_ding_robot/version" require "ding_ding_robot/errors" require "ding_ding_robot/message" require 'uri' require 'net/http' require 'json' class DingDingRobot attr_accessor :access_token, :max_retry def initialize(access_token) @access_token = access_token @max_retry = 3 end def send_message...
true
d484a3209b9623892655a233e41dc1547a1afa2c
Ruby
basushaunak/substring-ruby
/substring.rb
UTF-8
657
3.21875
3
[]
no_license
def substring(in_phrase,in_word_list) phrase = in_phrase.downcase.split() words=[] in_word_list.each do |word| words.push(word.downcase()) end found = {} words.each do |word| # Individual words in the dictonary phrase.each do |wrd| # Individual words in the phrase if ...
true
15345be1a2756c5c723ec9722dac70b603b1916f
Ruby
Kariag/phase-0-tracks
/ruby/santa.rb
UTF-8
3,934
4.03125
4
[]
no_license
# A speak method that will print "Ho, ho, ho! Haaaappy holidays!" (Santa has been working on being more inclusive.) # An eat_milk_and_cookies method that takes a cookie type (example: "snickerdoodle") as a parameter and prints "That was a good <type of cookie here>!" # An initialize method that prints "Initializing San...
true
144b3ebc1974edd0eeb1e258b5e3ef0d29b63aa1
Ruby
TimHood/rspec-test-first
/02_calculator/calculator.rb
UTF-8
519
3.890625
4
[]
no_license
def add(n1, n2) n1 + n2 end def subtract(n1, n2) n1 - n2 end def sum(nums) return 0 if nums.length == 0 return nums[0] if nums.length == 1 i = 0 sum = 0 while i < nums.length sum += nums[i] i += 1 end return sum end #copied this method from rubymonk tutorial def multiply(*numbers) numbers.inject(1) { ...
true
fe5a8762ab4b459c67217caeac9b72d65ba3d27f
Ruby
tazsingh/carrierwave_imagevoodoo
/benchmarks/minimagick_vs_imagevoodoo.rb
UTF-8
665
2.515625
3
[ "MIT" ]
permissive
require "benchmark" require "carrierwave" class CatUploader < CarrierWave::Uploader::Base storage :file version :thumbnail do process resize_to_fit: [200, 200] end end cat_file = File.new("images/cat.jpg") case RUBY_PLATFORM when "java" require "../lib/carrierwave_imagevoodoo" CatUploader.send :includ...
true
df51f109e51450e65c7db86e48065045f5920b97
Ruby
JulianNicholls/Adventure
/ruby/weapon.rb
UTF-8
406
3.296875
3
[]
no_license
require './formatters' # A weapon for an adventure class Weapon include Formatters attr_reader :name, :power def self.load(str) weapon = /(?<name>.*)\s(?<power>\d+)/.match str new(weapon[:name], weapon[:power].to_i) end def initialize(name, power) @name = titlecase(name) @power = power ...
true
903c28bb51c059d63cb09417003081058f4dab97
Ruby
skryl/restforce-db
/lib/restforce/db/command.rb
UTF-8
4,069
2.53125
3
[ "MIT" ]
permissive
require "daemons" require "optparse" module Restforce module DB # Restforce::DB::Command represents the command line interface for our # daemonized processing loop. It captures a set of options from the command # line to configure the running worker thread for synchronizing data. class Command ...
true
f1ce032395fd8a606ca3b364a92e91cb58463144
Ruby
aasmith/consim
/lib/consim/simulator.rb
UTF-8
940
2.78125
3
[]
no_license
module Consim # A class to facilitize multiple deployment run-throughs, as some placement # strategies can be non-deterministic. class Simulator attr_reader :cluster, :services def initialize(cluster, services) @cluster = cluster @services = services end def simulate(n = 100) ...
true
f3412cef630c1f69ffcd262b56e3a85cb1e20f00
Ruby
tf0228/NazoTalk
/app/models/favorite.rb
UTF-8
624
2.609375
3
[]
no_license
class Favorite < ApplicationRecord belongs_to :user belongs_to :question after_create :rank_change after_destroy :rank_change protected def rank_change favorites_count = self.question.user.questions.inject(0) { |sum, n| sum += n.favorites.count } if favorites_count < 10 self.questio...
true
000b5b3d627e0fc382aeea9f3310b195fc9989e4
Ruby
Claiborne/media-qa
/test/lib/prime/sqlserver.rb
UTF-8
888
2.5625
3
[]
no_license
#require 'tiny_tds' module SqlServer def get_user_id #creates a new db object using our dev sql server # client = TinyTds::Client.new(:username => 'fklun', :password => 'J3d1r0xorz%', :host => 'igndevsql01.las1.colo.ignops.com', :database => 'Gametrack', :login_timeout => 60) # puts client.active? ...
true
4706a214ee284af43ee339a3e5a3b2a22640695f
Ruby
richmit/ex-aupg
/fqdns.rb
UTF-8
1,372
2.890625
3
[]
no_license
#!/usr/local/bin/ruby # -*- Mode:Ruby; Coding:us-ascii-unix; fill-column:132 -*- #################################################################################################################################### # @file fqdns.rb # @author Mitch Richling <https://www.mitchr.me/> # @Copyright Copyright 2012 by...
true
6ed4a1e8c7c7a2905e5a40ceb1a8ad69defc0bf7
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/hamming/144cc72c001b4b49a96909e032655fb4.rb
UTF-8
588
3.578125
4
[]
no_license
class DNA attr_reader :original_strand, :other_strand def initialize(original_strand) @original_strand = original_strand end def hamming_distance(other_strand) @other_strand = other_strand count = 0 index = 0 if lowest_common_length > 0 lowest_common_length.times do ...
true
3c29422c649eac497b0748a61a5782fcdb588afe
Ruby
Kohei909Otsuka/temona_tech_ed_doc
/freshman/persistent_todo/04_clean_version/todo_csv_storage_test.rb
UTF-8
947
2.890625
3
[]
no_license
require "csv" require "minitest/autorun" require_relative "todo_csv_storage" class TestTodoCsvStorage < Minitest::Test PATH = "test_data/todo.csv" DUMMYS = [ {id: 1, name: "task1"}, {id: 2, name: "task2"}, {id: 3, name: "task3"}, {id: 4, name: "task4"}, ] def setup @storage = TodoCsvStorag...
true
714e6f149d9628c2ac58878a0cc923b725017990
Ruby
babyshoes/prime-ruby-web-0715-public
/prime.rb
UTF-8
133
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime?(num) arr = Array(1..(num/2).ceil) arr.each do |x| return false if x != 1 && num % x == 0 end return true end
true
3b915982de95bc5abd9a24680dd51e2f91987096
Ruby
TwilioDevEd/anonymous-communications-rails
/app/models/reservation.rb
UTF-8
2,520
2.53125
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
class Reservation < ActiveRecord::Base validates :name, presence: true validates :guest_phone, presence: true enum status: [ :pending, :confirmed, :rejected ] belongs_to :vacation_property belongs_to :user, optional: true def notify_host(force = false) # Don't send the message if we have more than on...
true
180be9643502411c5126d321bfb140a6113c0908
Ruby
KSureshB/palindrome
/lib/palindrome.rb
UTF-8
470
3.25
3
[ "MIT" ]
permissive
require "palindrome/version" module Palindrome class Palindrom def reverse(word_arr) reverse = [] index = word_arr.length until index == 0 do reverse << word_arr[index - 1] index -= 1 end reverse end def is_palindrome?(word) word_arr = word.downcase.gsub(/ /,'').split('') if word_arr == reverse...
true
0c84ce5ef17b894f88204625775f57bb963d1f03
Ruby
kokoko313/codewars
/luhn.rb
UTF-8
1,847
4.09375
4
[]
no_license
def digits_of(n) n.to_s.split('').map! { |s| s.to_i } end def luhn_checksum(card_number) digits = digits_of(card_number) # выбор четных/нечетных odd_digits = digits.values_at(*digits.each_index.select(&:odd?)) even_digits = digits.values_at(*digits.each_index.select(&:even?)) #четные X2 even_digits.map! {|...
true
dee859695bf400b3bacfe67ecd05b46fe3b52de4
Ruby
izumin5210-sandbox/coding-exercises
/arc056/b/main.rb
UTF-8
602
3.078125
3
[ "MIT" ]
permissive
require 'set' n, m, s = gets.split(' ').map(&:to_i) routes = Hash.new { |h, k| h[k] = [] } m.times do u, v = gets.split(' ').map(&:to_i) routes[u] << v routes[v] << u end used = Set.new users = [] 1.upto(n) do |n_i| i = s visited = Set.new candidates = Set.new candidates.add(i) unless used.include?(i...
true
b41d26218f5c51422cf6519168cbc44b14d5b45c
Ruby
Eden-Eltume/120
/Lesson_4_OO_Practice_Problems/Easy3/ex6.rb
UTF-8
629
4.625
5
[]
no_license
# We could simply remove the self keyword because attr_accessor gives us acess to the age instance variable. # Thus making the keyword self redudant. # This means in this case self and @ are the same thing and can be used interchangeably. class Cat attr_reader :age def initialize(type) @type = type @age ...
true
fe952b493ac2f86d9b0eb3f903f0733e703e7f3c
Ruby
timsully/learn_ruby_the_hard_way
/ex31.2.rb
UTF-8
733
3.78125
4
[]
no_license
puts "You're stranded in boonies, what do you do?" puts "\v 1. Run away from home?" puts "\v 2. Stay home?" print "> " choose_fate = $stdin.gets.chomp if choose_fate == "1" || "2" puts "There is a computer that your friend gave you. What do you do?" puts "1. Play video games on it." puts "2. Configure the compu...
true
bb473a3568390b9afefd84d386ae7d3f7ee2fa7b
Ruby
ha4gu/atcoder
/ABC/110/119/C2.rb
UTF-8
895
3.453125
3
[]
no_license
N, A, B, C = gets.split.map(&:to_i) $needs = [0, A, B, C] $mp = [] BAMBOOS = N.times.map { gets.to_i } # p BAMBOOS $count = 0 def calc_mp(array) # 0: 使わない、 1: Aに使う、2: Bに使う、3: Cに使う if (array.include?(1) && array.include?(2) && array.include?(3)) # 1, 2, 3があるパターンでないと条件を満たせない # p array mp = 0 (1..3)....
true
935a6c9c7ed0ae22b9c2967cbdfd7fab6290ced4
Ruby
mikennaji/ttt-game-status-cb-000
/lib/game_status.rb
UTF-8
1,344
3.703125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Helper Method def position_taken?(board, index) !(board[index].nil? || board[index] == " ") end # Define your WIN_COMBINATIONS constant WIN_COMBINATIONS = [ [0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[6,4,2]] def full?(board) board.all? { |x| x=="O" || x == "X" } end def draw?(board) set = w...
true
f590f278e77cb72844890f075d5d05dff58bbb12
Ruby
DruRly/baseball
/run.rb
UTF-8
592
3.671875
4
[]
no_license
require_relative 'baseball' #1. Most improved batting average year_from = 2009 year_to = 2010 puts "Most improved batting average (#{year_from} to #{year_to})" puts BaseballStatsCalculator.most_improved_batting_average year_from, year_to #2. Slugging percentage team = "OAK" year = 2007 puts "Slugging percentage for #...
true
3d842fa300d417e3d2aa8d4f06d910da38123fe9
Ruby
shktkt219/ttt-with-ai-project-v-000
/lib/game.rb
UTF-8
2,604
3.53125
4
[]
no_license
class Game attr_accessor :board, :player_1, :player_2 WIN_COMBINATIONS = [ [0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [6,4,2] ] def initialize(player_1 = Player::Human.new("X"), player_2 = Player::Human.new("O"), board = Board.new) @player_1 = player_1 ...
true
653d8bd68fd8470ab5ca17fdde59203e5e1aacb0
Ruby
ojima-h/sorge
/lib/sorge/dsl/trigger.rb
UTF-8
3,690
2.515625
3
[ "MIT" ]
permissive
module Sorge class DSL module Trigger class << self def classes @classes ||= {} end def register(name, klass) classes[name] = klass end def [](type) classes.fetch(type) do raise NameError, "undefined trigger #{type}" ...
true
acdc2d644d1b9dec574bb3094fa0fabbdcda3b00
Ruby
easyhappy/useful
/codes/eager_loading.rb
UTF-8
1,751
2.84375
3
[]
no_license
require 'rubygems' require 'faker' require 'active_record' require 'benchmark' # This call creates a connection to our database. ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "127.0.0.1", :username => "tianji", :password => "tianji", :database => "andy") ...
true
ac71312b72c1305eb6dc069e5f1540224f8ce9cc
Ruby
mpissanos/anagram-detector-online-web-ft-092418
/lib/anagram.rb
UTF-8
290
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" class Anagram attr_accessor :word def initialize(word) self.word = word end def match(arr) # binding.pry match_arr = [] arr.each { |w| match_arr << w if w.scan(/\w/).sort == self.word.scan(/\w/).sort } match_arr end end
true
36b6ccea3b94932ac06fe2044e137696e9ee5cdf
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/0f74bd27801642a3a2648f085d5c1ed3.rb
UTF-8
385
3.90625
4
[]
no_license
class Bob def hey words words = words.strip.gsub(/\s/, "") if words.empty? "Fine. Be that way!" elsif is_shouting? words "Woah, chill out!" elsif is_question? words "Sure." else "Whatever." end end private def is_shouting?(words) (words == words.upcase) en...
true
59edbe725f9ebe3932e54dec8fde419c616e12ce
Ruby
kristru/address-bloc
/models/address_book.rb
UTF-8
2,207
3.96875
4
[]
no_license
require_relative 'entry' require "csv" class AddressBook attr_reader :entries def initialize @entries = [ ] end def add_entry(name, phone_number, email) index = 0 @entries.each do |entry| if name < entry.name break end index += 1 end @entries.insert(@entries.leng...
true
eab6a0597aa811f48b251672ce85934decba8bda
Ruby
jsundo015/recursion_practice
/recursion_exercises.rb
UTF-8
2,684
3.71875
4
[]
no_license
#Warmup def range(start, en) return [] if en < start return [en] if en == start [start] + range((start+1), en) end def sum_iter(arr) sum = 0 arr.map{|num| sum += num } return sum end def sum_recur(arr) return arr[0] if arr.length == 1 arr[0] + sum_recur(arr[1..-1]) end #Exponentiation...
true
6e4af1125456b903d061a51c8be923605e5b2325
Ruby
SaphMB/bank-tech-test
/lib/printer.rb
UTF-8
173
2.84375
3
[]
no_license
class Printer def print_statement(transactions) puts 'date || credit || debit || balance' transactions.each { |transaction| puts transaction.to_string } end end
true
215c3ecc27769508a327a3ae1552a4250c75572e
Ruby
tullur/mampf
/app/models/solution.rb
UTF-8
886
2.875
3
[ "MIT" ]
permissive
# Solution class # plain old ruby class, no active record involved class Solution attr_reader :content attr_accessor :explanation def initialize(content) @content = content end def self.load(text) YAML.load(text) if text.present? end def self.dump(solution) solution.to_yaml end def typ...
true
1f4be782607aff7bf8592f0293d37ce73ef78dbc
Ruby
d-low/d-low.com
/app/models/post.rb
UTF-8
1,890
3.09375
3
[]
no_license
# The Post model encapsulates all the information about a post including the path to it, its # title, the date of the post, an array of the images found in it, the content, and the date # if was last updated. class Post attr_reader :path attr_reader :title attr_reader :date attr_reader :images attr_reader :conten...
true
cc8e0ea1e3f243498402ec036d5a30c29f1bbab6
Ruby
misnyo/dacp
/dacp/dacpinstance.rb
UTF-8
4,038
2.65625
3
[]
no_license
require 'pp' require 'net/scp' ## #Represents an AWS instance class DacpInstance ## #Queries instance data from AWS def initialize(ec2, options, name) @options = options @ec2 = ec2 @name = name resp = @ec2.describe_instances({filters: [ { ...
true
2c803130bd7018048266db6b79187e69ee444305
Ruby
josh-sea/idea-testing
/cigar/lib/review.rb
UTF-8
247
2.734375
3
[]
no_license
class Review attr_reader :review, :user, :cigar @@all = [] def self.all @@all end def initialize(review, user, cigar) @review = review @user = user @cigar = cigar @@all << self end end ## end of cigar class
true
89e43f0c7cfaca080761090e5a0ff641cd3c88d4
Ruby
wilsonafs/ruby
/aula2.rb
UTF-8
147
3.546875
4
[]
no_license
puts "Digite o seu nome" nome = gets.strip puts "Olá #{nome}, qual a sua idade?" idade = gets.strip puts "Olá #{nome}, você tem #{idade} anos."
true
4b60f467241d3f8bc107ceaf83474a4b58c2f680
Ruby
yukas/brainfuck-transpiler
/brainfuck_transpiler.rb
UTF-8
958
3.46875
3
[]
no_license
class BrainfuckTtanspiler def initialize @numbers = [] @brainfuck_code = [] end def get_brainfuck_code input find_a_conclusion get_the_numbers_to_ASCII convert_brainfuck_code output_to_file end private attr_reader :file, :numbers, :text, :brainfuck_code def input...
true
6e77f32fe0eb72c176045abbc1474b1a4195945c
Ruby
DanielleInkster/Battle-1
/spec/game_spec.rb
UTF-8
908
2.90625
3
[]
no_license
require 'game' describe Game do let (:player1) { double :player1 } let (:player2) { double :player2 } subject(:game) { described_class.new(player1, player2) } it 'allows access to players' do expect(player1).to receive(:name) subject.player1.name end it 'knows the current player' do expect(s...
true
05f412692ec26151c3ee86167b29000927de5ba3
Ruby
Bis87/goodprogrammers_2
/lesson_2/dice.rb
UTF-8
178
3.703125
4
[]
no_license
puts "how many dice?" number = gets.to_i dice_summ = 0 number.times do dice = rand(6) + 1 puts dice dice_summ += dice end puts "Your scores: #{dice_summ}"
true
b2a9afad66317b0796305bf73e1bfbcc31922c81
Ruby
garrettlasky1982/rubocop
/lib/rubocop/cop/lint/to_json.rb
UTF-8
966
2.5625
3
[ "CC-BY-NC-4.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module RuboCop module Cop module Lint # This cop checks to make sure `#to_json` includes an optional argument. # When overriding `#to_json`, callers may invoke JSON # generation via `JSON.generate(your_obj)`. Since `JSON#generate` allows # for an optional ar...
true
424ace383cc9e517f46af432d60a85fd24401e94
Ruby
michellejanosi/ruby-practice
/codewars/convert_boolean.rb
UTF-8
260
4.1875
4
[]
no_license
# Complete the bool_to_word (Javascript: boolToWord ) method. # Given: a boolean value # Return: a 'Yes' string for true and a 'No' string for false def bool_to_word bool bool ? "Yes" : "No" end bool_to_word(true) # => 'Yes' bool_to_word(false) # => 'No'
true
0caa8b1792714f6878bd0c76dfce4b778859e26d
Ruby
adam-dratwinski/multiplications
/app/multiplication_table.rb
UTF-8
324
3.203125
3
[]
no_license
class MultiplicationTable attr_accessor :rows, :cols def initialize(rows, cols) @rows, @cols = rows, cols end def get_row(n) @rows.map { |v| v * @cols[n] } end def get_all result = [["x"] + @rows] @cols.size.times do |i| result << [@cols[i]] + get_row(i) end result end ...
true
5572a48eb27f4fa754e9d1676a9898ace32bb62f
Ruby
tomdalling/rschema
/lib/rschema/schemas/set.rb
UTF-8
1,923
2.875
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true require 'set' module RSchema module Schemas # # A schema that matches `Set` objects (from the Ruby standard library) # # @example A set of integers # require 'set' # schema = RSchema.define { set(_Integer) } # schema.valid?(Set[1, 2, 3]) #=> true...
true
d73a09155e148b4c4a1e8f707eec5173588d0078
Ruby
Kagayakashi/learn_ruby
/lesson2/task4.rb
UTF-8
471
3.765625
4
[]
no_license
puts "Хеш латинских букв и их порядковый номер" letters = ("A".."Z").to_a vowels = ["A","E","I","O","U","Y"] letter_hash = {} # Заполнить хеш буквами и порядковым номером letters.each.with_index(1) do |letter, order| letter_hash[letter] = order if vowels.include?(letter) end # Вывести хеш букв letter_h...
true
43876f4cd214a072e4ed2d78532a50cc5f742ec4
Ruby
finishit/nutrition_service
/lib/tasks/metadata.rake
UTF-8
785
2.515625
3
[]
no_license
namespace :metadata do task :generate_migrations, [:path] => :environment do |task, arguments| m_files = files(arguments.path) m_files.each do |file| file_name = file[0][0] csv = file[1][0] resource = get_resource(file_name) metadata = get_metadata(resource, csv) metadata.gener...
true
c8098bd3ee21c025033b782178d65cd0424e5dac
Ruby
JessicaG/sales_engine
/test/merchant_test.rb
UTF-8
661
2.546875
3
[]
no_license
require_relative 'test_helper' require 'date' class MerchantTest < Minitest::Test attr_reader :merchant, :repository def setup data = {id: "1", name: "Schroeder-Jerde", created_at: "2012-03-27 14:53:59 UTC", updated_at: "2012-03-27 14:53:59 UTC"} @repository = Minitest::Mock.new @merchant = Merc...
true
f68db42d3415eae9f94bef77c6e490a253bd69d2
Ruby
le0ra/eplusinterface_diagrams
/sketchup/old_trunk/ruby/area.rb
UTF-8
357
2.859375
3
[]
no_license
# calculate the area of faces model=Sketchup.active_model selection_set = model.selection if selection_set.length == 0 selection_set = model.active_entities end fcount = 1 selection_set.each {|entity| if entity.class == Sketchup::Face puts sprintf('face:%s', fcount) puts sprintf(' area:%s',...
true
6727e5425156d6bb998ce6969cbc6cefbce0dd5e
Ruby
Macro80-20/rack-responses-lab-london-web-career-031119
/app/application.rb
UTF-8
586
2.65625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Application def call(time) resp = Rack::Response.new resp.write "good Morning\n" resp.write "good Afternoon\n" resp.finish end end # it 'wishes user a good morning in the morning' do # allow(Time).to receive(:now){ # Time.new(2015,11,27,9,30) # } # get '/' # expect(last_r...
true
53e316fae178129d56e494ee8c0eee25157b915b
Ruby
epitron/scripts
/pacman-rollback
UTF-8
3,399
2.75
3
[]
no_license
#!/usr/bin/env ruby ##################################################################### require 'epitools' ##################################################################### Package = Struct.new(:root, :file, :desc, :date, :size) class Package include Comparable ARM_ROOT="https://archive.archlinux.org/pac...
true
c03a382ea13b1bbca9474fb9becba866067c4f7b
Ruby
Kangb0tmang/wdi13_warmups
/ruby_squares/get_squares.rb
UTF-8
257
3.40625
3
[]
no_license
require 'pry' def get_squares(arr) results = [] arr.each do |num| # if Math.sqrt(num) % 1 == 0 if (Math.sqrt(num) % 1).zero? results.push(num) end end puts results.sort.uniq end get_squares([4, 1, 16, 1, 10, 35, 22]) binding.pry
true
67d070417ddb7816d17e6a971ee898be4a6bbe77
Ruby
blairanderson/sales_engine
/lib/sales_engine/transaction.rb
UTF-8
2,522
2.578125
3
[ "MIT" ]
permissive
module SalesEngine class Transaction attr_reader :id, :invoice_id, :credit_card_number, :credit_card_expiration_date, :result, :created_at, :updated_at def initialize(input) @id = input[:id].to_i @inv...
true
a4b6c81ad5f5925baeda3bc429fb0d623964ddf1
Ruby
blitzcom/skywrath
/test/models/user_test.rb
UTF-8
2,620
2.53125
3
[]
no_license
require "test_helper" class UserTest < ActiveSupport::TestCase def setup @user = User.new(email: "foo@bar.com", password: "123456", password_confirmation: "123456") end class Create < UserTest test "valid on create" do assert @user.valid? end test...
true
3e17f1333c4e9b064da760afa2d14258f96aa75f
Ruby
aguilarsoto/pathfinder
/spec/pathfinder_grid_spec.rb
UTF-8
1,609
3
3
[]
no_license
require 'spec_helper' describe Pathfinder::Grid do before :each do @grid = Pathfinder::Grid.new(5, 6) end it "should know the length, the size of the grid and initialize the rovers" do @grid.length.should == 5 @grid.size.should == 6 @grid.rovers.should == [] end it "should only allow valid...
true
fb6e3cfa18da2617beb2e9e7ab69c62a27966965
Ruby
Tsukasaki-keiji/bookers2-debug
/test.rb
UTF-8
520
3.765625
4
[]
no_license
# if num = "lslslslsls" # 代入が成功 # puts "成功" # else # puts "失敗" # end # ------------------------------------ # num = 10 # if num == 10 # 等しいかどうか # puts "成功" # else # puts "失敗" # end #------------------------------------- num = 0 if num # そもそも存在するかどうかかつ,truthyな値かどうか puts "成功" else puts "失敗" end # * 言語によっ...
true
b7aac8d3e7fd0b3b87deb08a56a09d761bde82bc
Ruby
PeckLiu2017/algorithm_practice
/string_problem/replace_string.rb
UTF-8
2,472
3.328125
3
[]
no_license
def replace(str, from, _to) return str if str.nil? || from.nil? || str.eql?('') || from.eql?('') chas = str.chars chaf = from.chars match = 0 chas.each_with_index do |_k, i| if _k == chaf[match] match +=1 if match == chaf.size clear(chas, i, chaf.length) match = 0 end ...
true
410272d7e69acd851c1e35f09356f20656cfd925
Ruby
kevinkrainson/Homework
/Deafgrandma.rb
UTF-8
244
3.46875
3
[]
no_license
puts "HUH?" while true do print '> ' response = gets.chomp if response == "BYE" break elsif response != response.upcase puts "HUH?! SPEAK, SONNY!" else year = rand(1930 .. 1951) puts "NO, NOT SINCE #{year}" end end
true
b939b10f335ee719e1ad0d417b77c23dd1768c0f
Ruby
adammcc/Rynoq
/spec/models/stock_spec.rb
UTF-8
835
2.671875
3
[]
no_license
require 'spec_helper' describe Stock do before(:all) do @stock = Stock.create(ticker:'goog', company_name:'Google') end it "is a class" do Stock.class.should == Class end it "can be instantiated" do @stock.class.should == Stock end it "has a ticker attribute" do @stock.ticker.should == 'goog' end ...
true
bdd0f2f54358a24cd629fbd17f4dbe02a3b9ee1d
Ruby
twcrone/euler
/problem19/solve_problem_19.rb
UTF-8
3,461
3.53125
4
[]
no_license
class SundayCalculator FIRST_DAYS = [1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335] FIRST_DAYS_LEAP_YEAR = [1, 32, 61, 92, 122, 153, 183, 214, 245, 275, 306, 336] def sunday?(year, month, day) (day - first_sunday(year)) % 7 == 0 end def leap_year?(year) return year % 4 == 0 unless year % 1...
true
3dfc2328191cc354e93ae5db3f887b5dd9e8063b
Ruby
ashleyskyeryan/rspec-fizzbuzz-cb-000
/fizzbuzz.rb
UTF-8
205
3.578125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def fizzbuzz(user_number) user_number = gets.to_i if user_number / 3 == % 0 puts "Fizz" elsif user_number / 5 == % 0 puts "Buzz" elsif user_number / 15 == % 0 puts "FizzBuzz" else puts "nil" end
true
5c35ba830a00d9397b5e38d72206cdd33d96ad23
Ruby
jhunschejones/Rangor
/_coding tests/class_test3.rb
UTF-8
935
4.25
4
[]
no_license
# define a class for saving a user value to a file class SaveValue def initialize() end def take_value(v) @v = v File.new "save.txt", 'w' file = open "save.txt", 'w' file.write(@v) file.close end end # define a class for retrieving a value from a file class GetValue def initialize() ...
true
e92b4b582474a7b3046f0ffe64cb6de0ed74279f
Ruby
systemnate/exercism
/crypto-square/crypto_square.rb
UTF-8
628
3.4375
3
[]
no_license
class Crypto attr_reader :str def initialize(str) @str = str end def normalize_plaintext @str.downcase.scan(/\w+/).join("") end def size sz = normalize_plaintext.size Math.sqrt(sz).ceil end def plaintext_segments normalize_plaintext.chars.each_slice(size).to_a.map { |w| w.join(""...
true
ce3465e065c182a450d22c573677321868f6e8e0
Ruby
Yoomee/bta
/lib/embedit/validate.rb
UTF-8
2,513
2.671875
3
[]
no_license
# ----------------------------------------------------------------------- # # Copyright (c) andymayer.net Ltd, 2007-2008. All rights reserved. # This software was created by andymayer.net and remains the copyright # of andymayer.net and may not be reproduced or resold unless by prior # agreement with andymayer.net. #...
true
91bf0cca99ca6b6a95d694bb3d1c6325425384e5
Ruby
felipeelias/resubject
/lib/resubject/extensions/template_methods.rb
UTF-8
4,431
2.953125
3
[ "MIT" ]
permissive
require 'active_support/time' module Resubject module Extensions # All Rails extensions module TemplateMethods # Generates an attribute using `number_to_currency` helper from rails # # @example # # class ProductPresenter < Resubject::Presenter # currency :price ...
true
3e78ce9db93be459b406151c31886ecb96c2a094
Ruby
dkhofer/advent-of-code
/2015/spec/day20_spec.rb
UTF-8
984
2.84375
3
[ "MIT" ]
permissive
require 'spec_helper.rb' describe "day 20" do context "divisors" do it "finds divisors correctly" do expect(divisors(4)).to eq Set.new([1,2,4]) end end context "part 1" do it "works for low numbers" do expect(house_presents(1)).to eq 10 expect(house_presents(2)).to eq 30 expe...
true
17650a5cd34c1d03a03ecd982e5c5d4301f66800
Ruby
alexcutschall/module_3_final
/app/serializers/game_serializer.rb
UTF-8
604
2.609375
3
[]
no_license
class GameSerializer < ActiveModel::Serializer attributes :game_id has_many :scores def player_1_score object.player_1.plays.map do |play| play.score end.sum end def player_2_score object.player_2.plays.map do |play| play.score end.sum end class PlaySerializer < ActiveModel:...
true
2c5ebbc2dc666f64ea4275f14666001082e00ff5
Ruby
DanMcDonald91/Animal_Shelter_Project
/db/seeds.rb
UTF-8
1,158
2.796875
3
[]
no_license
require('pry-byebug') require_relative("../models/animal") require_relative("../models/owner") require_relative("../models/adoption") animal1 = Animal.new({ "animal_name" => "Biggy","species" => "Dog","breed" => "BullDog","admission_date" => "2017-02-05","adoption_status" => "Available"}) animal2 = Animal.new({ "an...
true
2a933d4bc06a8f497f5a4c56abb51aebbfeadd7e
Ruby
fnando/recurrence
/test/recurrence/include_test.rb
UTF-8
2,475
2.703125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require "test_helper" class IncludeTest < Minitest::Test test "includes date (day)" do r = recurrence(every: :day, starts: "2008-09-30") assert r.include?("2008-09-30") assert r.include?("2008-10-01") end test "includes date (week)" do r = recurrence(every: :week, ...
true
86755984b264ec3a5061a5e3c2b6a2d7c3029981
Ruby
ddeleon267/ddeleon-cli-app
/lib/whats_on_tap/scraper.rb
UTF-8
4,979
3.015625
3
[ "MIT" ]
permissive
require "pry" class WhatsOnTap::Scraper def self.get_beer_menu_site(city) encoded_city = URI::encode(city) Nokogiri::HTML(open("https://www.beermenus.com/search?q=#{encoded_city}")) end def self.make_locations(city) page = self.get_beer_menu_site(city) page.css("div.pure-u-1").each do |data| ...
true
1cfb5a4aa2b83479243970284023da183c0d82a6
Ruby
wojciechzuccola1987/doppelganger
/test/sample_files/sexp_test_file.rb
UTF-8
110
2.96875
3
[ "MIT" ]
permissive
def muir puts "John Muir" @variable = "muir" %w(this is some words).each do |word| word.size end end
true
f3c6453d9fed924e65077b74b17a455184513c7b
Ruby
pn-y/interactive_bitmap_editor
/lib/bitmap_editor.rb
UTF-8
1,070
2.765625
3
[]
no_license
# frozen_string_literal: true require 'dry/monads' require_relative 'canvas' require_relative 'bitmap_editor/editor.rb' require_relative 'bitmap_editor/printer.rb' require_relative 'bitmap_editor/parser.rb' require 'pry' class BitmapEditor include Dry::Monads[:result, :do, :list] def run(path) result = proc...
true
217f5229191a0ea13bd9d4e9ffd71d11d933c173
Ruby
sasalatart/memeticame-api
/app/models/tag.rb
UTF-8
438
2.5625
3
[]
no_license
# == Schema Information # # Table name: tags # # id :integer not null, primary key # text :string # created_at :datetime not null # updated_at :datetime not null # class Tag < ApplicationRecord before_create :downcase has_many :meme_tags, dependent: :destroy has_many :...
true
0cdf93eac01e3d4040b6d0957463786bea5941bc
Ruby
cjilbert504/programming-univbasics-3-build-a-calculator-lab-online-web-prework
/lib/math.rb
UTF-8
399
3.34375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def addition(num1, num2) add = num1 + num2 return add end def subtraction(num1, num2) subtract = num1 - num2 return subtract end def division(num1, num2) divide = num1 / num2 return divide end def multiplication(num1, num2) mult = num1 * num2 return mult end def modulo(num1, num2) mod = num1 % num2 ...
true
33fb3a5f2fda0246f5ad2a6a63fa90ed6b29cc5b
Ruby
margOnline/fpl-tracker
/setup_teams.rb
UTF-8
665
2.6875
3
[]
no_license
require 'sequel' require 'httparty' require './tracker' class SetupTeams def self.create_table(db_conn) unless db_conn.table_exists?(:teams) db_conn.create_table :teams do primary_key :id String :name String :tla end end populate(db_conn) end def self.populate(db...
true
83e8f1a38280410b9d97bebefc635c2f60e1fe0c
Ruby
bsou/rigse
/app/models/materials_collection.rb
UTF-8
1,907
2.640625
3
[ "MIT" ]
permissive
class MaterialsCollection < ActiveRecord::Base attr_accessible :description, :name, :project_id belongs_to :project, :class_name => "Admin::Project" has_many :materials_collection_items, dependent: :destroy, order: :position # List all supported material types in this array! It's used by #materials method. ...
true
69bea56a6299688d79be5babd480240a3f9a1250
Ruby
Papankr/-6
/3/src.rb
UTF-8
344
3.375
3
[]
no_license
require './main.rb' puts '*' * 30 + 'sin(x)' + '*' * 30 lambda_sin = ->(x) { Math.sin(x) } p differ(0.49, 0.50, 0.51) { |x| Math.sin(x) } p differ(0.49, 0.50, 0.51, lambda_sin) puts '*' * 30 + 'tag(x)' + '*' * 30 lambda_tan = ->(x) { Math.tan(x + 1) } p differ(0.49, 0.50, 0.51) { |x| Math.tan(x + 1) } p differ(0.49, ...
true
4ba397b9899a310df7d0ac91bec572d1842bb464
Ruby
SiCuellar/archerdx_challenge
/ruby/chromosome_annotation/test/chromosome_annotation_test.rb
UTF-8
2,332
2.609375
3
[]
no_license
require "./lib/chromosome_annotation" require "minitest/autorun" require "minitest/pride" class ChromosomeAnnotationTest < Minitest::Test def test_it_exists chromosome_annotation = ChromosomeAnnotation.new("coords_to_ann.txt","test_chromosome_map.gtf") assert_instance_of ChromosomeAnnotation, chromosome_anno...
true
f6c2f4edae8cc36969ff71610680b48b1b352b30
Ruby
derrickgillespiewv/web_site
/money_hash.rb
UTF-8
371
3
3
[]
no_license
def change_machine(amount) change = Hash[:quarters, 0, :dimes, 0, :nickels, 0, :pennies, 0] coin_values = Hash[25, :quarters, 10, :dimes, 5, :nickels, 1, :pennies] coin_values.each do |coin, value| while amount >= coin change[coin_values[coin]] += 1 amount -= coin end end change.collect...
true
27cd2710db8c7a06053e13c166c3f8e4653f32ba
Ruby
amandapouget/go_fish_rails
/spec/factories/cards.rb
UTF-8
806
2.5625
3
[]
no_license
FactoryGirl.define do def rank_char(rank) if Card::RANKS.include?(rank) index = Card::RANKS.index(rank) return index + 2 if index < 9 return rank[0] end return 0 end factory :card do rank { Card::RANKS[rand(Card::RANKS.size)] } suit { Card::SUITS[rand(Card::SUITS.size)] } ...
true
e1acb541983ab3787bfd2b72ebe2d7cd58dc3b17
Ruby
curlygirly/airport_challenge
/spec/feature/grand_finale_spec.rb
UTF-8
1,512
2.84375
3
[]
no_license
require 'capybara/rspec' ## Note these are just some guidelines! ## Feel free to write more tests!! # Given 6 planes, each plane must land. # Be careful of the weather, it could be stormy! # Check when all the planes have landed that they have status "landed" # Once all planes are in the air again, check that they ha...
true
3c9a178ec19182765ac7e5691f2cdcb2b848c147
Ruby
gui1030/VS_Testing
/Cloud/app/services/line_check_service.rb
UTF-8
914
2.671875
3
[ "Apache-2.0" ]
permissive
class LineCheckService < ApplicationService CREATION_WINDOW = 15.minutes class << self def create_line_checks!(time) schedules = LineSchedule.where('time < ?', time + CREATION_WINDOW) schedules.each do |schedule| schedule.transaction do create_line_check!(schedule) if schedule.time...
true
69e650cee8ac382a563d9131a9cc15651992a9e7
Ruby
farhatmihalko/aud
/dictionary_raw/test.rb
UTF-8
626
2.53125
3
[]
no_license
# require 'net/http' # require 'uri' # $stdin = File.open('kzwords.txt','r'); # $stdout = File.open('out.txt','w'); # def read_word() # s = gets # return s # end # def get_ans(s) # definition = s.scan(%r{<p>(.*)</p>}m) # end # while (s = read_word) # s.chomp! # postData = Net::HTTP.post_for...
true
490e957c76a460715e9b5d76db83a44d78805c69
Ruby
mattknox/cassandra
/lib/cassandra/time.rb
UTF-8
148
2.796875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class << Time def now_in_useconds time = Time.now time.to_i * 1_000_000 + time.usec end alias :stamp :now_in_useconds end
true
8c7dd7e12916286e04ff461d90133f110f1ae030
Ruby
renjuzac/tla
/basics/basics.2.rb
UTF-8
158
3.65625
4
[]
no_license
puts "Enter 4 digit number" number=gets.to_i puts "Thousands: #{number/1000} ,Hundreds #{ (number%1000)/100} , Tens #{(number%100)/10} , Ones #{number%10}"
true
26805fb242abf39ee8ceeb521d121156bac35810
Ruby
azorko/Poker
/lib/deck.rb
UTF-8
835
3.8125
4
[]
no_license
require_relative 'card' # Represents a deck of playing cards. class Deck attr_accessor :cards # Returns an array of all 52 playing cards. def self.all_cards suits = Card.suits values = Card.values deck = [] suits.each do |suit| 13.times { |val| deck << Card.new(suit, values[val]) } end ...
true
e3ee239db148fdb0952357c182d12c6bbf349bd1
Ruby
samlamgithub/webappRubyScriptAndDatabase
/server2.rb
UTF-8
8,724
2.515625
3
[]
no_license
require 'pg' require 'socket' require 'json' require 'base64' require 'pp' require 'date' def main localIp = Socket::getaddrinfo(Socket.gethostname,"echo",Socket::AF_INET)[0][3] puts localIp filePath = "/homes/jl6613/public_html/" fileName = "serverIp.txt" File.open(filePath+fileName, 'w') { |file| file.writ...
true
8c7a0639660687f22c008621ff4fe6c5a5f869dd
Ruby
destiny-index/refactoring-ruby
/src/introduce_inheritance.rb
UTF-8
1,071
3.234375
3
[]
no_license
# class MountainBike # TIRE_WIDTH_FACTOR = 6 # # attr_accessor :tire_diameter # # def wheel_circumference # Math::PI * (@wheel_diameter + @tire_diameter) # end # # def off_road_ability # @tire_diameter * TIRE_WIDTH_FACTOR # end # end # # class FrontSuspensionMountainBike # TIRE_WIDTH_FACTOR = 6 # ...
true
45163e309af164c3c892bb665db6cb374c5341f1
Ruby
NMontesino/dumbo-web-082619
/03-intro-oo/clown.rb
UTF-8
1,259
3.984375
4
[]
no_license
require 'pry' clown_joke = "Why don't sharks eat clowns? They taste funny." clown_names = [ "Bluster", "Flaky", "Raspy", "Floppy", "Krusty", "Baby" ] class Clown attr_reader :fear attr_writer :age attr_accessor :name, :skill # Initialize => Linked to Clown.new() def initialize(name, age, skill,...
true
4123e829071ec6c199a45f468794fe666a217a6b
Ruby
graysky/jekyll
/test/test_post.rb
UTF-8
9,989
2.546875
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/helper' class TestPost < Test::Unit::TestCase def setup_post(file) Post.new(@site, source_dir, '', file) end def do_render(post) layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")} post.render(layouts, {"site" => {"posts" => []}}) e...
true
abbc57baa3cb61a1242f58fd0d187b4171356298
Ruby
mvincent7891/lite_rail
/lib/show_exceptions.rb
UTF-8
1,179
2.640625
3
[]
no_license
require 'erb' require 'byebug' class ShowExceptions attr_reader :app def initialize(app) @app = app end def call(env) begin @app.call(env) rescue => e render_exception(e, env) end end private def render_exception(e, env = nil) template_path = "lib/templates/rescue.htm...
true
b8dd1aa9441b82b980011b526d6e0feb2bf35cb5
Ruby
roa-sh/ruby_path
/Mixins/extend_keyword.rb
UTF-8
370
4.03125
4
[]
no_license
# extends insert functionalities in the class itself, but no in the objects created from the class. module Announcer def who_am_i "The name of this class is #{self}" end end class Dog extend Announcer end class Cat extend Announcer end # it works, bc it's a class p Cat.who_am_i # doesn't work, bc it'...
true
3eb34f3b11f4d42423f5ebe72fa02a034d1c2ceb
Ruby
splybon/advent-of-code
/2018/solutions/day-9/solution_part_2.rb
UTF-8
2,403
3.734375
4
[]
no_license
require_relative('../../utils/data_reader.rb') # Works for solution but not other example ones # Using as node of a doubly-linked list class CircleNode attr_accessor :next_node, :prev_node attr_reader :value def initialize(value, next_node=nil, prev_node=nil) @value = value @next_node = next_node || sel...
true
45955c922e8c8eede66243d540e8a8d7994bb858
Ruby
iSarCasm/myRsa
/spec/my_random_spec.rb
UTF-8
1,567
3
3
[]
no_license
require_relative 'spec_helper' describe MyRandom do describe '#randomize, #get_seed_from_time' do 10.times do rnd = MyRandom.randomize it("Randomize returned #{rnd}") {} end end describe '#random' do 10.times do rnd = MyRandom.random it("Random returned #{rnd}") {} end ...
true
d8cbb27c0fd1aa004066a5bad2d35718d012480c
Ruby
kbhoffmann/market_ic_2108
/spec/vendor_spec.rb
UTF-8
1,228
3.265625
3
[]
no_license
require './lib/item' require './lib/vendor' require 'pry' RSpec.describe do it "exists" do vendor = Vendor.new("Rocky Mountain Fresh") expect(vendor).to be_an_instance_of(Vendor) end it "has attributes" do vendor = Vendor.new("Rocky Mountain Fresh") expect(vendor.name).to eq("Rocky Mountain Fr...
true
334f36b25852c71efb1beb9063071ce7c1cdcb77
Ruby
rathrio/punch
/test/month_test.rb
UTF-8
2,025
3.09375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative "config" class MonthTest < PunchTest def setup @month = Month.from(<<-BRF, 1, 2014) Januar 2014 28.11.14 18:00-19:00 Total: 01:00 30.12.14 08:00-13:00 Total: 05:00 Total: 21:00 BRF end def test_sorting day = Day.from "...
true
49b5bb7c2a8ad61cb89b7c8295d25f6102c71ec0
Ruby
QPC-WORLDWIDE/rubinius
/benchmark/rubinius/bm_array_each.rb
UTF-8
253
2.8125
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'benchmark' total = (ENV['TOTAL'] || 1_000).to_i ary = Array.new(5_000) { |i| i } Benchmark.bmbm do |x| x.report("loop") do total.times { |i| i } end x.report("Array#each") do total.times { |i| ary.each { |a| a } } end end
true