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
3b6f7c57238982a45fed3a5f997e36e0d63d7ef3
Ruby
mmrobins/project-euler-solutions
/049_prime_permutations.rb
UTF-8
918
2.953125
3
[]
no_license
require 'pp' require 'primality_testing' require 'set' class Array def to_i self.join.to_i end end module Enumerable def dups inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys end end permuted_primes_with_at_least_three_prime_permutations = [] 9999.primes_less_than.select {|n| n > 999}.e...
true
a2583e179c3a1a5aaef08c79445f499915b87c07
Ruby
ginnyfahs/whiteboarding-practice
/ruby/strings/substring_checker.rb
UTF-8
433
3.515625
4
[]
no_license
def substring_checker(a1, a2) substrings = [] i = 0 while i < a2.length j = 0 while j < a1.length if a2[i].include? a1[j] if !substrings.include? a1[j] substrings << a1[j] end end j +=1 end i +=1 end return substrings end a1 = ["arp...
true
14a389e44118ba8b09747cb7b063818d1dd8b158
Ruby
wjdix/resque-pool
/lib/resque/pool/logging.rb
UTF-8
377
2.6875
3
[ "MIT" ]
permissive
module Resque class Pool module Logging # Given a string, sets the procline ($0) # Procline is always in the format of: # resque-pool-master: STRING def procline(string) $0 = "resque-pool-master: #{string}" end # TODO: make this use an actual logger def log(me...
true
4baf3ed9505bd6e3cdda9d4b991e8a3a51dcd2f3
Ruby
venelrene/Codewars
/tdd_kata/spec/string_calculator_spec.rb
UTF-8
1,680
3.890625
4
[]
no_license
require "string_calculator" describe StringCalculator do #We are using another describe block to describe the add class method. By convention, class methods are prefixed with a dot (".add"), and instance methods with a dash ("#add"). describe ".add" do #We are using a context block to describe the context unde...
true
c1690eacdf853033ea02ce2a499caf5e41bde60b
Ruby
coffeencoke/fun
/lib/problems/ccipher.rb
UTF-8
469
3.34375
3
[ "MIT" ]
permissive
module CCipher def self.decode(message, shifts) message.each_char.with_index do |char, index| original_index = char.ord-alphabet_offset unshifted_index = original_index-1 - shifts new_index = unshifted_index % alphabet.size message[index] = alphabet[new_index] end message end ...
true
216d02a9e85e5c0cece72eeedd67a6ba3ad9c859
Ruby
mikemorton72/practice_ruby
/prework/song.rb
UTF-8
1,339
3.5625
4
[]
no_license
class Song def initialize(title, artist, lyrics) @song_title = title @song_artist = artist @song_lyrics = lyrics end def title=(str) @song_title = str end def artist=(str) @song_artist = str end def lyrics=(str) @song_lyrics = str e...
true
737914e01aa65f50d2c1d1aafe53162599c1cc11
Ruby
Yoomee/ym-core
/lib/ym_core/model/date_accessor.rb
UTF-8
928
2.5625
3
[ "MIT" ]
permissive
module YmCore::Model::DateAccessor def self.included(base) base.extend(ClassMethods) end module ClassMethods def date_accessors(*args) options = args.extract_options! format = options[:format] || "%d/%m/%Y" args.each do |date_attr| self.validates("#{date_attr}_s", :date =>...
true
a8a4e16c41cbaf9991b12b8bad5b1b55aec94c82
Ruby
pbalzac/adventofcode-2020
/20/20.rb
UTF-8
4,170
3.125
3
[]
no_license
def rotate(grid) (grid.length - 1..0).step(-1).map { |i| grid.map { |row| row[i] }.join } end def flip(grid) grid.map { |row| row.reverse } end def match(side, g1, g2) if side == :bottom return g1[-1] == g2[0] else return g1.map { |row| row[-1] } == g2.map { |row| row[0] } end end def match_l...
true
24935a535b6744bbe2ca7b5dc929b5b0277dab7e
Ruby
skilldrick/consideredharmful
/app/models/harmful.rb
UTF-8
1,030
2.890625
3
[]
no_license
require 'open-uri' require 'json' class Harmful attr_accessor :title, :title_no_formatting, :url def self.load_json key = "ABQIAAAAWLOrTtZZMVqckifzzqf5ExTJ4z6FYubmaJQBWq" key << "BMMbq6Cm7PQhTpBR48VC90aX3PtU5LEktkiQhpnw" rsz = 8 start = 0 search_method = 'blogs' search_method = 'web' q...
true
b0503dc654c0bbddd62311a317f33fc9cb303960
Ruby
ericschoettle/ruby-week2-day2
/ruby_week2_day2/tamagotchi/spec/tamagotchi_spec.rb
UTF-8
3,022
3.03125
3
[]
no_license
require('rspec') require('Tamagotchi') describe(Tamagotchi) do before() do Tamagotchi.clear() end describe("#initialize") do it("sets the name and life levels of a new Tamagotchi") do my_pet = Tamagotchi.new("lil dragon") expect(my_pet.name()).to(eq("lil dragon")) expect(my_pet.food_lev...
true
a88e81822ab16b30bfe81998d29e1dbd55ac63c2
Ruby
dsstewa/todo-ruby-basics-online-web-prework
/lib/ruby_basics.rb
UTF-8
272
3.3125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def division(num1, num2) n = num1 / num2 n end def assign_variable(value) n = value end def argue(hello) hello end def greeting(hello,bye) end def return_a_value n = "Nice" n end def last_evaluated_value n = "expert" n end def pizza_party(n = "cheese") n end
true
7994a0b24c987bf7525962e5fc972d423dc38c39
Ruby
nathanworden/RB101-Programming-Foundations
/RB101-RB109_small_problems/13.debugging/11.whats_wrong_with_the_output.rb
UTF-8
1,258
4.59375
5
[]
no_license
# What's wrong with the output? # Josh wants to print an array of numeric strings in reverse numerical order. # However, the output is wrong. Without removing any code, help Josh get the # expected output. # arr = ["9", "8", "7", "10", "11"] arr = ["9", "8", "7", "10", "11"] p arr.sort do |x, y| y.to_i <=> x.to...
true
23694dea8e1e0c60d9066f9c52e7f7e9e73e0c35
Ruby
johnram528/ufc-rankings-cli-gem
/lib/ufc_rankings/rankings.rb
UTF-8
877
2.84375
3
[ "MIT" ]
permissive
class UfcRankings::Rankings @@division_names = ["Pound for Pound", "Flyweight", "Bantamweight", "Featherweight", "Lightweight", "Welterweight", "Middleweight", "Light Heavyweight", "Heavyweight", "Women's Strawweight", "Women's Bantamweight"] @@divisions = {} @@division_names.each_index {|i| @@divisions[i] = Arr...
true
cbc0d2f1eed3525f683b9b2f21272caf20f72e73
Ruby
quantumduck/stretch_tdd_ruby
/stretch_05_array_extensions/array_extensions.rb
UTF-8
151
3.3125
3
[]
no_license
class Array def sum total = 0 each { |element| total += element } total end def square map { |element| element**2 } end end
true
4ef0eb60f308b67675bce422d5947d7b0b9f4bd6
Ruby
axionos/silicon-valley-code-challenge-nyc-web-career-040119
/app/models/venture_capitalist.rb
UTF-8
1,061
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class VentureCapitalist attr_reader :name, :total_worth @@all = [] def initialize(name, total_worth) @name = name @total_worth = total_worth @@all << self end # INSTANCE METHODS def offer_contract(startup, type, investment) FundingRound.new(startup, self, type, investment) end def al...
true
1675468415870986baae2413a7ec63c0d1e100fa
Ruby
cielavenir/procon
/atcoder/tyama_atcodernikkei2019exG.rb
UTF-8
134
3.015625
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby h=Hash.new 0 gets.chomp.chars{|c|h[c]+=1} x=y=0 h.each_value{|v|d,r=v.divmod 2;x+=d*2;y+=r} y>0&&(y-=1;x+=1) p x**2+y
true
3bd0a07262ae990509e3001a8fe8a393393e8c1a
Ruby
guns/haus
/lib/ruby/nerv/util/notification.rb
UTF-8
3,212
2.515625
3
[ "MIT" ]
permissive
# -*- encoding: utf-8 -*- # # Copyright (c) 2011-2017 Sung Pae <self@sungpae.com> # Distributed under the MIT license. # http://www.opensource.org/licenses/mit-license.php require 'cgi' module NERV; end module NERV::Util; end class NERV::Util::Notification PRESETS = { 'alert' => { :title => nil, ...
true
9a48eff1ab9aac9aef10bbc3b019603a88998371
Ruby
diegodurs/checklist
/lib/checklist/list.rb
UTF-8
2,121
3.015625
3
[]
no_license
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHET...
true
088884cd59cc107a8649832addfdcd5f4704347f
Ruby
MASisserson/rb101
/small_problems/easy_6/7.rb
UTF-8
1,527
4.21875
4
[]
no_license
# Halvsies =begin PEDAC Input: array Output: 1 nested array Requirements: Splits down the middle favor the first half Elements and arrays in same order as original array. Nondestructive Returns 2 arrays even if one or both would be empty Mental Model: Make one array that is the second cu...
true
5147d5cffbdd0c3d5093ea839c20ed9f0dacbdca
Ruby
eosin-kramos/Ruby-Exercises-
/picky_eater.rb
UTF-8
532
3.4375
3
[ "MIT" ]
permissive
foods = ["Candy", "Soda", "Lettuce", "McDonalds", "KFC", "Mango", "Carrot"] vegetables = ["Lettuce", "Broccoli", "Carrot", "Onion"] fruits = ["Apple", "Orange", "Mango", "Pineapple"] foods.each do |food| if vegetables.include?(food) 4.times do puts "Gross, I hate #{food}" end elsif fruits.include?(fo...
true
f11dc7a4561b3c2d34124056d3564be8825e0539
Ruby
21sapphire/IntroBook
/1Basics/Ex1.rb
UTF-8
675
3.90625
4
[]
no_license
# 1 puts "Matthew " + "Buckman" # 2 puts 5678 / 1000 puts 5678 % 1000 / 100 puts 5678 % 1000 % 100 / 10 puts 5678 % 1000 % 100 % 10 # 3 movies = {:jurassic_park => 1993, :et => 1982, :minority_report => 2002, :bridge_of_spies => 2015} puts movies[:jurassic_park] puts movies[:et] puts movies[:minority_report] puts mov...
true
e260f6ccc7a8380af49639c259e149eeae8e01db
Ruby
tsukajizo/bingo
/testBingo.rb
UTF-8
415
3.234375
3
[]
no_license
require_relative "bingo" bingo = Bingo.new while bingo.remain? bingo.select_number print bingo.current_number print "\n" end print Bingo::MESSAGE_GAME_IS_OVER bingo = Bingo.new 35.times{|n| bingo.select_number} print bingo.used_numbers[4] print ":" print bingo.unused? bingo.used_numbers[4] print "\n" print b...
true
a76888f0b2ce041277f578061ed024935af6bfdf
Ruby
idoo/simple_shop
/spec/shop_spec.rb
UTF-8
659
2.53125
3
[]
no_license
require 'spec_helper' # require_relative 'shop/pricing_rules' # require_relative 'shop/checkout' describe 'Shop' do let(:co) { Shop::Checkout.new(Shop::PRICING_RULES) } let(:items1) { ['FR1', 'AP1', 'FR1', 'CF1'] } let(:items2) { ['FR1', 'FR1'] } let(:items3) { ['AP1', 'AP1', 'FR1', 'AP1'] } it 'should calc...
true
ed4e25f4a0e968b8aa33ee8ee880885bba279237
Ruby
matipan/odin_ruby
/project_recursion/merge.rb
UTF-8
491
3.5
4
[]
no_license
require 'benchmark/ips' def merge_sort(array) return array if array.length <= 1 half = array.length / 2 merge_arrays(merge_sort(array[0..half-1]),merge_sort(array[half..-1])) end def merge_arrays(left, right) sorted = [] until left.empty? or right.empty? left.first <= right.first ? sorted << left.shift : so...
true
3dfa7c53fabf5fb3930c5f189e8b0bc0fba32356
Ruby
shvets/misc-ruby
/image-resizer/image-resizer.rb
UTF-8
1,167
3.421875
3
[]
no_license
# idea from here: http://railstech.com/2011/02/resize-image-using-gd2/ require 'rubygems' require "image_size" require "open-uri" require 'gd2-ffij' class ImageResizer include GD2 def resize input_name, output_name, resized_width = 100, resized_height = 100 image = Image.import(input_name) resize_...
true
3380838819d1e1a95e694cc88c903ac75826c91d
Ruby
jsonjordan/Blackjack_2
/player.rb
UTF-8
399
3.28125
3
[]
no_license
require './hand' class Player attr_reader :wallet, :hand def initialize wallet = 0 @wallet = wallet hand_new end def add_to_hand card @hand.add(card) end def wins ammount @wallet += ammount end def broke? wallet == 0 end def hand_new @hand = Hand.new end def hit? ...
true
2c98428f1a11bf98f92d6a99fcbf46211ced9915
Ruby
yuji91/RefactoringRuby_01_sample
/main.rb
UTF-8
336
2.703125
3
[]
no_license
require './movie.rb' require './rental.rb' require './customer.rb' require './regular_price' require './new_release_price' require './children_price' movie = Movie.new("movie_01", Movie::REGULAR) rental = Rental.new(movie, 0) customer = Customer.new("customer_01") customer.add_rental(rental) result = customer.statem...
true
12c788db4aa51294cd453bd868d1808a9889ef2c
Ruby
mikefieldmay/tech_test_bank
/spec/statement_printer_spec.rb
UTF-8
1,371
2.78125
3
[]
no_license
require 'statement_printer' describe StatementPrinter do let(:transaction){ Struct.new("Transaction", :date, :credit, :debit, :balance )} let(:transaction_one) { transaction.new( '14/01/2012', '', '500.00', '2...
true
568d1f3e2f5d18fc1654d5fdc566caf66d707bee
Ruby
meinside/meinside-ruby
/lib/externals.rb
UTF-8
2,995
2.59375
3
[ "BSD-3-Clause" ]
permissive
# coding: UTF-8 # lib/externals.rb # # functions using external services # (in unofficial ways) # # created on : 2013.02.27 # last update: 2013.08.23 # # by meinside@gmail.com require 'json' require_relative 'my_http' require_relative 'my_str' module Externals FAKE_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel ...
true
9dad5500edbcc5c82ea4de98d9e55f9e9f8af64f
Ruby
heptagon-inc/adwords
/cities.rb
UTF-8
572
2.578125
3
[]
no_license
#!/usr/bin/env ruby # coding: utf-8 @cities = %w( 青森市 弘前市 八戸市 黒石市 五所川原市 十和田市 三沢市 むつ市 つがる市 平川市 平内町 今別町 蓬田村 外ヶ浜町 鰺ヶ沢町 深浦町 西目屋村 藤崎町 大鰐町 田舎館村 板柳町 鶴田町 中泊町 野辺地町 七戸町 六戸町 横浜町 東北町 六ヶ所村 おいらせ町 大間町 東通村 風間浦村 佐井村 三戸町 五戸町 田子町 南部町 階上町 新郷村 )
true
adcbba81887f1042c7899f47ae9b6fd33280958f
Ruby
BaptisteCoulon/Project-ruby
/Game.rb
UTF-8
1,568
2.796875
3
[]
no_license
require 'gosu' require_relative "./Joueur.rb" require_relative "./Map.rb" require_relative "./Tiles.rb" require_relative "./Rectangle.rb" require_relative "./Ennemi.rb" require_relative "./Cheese.rb" require_relative "./State.rb" require_relative "./GameState.rb" require_relative "./MenuState.rb" require_rel...
true
1b5000ac0c3317f9b656b4ac6a5ce68b55135491
Ruby
v-yarotsky/taketo
/lib/taketo/config_traverser.rb
UTF-8
473
2.6875
3
[ "MIT" ]
permissive
require 'delegate' require 'forwardable' module Taketo class ConfigTraverser def initialize(root) @root = root end def visit_depth_first(visitor) path_stack = [@root] while path_stack.any? node = path_stack.pop visitor.visit(node) node.class.node_types.each d...
true
a6ecee1db6c4ef11e1a66fdba84f884ec8e94cfe
Ruby
lcloyola/upis-ror
/app/models/gwa.rb
UTF-8
1,945
2.75
3
[]
no_license
class Gwa < ActiveRecord::Base belongs_to :student belongs_to :schoolyear def self.search(schoolyear, batch, mode) gwas = Gwa.joins(:student) gwas = gwas.where('students.batch_id' => batch.id, 'schoolyear_id' => schoolyear.id, 'gwa_type' => mode) gwas = gwas.each{|s| s[:deficiency] = s.student.has_def...
true
4a6cf95037c79ce15ffb928c3a2e92b9d1d2f8f6
Ruby
limeiralucas/LocadoraRuby
/Item.rb
UTF-8
383
3.390625
3
[]
no_license
class Item attr_reader :name, :id, :year, :genre, :avaliable def initialize(id, name, year, genre) @id = id @name = name @year = year @genre = genre @avaliable = true end def to_s() "Item ##{id}\n Name: #{name}\n Year: #{year}\n Avaliable: #{avaliable ? "Yes" : "No" }\n" end def lease() @aval...
true
53b08fdb867e61b223877feabbd54fdbb3e20cfd
Ruby
AlexandreDutra-Dev/Curso-Ruby-Rails
/ruby_language/numbers.rb
UTF-8
1,243
4.03125
4
[]
no_license
=begin Open Shell In Repl.it shift + cmd + p type shell, hit enter Methods object.odd? object.even? =end puts "\nNumbers\n" puts 1 + 2 puts 5 + 6 puts 10 * 2 puts 10 / 2 puts 10 / 4 # Integer of division drops decimal puts 10.0 / 4 # converts puts 10 / 4.to_f # method converts puts (10 / 4).to_f # Evaluat...
true
632ea04fc3cda5361ce8395998500322577703bc
Ruby
FiddlersCode/kata
/CamelCaseMethod/lib/CamelCaseMethod.rb
UTF-8
111
3.21875
3
[]
no_license
def CamelCaseMethod(string) string.split.map(&:capitalize).join end puts CamelCaseMethod("bob the builder")
true
fbef7af13fc829fb52c131f29f10216daf2c9c55
Ruby
bitterfly/bikesurfing
/src/bikesurf/lib/bikesurf/helpers/date_helper.rb
UTF-8
754
2.71875
3
[]
no_license
require 'date' module Bikesurf module Helpers module DateHelper def timestamp_to_date(timestamp) return nil unless timestamp Time.at(timestamp).utc.to_datetime.to_date end def date_to_timestamp(date) return nil unless date Time.utc(date.year, date.month, date.da...
true
af94c2718186e67918d285d9e4b7fffafa07d2f6
Ruby
petrachi/hydrogen
/lib/hydrogen/seeder.rb
UTF-8
371
2.59375
3
[ "MIT" ]
permissive
class Hydrogen::Seeder attr_accessor :update, :reset def initialize update: false, reset: false @update = update @reset = reset end def seed stocks.map &:seed end def stocks Dir[File.join(Rails.root, "db", "hydrogen", "*")] .select{ |file| File.directory? file } .map{ |file| ...
true
3035ade4864a58d9d9a92d1c0ef709af741b6ebf
Ruby
innku/dashboard
/lib/sharewall_client.rb
UTF-8
469
2.71875
3
[]
no_license
require 'rest_client' require 'json' class SharewallClient attr_accessor :url def initialize url @url = url end def execute raw_response = RestClient.get(url) @response = JSON.parse(raw_response.body).reverse[0..7] end def data if @response @response.map do |link| { ...
true
58e5e0c26b93e37b95409f9279a05296b30d38a4
Ruby
mb-mysterdev/ruby_exo
/exo_13.rb
UTF-8
143
2.859375
3
[]
no_license
puts "Votre année de naissance svp ??" année_de_naissance = gets.to_i i = année_de_naissance begin puts(i) i +=1; end until i > 2018
true
b97c46088a6cdd00e6372272f580b468a3fdd318
Ruby
binoymichael/exercism-solutions
/ruby/hamming/hamming.rb
UTF-8
345
3.171875
3
[]
no_license
module BookKeeping VERSION = 3 end class Hamming def self.compute(first_strand, second_strand) throw ArgumentError unless first_strand.length == second_strand.length return 0 if first_strand == second_strand return (0...first_strand.length).count do |index| first_strand[index] != second_strand[...
true
09b06760f139b340f7783b1176fcf30852190418
Ruby
ddugue/garden-rake
/test/args.rb
UTF-8
2,853
2.53125
3
[ "MIT" ]
permissive
require 'rake/garden/command_args' require 'rake/garden/commands/sh' require 'rake/garden/context' require 'rake/garden/filepath' require_relative 'fake_manager' RSpec.describe Garden::CommandArgs, "#initialize" do it "should create an arg based on a string" do expect("a" >> "b").to eq(["a", "b"]) end it "sh...
true
794df2b4643b60e8ae4ba1a3c1330ee33123e94e
Ruby
sreeharikmarar/geektrust-cricket
/cricket_2/lib/cricket/team.rb
UTF-8
1,915
3.15625
3
[]
no_license
require 'yaml' module Cricket class Team attr_reader :name, :players, :score_board attr_accessor :striker, :non_striker def initialize(name) @name = name initialize_team end def striker_play(ball) run = @striker.play(ball) update_score(ball, run) end def game_en...
true
be92421f263961c7a91abf0f5a20c31ea6948153
Ruby
drLoom/csv_to_ascii
/test/test_parser.rb
UTF-8
382
2.609375
3
[]
no_license
require "minitest/autorun" require 'lib/parser' class TestParser < Minitest::Test def test_it_should_leave_value_same text = <<~TEXT int;string;money; 1;aaa bbb ccc;1000.33 TEXT assert_equal [[ { type: "int", value: "1" }, { type: "string", value: "aaa bbb ccc" }, { type: "money", value: "10...
true
288abce41ddca0f3cdff2c2200ea412389befb56
Ruby
jcovell/lesson2
/rubocop.rb
UTF-8
1,436
3.53125
4
[]
no_license
=begin Rubocop is a static code analyzer. This means that it analyzes your code and offers advice regarding its style format as well as possible logical errors. In Rubocop parlance, these rules are called cops. Cops are further grouped into departments. The first department we care about is centered around enforcing ...
true
9ba01d396a8355b6ca90fd2a175540c9a8220543
Ruby
Danarvelini/Bootcamp_Impulso--Fullstack_developer
/LearningRuby/symbols.rb
UTF-8
346
2.9375
3
[]
no_license
#Its a special type of object. They are create with ":" in the beginning of the identifier #They are immutable #Great to substitute Strings for labels and keys and hash name = 'Dan' p name.object_id #Its different every time it is set :"Dan" p :Dan.object_id #its always the same id on memory, and that makes it very ...
true
dfd54b7ba636f4c980bbc8a99f58d3aefc87a30a
Ruby
HarrisJT/css-class-string
/spec/css_class_string/helper_spec.rb
UTF-8
1,855
2.796875
3
[ "MIT" ]
permissive
require 'spec_helper' require 'css_class_string/view_helpers' describe "CssClassString::Helper" do describe ".to_s" do context "when a key's value is truthy" do let(:hash) { {truthy: true} } subject { CssClassString::Helper.new(hash).to_s } it { is_expected.to eq("truthy") } end ...
true
874878046272eef5615f0f214d897b5f1c8758bd
Ruby
komiyak/reading-metaprogramming-ruby
/chapter_5/singleton_class.rb
UTF-8
135
3.15625
3
[]
no_license
obj = Object.new singleton_class = class << obj self end pp singleton_class pp singleton_class.class # Or pp obj.singleton_class
true
43501681475df960e41fbeb011d9b6253b043570
Ruby
itsmekhanh/leetcode
/add_two_numbers.rb
UTF-8
749
4.0625
4
[]
no_license
# you are given two linked lists representing two non-negative numbers. # The digits are stored in reverse order and each of their nodes contain a # single digit. Add the two numbers and return it as a linked list. require_relative "classes/list_node.rb" def add_two_numbers(l1, l2) head = nil tail = nil carry ...
true
7abc1ac4b148fca237df737fb396bde8d2aa04e7
Ruby
firechicago/advent-of-code
/Day-7-Problem-1/parse.rb
UTF-8
1,254
3.3125
3
[]
no_license
raw_data = File.readlines(ARGV[0]) def action(string) string.match(/[A-Z]+/).to_s end def receiver(string) string.chomp.match(/[a-z]+\z/).to_s end def arguments(string) string.scan(/(\d+|[a-z]+)(?= )/).flatten end class Wire @@diagram = {} attr_reader :name, :action, :arguments def initialize(name, act...
true
9b545ee76e13cf3250f041ab8c1a5c0056c6da71
Ruby
JonathanAndrews/worlds_simplest_poker
/spec/feature/configure_game_spec.rb
UTF-8
1,230
2.65625
3
[]
no_license
# frozen_string_literal: true feature 'Configure Game screen' do scenario 'displayed when entering website' do visit '/' expect(page).to have_content("Welcome the World's Simplest Poker Game") end scenario 'should have a number of players input' do visit '/' expect(page).to have_content('How man...
true
9ef90d0a66b8b322b0adbf3a83ae39d8c63265f0
Ruby
MarkHyland/to-do-list
/lib/list.rb
UTF-8
175
2.578125
3
[]
no_license
# Have to create the class for it to show up in the # database. class List < ActiveRecord::Base has_many :items def to_s "id: #{self.id}, name: #{self.name} \n" end end
true
05b4d7e10c3ea7f8a56636a55ba23ec18923a740
Ruby
coreymartella/project_euler
/p007.rb
UTF-8
476
3.90625
4
[]
no_license
def prime(n) factors= [] return false if n % 2 == 0 3.step((n**0.5).ceil,2) do |i| return false if n % i == 0 end true end def p7(n) primes = [nil,2,3,5,7,11,13] while !primes[n] #need to fill in primes (primes.last+2..primes.last*2).step(2) do |i| primes << i if prime(i) end end ...
true
a2df554d8ab72b984572797b4fe4491e628f9d73
Ruby
vladigonzalez/Clase13
/ejercicio2.rb
UTF-8
791
3.828125
4
[]
no_license
#ejercicio2.rb puts"desarrollo 1 mostrar los productos" productos = {'bebida' => 850, 'chocolate' => 1200,'galletas' => 900, 'leche' => 750} productos.each { |producto, valor| puts "Producto: #{producto} $: #{valor}" } puts"-----------------------------------------" puts"desarrollo 2: agregar cereal 2200" puts"----...
true
f17bad2c32d7c1bb8780395fb62ecfdf4d59fff6
Ruby
SleeplessByte/RubiesInSpace
/core/generator/space.basic.rb
UTF-8
13,816
3.03125
3
[]
no_license
require_relative '../env/space.universe' module Generators module Universe ## # This is space. This is where the rubies are! # class Basic ## # # VERSION = '1.0.0' ## # Returns the size for the universe # def self.size( universe ) results = {} results[ :n ...
true
876a09cd7b69f47c484ef433d9f88f1a281a8237
Ruby
brendanr425/Intro-to-Ruby
/Intro-to-Ruby/exercises/exercise_13.rb
UTF-8
547
3.28125
3
[]
no_license
def assignment(arr) info = Hash.new info[:email] = arr[0] info[:address] = arr[1] info[:number] = arr[2] return info end contact_data = [["joe@email.com", "123 Main st.", "555-123-4567"], ["sally@email.com", "404 Not Found Dr.", "123-234-3454"]] contacts = {"Joe Smith" => {}, "Sally Johnson" ...
true
b16dec29b4d7ce358f2d9e3f7303513485aa4be8
Ruby
khashiyousefi/FoodNatic
/test/models/comment_test.rb
UTF-8
1,864
2.59375
3
[]
no_license
require 'test_helper' class CommentTest < ActiveSupport::TestCase test "comment should not save if empty comment" do c1 = Comment.new assert_not c1.save end test "Comment save in Recipe and User success" do c1 = Comment.new c1.comment_text = "test" # make a new user instance for c to save ...
true
bc4d2b131d5aa853824b3c354a90967aa152173b
Ruby
douglasdrumond/codility-lessons
/lesson2/FrogRiverOne.rb
UTF-8
382
3.28125
3
[]
no_license
# you can use puts for debugging purposes, e.g. # puts "this is a debug message" def solution(x, a) # write your code in Ruby 2.2 count = [0]*(x+1) sum = 0 a.each_with_index do |v, i| if count[v] == 0 count[v] = 1 sum += 1 if sum == x re...
true
040d04dfd1b2d72cd6cec12b3f4c550607882fd7
Ruby
gretchenista/skillcrush-ruby-challenge
/blog.rb
UTF-8
1,350
3.640625
4
[]
no_license
class Blog attr_accessor :title, :all_blog_posts, :total_blog_posts def initialize @created_at = Time.now puts "Name your blog" @title = gets.chomp @all_blog_posts = [] @total_blog_posts = 0 end def create_blogpost new_blog_post = Blogpost.new puts...
true
95247614a5adfa4b752efed5b3423ffac3fb98fd
Ruby
is8r/top10games
/public/ruby/step2.rb
UTF-8
3,327
2.75
3
[]
no_license
require 'json' # -------------------------------------------------- # setting is_debug = false if is_debug file_input = 'dist/results_mini.json' file_output = 'dist/rank_mini.json' else file_input = 'dist/results.json' file_output = 'dist/rank.json' end # -------------------------------------------------- #...
true
edeacd6cf4cc313e02f6ca653bcaefb601837a6d
Ruby
ZASMan/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
2,967
3.90625
4
[]
no_license
#write your code here #Update: Must be able to take in more than one word def translate(word) #In case there are multiple words, split into array seperated by spaces word_arr = word.split(" ") #Values for Vowels and Consonants vowels = ["a", "e", "i", "o", "u", "y"] consonants = ["b", "c", "d", "f", "g", "h", "j...
true
22f92c3ff7ce840425e80255788c02bc380640e9
Ruby
davidbrahiam/credit_card
/credit_card_test.rb
UTF-8
3,636
2.984375
3
[]
no_license
require "test/unit" require_relative './credit_card' class CreditCardTest < Test::Unit::TestCase include ModuleCreditCardHelper # Check types of credit cards def test_types cards_list = [ {type: "VISA", status: :success, number: '4111111111111111'}, {type: "VISA", status: :...
true
540d5d64f6b9c9db92d2544ce8de0d1c1fffbcb2
Ruby
yumojin/Example-Sketches
/samples/processing_app/library/video/movie/loop.rb
UTF-8
428
2.609375
3
[ "MIT" ]
permissive
# Loop. # # Shows how to load and play a QuickTime movie file. # # load_libraries :video, :video_event include_package 'processing.video' attr_reader :movie def setup size(640, 360) background(0) # Load and play the video in a loop @movie = Movie.new(self, 'transit.mov') movie.loop end def draw image(mo...
true
76bad2cf7235626bd6a62b0db953880f4a659f82
Ruby
pivotib/radiant-content-pieces-extension
/spec/models/content_piece_spec.rb
UTF-8
1,640
2.765625
3
[]
no_license
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe ContentPiece do before do @content_piece = ContentPiece.instance @content_piece.clear end it "should be a singleton" do lambda { ContentPiece.instance }.should_not raise_error end describe "<< method" do it "s...
true
6e0aab08c4d7611d2127d0c38a507e51c4091741
Ruby
andygnewman/unbeatable-noughts-and-crosses
/app/tictactoe.rb
UTF-8
932
2.71875
3
[]
no_license
require 'sinatra' require_relative './lib/game' class TicTacToe < Sinatra::Base set :root, File.dirname(__FILE__) get '/' do erb :index end get '/ready/?:starts' do GAME = Game.new redirect to('/play') if params[:starts] == 'computer' redirect to('/human') end get '/play' do GAME.c...
true
e0e47f093d427fcc7c743d6071cf33fe561bbf2c
Ruby
su-kun1899/rubybook
/chapter11/regex.rb
UTF-8
202
3.03125
3
[]
no_license
p "カフェラテ".match?(/ラテ/) p "ティーラテ".match?(/ラテ/) p "モカ".match?(/ラテ/) %w(カフェラテ モカ コーヒー).each do |drink| puts drink if drink.match?(/ラテ/) end
true
0b4e1fa5b3d41a5561a1c40a8fa920980afb21d1
Ruby
kevin4052/codewars
/ruby/6kyu/multiples-of-3-or-5.rb
UTF-8
402
3.578125
4
[]
no_license
# https://www.codewars.com/kata/514b92a657cdc65150000006/ruby # --------------my solution-------------- def solution(number) sum = 0; for i in 0..(number-1) if i % 5 == 0 || i % 3 == 0 then sum += i; end end return sum; end # --------------best practice-------------- ...
true
fd5d7ebe94917c288f1c5852e6790116bcd8a989
Ruby
codingsnippets/quest-till-done
/app/models/record.rb
UTF-8
945
2.53125
3
[]
no_license
# Record base model for Link, Note and Image class Record < ActiveRecord::Base searchkick extend FriendlyId friendly_id :description, use: [:slugged, :history] attr_accessor :encounter, :quest, :questname # Record belongs to a quest belongs_to :quest # Record belongs to a encounter belongs_to :encoun...
true
b7cea27d5055b63d487a9d17b20f6d6b81dd57cd
Ruby
rondale-sc/method_source-expressions
/lib/method_source-expressions/expression_collection.rb
UTF-8
786
2.8125
3
[ "MIT" ]
permissive
module MethodSource::Expressions class ExpressionCollection attr_reader :expressions def initialize(expressions) @top_node, *@expressions = expressions end def direct_descendents(collection=expressions) child_expressions.map{ |child| expression_or_collection(child) } end def sou...
true
d55ea22b13af81918dc35f40fbb7318b7992dece
Ruby
Kweiss/Ruby-Code
/test_statistics/lib/calculate_mean.rb
UTF-8
632
4.03125
4
[]
no_license
# Calculate the mean of a series of numbers class CalculateMean def initialize(ary, population="population") @series_of_nums = ary @pop = "population" end def mean sum = 0 # Add together the sum of all numbers in the set @series_of_nums.each { |x| sum += x } # If @series_of_nums is the full population:...
true
622421ba3e7aa9568e9bafd87ed01217dc1df832
Ruby
jeff-chen/Bowling-cucumber-demo
/app/models/game.rb
UTF-8
459
3.15625
3
[]
no_license
class Game < ActiveRecord::Base has_many :sessions def next_turn sessions.map{|i| i.next_turn}.min end def last_session sessions.sort{|a, b| a.next_turn <=> b.next_turn}.first end def has_winner? winner = true sessions.each do |session| winner &= (session.next_turn == 11) ...
true
0ded5704e6b1db4af83003a7c9820d81c0121f02
Ruby
learn-co-students/West-se-111620
/06-ruby-small-group-review/ix/lib/Manager.rb
UTF-8
736
3.3125
3
[]
no_license
class Manager attr_accessor :name, :department, :age @@all = [] def initialize(name, department, age) @name = name @department = department @age = age @@all << self end def self.all @@all end def self.all_departments @@all.map{|manager| ma...
true
0b53141bc316cd1474cee7797663b0dc2feb7342
Ruby
staceyko/playlister-rb-web-0715-public
/lib/artist.rb
UTF-8
2,292
3.609375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist @@all_artists = [] attr_accessor :name, :songs, :genres def initialize @songs = [] @genres = [] @@all_artists << self end def self.reset_artists @@all_artists.clear end def self.all @@all_artists end def self.count @@all_artists.count end require 'pry' def add_song(song) @so...
true
e262959f494e132320f43067bc875e7d4d0a2050
Ruby
SashaTlr/restaurant_grades
/model.rb
UTF-8
683
3.109375
3
[]
no_license
class RestaurantModel attr_reader :restaurant_name, :cuisine, :address, :zip, :phone def initialize(args = {}) @restaurant_name = args["dba"] @cuisine = args["cuisine_description"] @building = args["building"].nil? ? "" : args["building"].strip @street = args["street"].nil? ? "" : args["street"].str...
true
d6a240e3720d7983b4000b3eab01360d6c43b87f
Ruby
chanwoohill/math_game.rb
/question.rb
UTF-8
324
3.546875
4
[]
no_license
class Question attr_reader :solution def initialize @num1 = rand(21) @num2 = rand(21) @operator = [:+, :-, :*].sample @solution = @num1.send(@operator, @num2) end def get_question "What is #{@num1} #{@operator} #{@num2} ?" end def correct?(answer) answer.to_i == @solution end e...
true
61d9896a43ac6a9ec78b76761d1d50fc4eb39ce3
Ruby
jackCHH/riftodds
/lib/riotapi.rb
UTF-8
628
2.6875
3
[]
no_license
require 'httparty' require 'uri' class RiotApi BASE_URL = "https://na.api.pvp.net" API_KEY = "?api_key=4ac9d17c-8e89-44d9-99cd-cb806bd078b9" def get_summoner_id(name) summoner_url = "#{BASE_URL}/api/lol/na/v1.4/summoner/by-name/#{name}#{API_KEY}" parse_json(summoner_url) end def get_full_stats(id) stat...
true
fc253d56beceeca5b8a570e4d8a212d978f11338
Ruby
walidwahed/ls
/exercises/120-oop_problems/easy1/02.rb
UTF-8
1,096
4.5625
5
[]
no_license
# What's the Output? # Take a look at the following code: class Pet attr_reader :name def initialize(name) @name = name.to_s # calling to_s on a String does not create a new object end def to_s @name.upcase! "My name is #{@name}." end end name = 'Fluffy' fluffy = Pet.new(name) puts fluffy.nam...
true
de66747aca6db7bee8495113da38c236c02da7cb
Ruby
StuartChartersE22/w3d5_CodeClan_Cinema_homework
/console.rb
UTF-8
2,206
2.8125
3
[]
no_license
require("pry") require_relative("./models/film.rb") require_relative("./models/customer.rb") require_relative("./models/ticket.rb") require_relative("./models/screening.rb") Ticket.delete_all() Screening.delete_all() Customer.delete_all() Film.delete_all() customer1 = Customer.new({ "name" => "Stuart", "wallet" =...
true
9b361fa092d3dc1f99e54e296e88bdf9a90f6545
Ruby
RedRobster66/lab-ruby-apartments
/apartments.rb
UTF-8
3,357
3.25
3
[]
no_license
class CreditScoreError < Exception end class BadTenantCreditError < Exception end class NotEnoughRoomError < Exception end class NoSuchTenantError < Exception end class NoSuchApartmentError < Exception end class ApartmentIsOccupiedError < Exception end def calculate_credit_rating credit_score case credit_scor...
true
1e8efefcc93c4202e382530090acf9cd37acb851
Ruby
georgejeffery/badges-and-schedules-london-web-121018
/conference_badges.rb
UTF-8
469
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def badge_maker(name) "Hello, my name is #{name}."# end def batch_badge_creator(names) badges=[] names.each do |i| badges.push(badge_maker(i)) end badges end def assign_rooms(names) rooms=[] names.each_with_index do |i, index| rooms.push("Hello, #{i}! You'll be assigned to room #{index+1}!") end ...
true
56b7517498c322bcc2f9f22cefb57f0547421a56
Ruby
quintel/etlocal
/app/services/dataset_combiner.rb
UTF-8
6,657
3.125
3
[ "MIT" ]
permissive
# frozen_string_literal: true # The DatasetCombiner parent class acts as the interface through which smaller areas can be # combined into a bigger one. It validates user input, sets defaults and then delegates the work # to the ValueProcessor and DataExporter that do the actual combining. # See the 'initialize' method...
true
3b2997b23a6c8bbb4b54290c06af12d54a317135
Ruby
erictaelee/tech_interview_practice
/most_frequent_letter.rb
UTF-8
683
4.3125
4
[]
no_license
# Given a string, find the most commonly occurring letter. # Input: “peter piper picked a peck of pickled peppers” # Output: “p” def frequent_letter(string) letter_counts = {} index = 0 most_frequent_letter = "" most_frequent_count = 0 while index < string.length if letter_counts[string[index]] le...
true
4586f8403e31ba470f4ebb647925657e8da87230
Ruby
hhf666feng/gitlab
/lib/container_registry/repository.rb
UTF-8
886
2.53125
3
[ "MIT" ]
permissive
module ContainerRegistry class Repository attr_reader :registry, :name delegate :client, to: :registry def initialize(registry, name) @registry, @name = registry, name end def path [registry.path, name].compact.join('/') end def tag(tag) ContainerRegistry::Tag.new(sel...
true
669020987216085ab31d3844fa70be5cbb97e260
Ruby
cozziekuns/Sandra
/tile_util.rb
UTF-8
432
2.96875
3
[]
no_license
#============================================================================== # ** TileUtil #============================================================================== module TileUtil def self.tile_value(tile) return 10 if self.jihai?(tile) return tile % 9 + 1 end def self.tile_suit(tile) ret...
true
bcaf2dfa0f1e336f99aa27b5cbc6722855552d75
Ruby
karthickpdy/CP
/Hackerrank/max_draws.rb
UTF-8
56
3.1875
3
[]
no_license
t = gets.to_i t.times do n = gets.to_i puts n + 1 end
true
a9f624848c9f8c8f1511f42935000b5e3a6126b6
Ruby
cha63506/library-227
/work/deprecated/requirements.rb
UTF-8
2,152
2.6875
3
[ "BSD-2-Clause" ]
permissive
class Library # class Requirements include Enumerable # def initialize(location) @location = location @dependencies = nil end # Location of project. def location @location end # Returns an array of `[name, constraint]`. def dependencies @dependenc...
true
46d75dc3471f32493fa432b4d92556c6b95b6120
Ruby
ashabbir/summarization
/main.rb
UTF-8
3,887
2.5625
3
[]
no_license
require 'sinatra' require 'yaml' require 'pry' require 'json' require 'sinatra/reloader' if development? require_relative 'lib/file_processor' require_relative 'lib/summarize' require_relative 'lib/mail_reader' require_relative 'lib/news_feed' require_relative 'lib/sentimental' set :static, true set :root, File.dirn...
true
e74781c7d61f96ba49599baf46ff37cc903e9d28
Ruby
ConorFl/overflow
/app/controllers/votes_controller.rb
UTF-8
919
2.53125
3
[]
no_license
class VotesController < ApplicationController def upvotes changevotes(params[:class],1) end def downvotes changevotes(params[:class],-1) end private def changevotes(type,howmuch) @typeClass = Kernel.const_get(type) user =User.find(session[:current_user_id]) @type = @typeClass.find(p...
true
c66c861f6f5cfe508ab6b98bf7cade50f1761e55
Ruby
ncm/countwords
/optimized.rb
UTF-8
401
2.921875
3
[ "MIT" ]
permissive
counts = Hash.new(0) bufsize = 64*1024 remaining = '' while 1 do chunk = STDIN.read(bufsize) if !chunk break end chunk = remaining + chunk last_lf = chunk.rindex("\n") if !last_lf remaining = '' else remaining = chunk[last_lf+1..] chunk = chunk[..last_lf] end chunk.downcase.split.each{...
true
9c8edf0c4ac401dfcb66d1733ad4b314e55b0ad4
Ruby
j-sm-n/black_thursday
/test/merchant_item_analyst_test.rb
UTF-8
2,539
2.671875
3
[]
no_license
require './test/test_helper' require './lib/merchant_item_analyst' require './lib/sales_analyst' require 'pry' class MerchantItemAnalystTest < Minitest::Test attr_reader :mi_anlyst def setup invoice_path = "./test/fixtures/31_invoices.csv" merchant_path = "./test/fixtures/3_merchants_v2.csv" invoice_i...
true
1c4be1435bf89cfdd97a41f70d10765938b113c5
Ruby
rkjfb/mazes
/book_files/recursive_division.rb
UTF-8
1,773
3.484375
3
[]
no_license
#--- # Excerpted from "Mazes for Programmers", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http:...
true
59fd523700297df4c67ae1c42bb89249a0bc0e85
Ruby
mkrobert/ruby_projectilemotion
/projectilemotion.rb
UTF-8
1,707
3.578125
4
[ "MIT" ]
permissive
#this library is located at #https://github.com/mkrobert/ruby_projectilemotion include Math #required kinematics library is located at #https://github.com/mkrobert/ruby_kinematics require './kinematics' class ProjectileMotion < Kinematics def findVIX(x,y,h,th) if (x[0] != nil) return x elsif (th != ni...
true
44c1cd1369d47f6378b12ef1b40b0fbf7e0073ca
Ruby
jaimerson/bakeru
/lib/bakeru/background.rb
UTF-8
3,169
2.984375
3
[]
no_license
require 'gosu' require 'bakeru/zorder' require 'gl' require 'glu' require 'glut' module Bakeru # This class loads and draws the tiles for a given location. class Background include Gl include Glu attr_reader :location, :game, :player # A central point to modifying tile size TILE_SIZE = 1 ...
true
f73d9e72baecf64a4787e243d45b3c5f816db13b
Ruby
biradarganesh25/hw-acceptance-unit-test-cycle
/rottenpotatoes/app/helpers/movies_helper.rb
UTF-8
237
2.90625
3
[]
no_license
module MoviesHelper # Checks if a number is odd: def oddness(count) count.odd? ? "odd" : "even" end def get_movie_director(movie) if movie.director == nil return "N/A" end return movie.director end end
true
ae39f8da25880fda90114a9bdaa059739473d881
Ruby
amcmullen9291/countdown-to-midnight-onl01-seng-ft-030220
/countdown.rb
UTF-8
307
3.5
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def countdown(seconds) while seconds>0 do puts"#{seconds} SECOND(S)!" seconds-= 1 end "HAPPY NEW YEAR!" end def countdown_with_sleep(seconds) while seconds>0 do puts"#{seconds} SECOND(S)!" sleep 1 seconds-= 1 end "HAPPY NEW YEAR!" end
true
6090a1d01c845c96b90788d5f73424febfd5b6e7
Ruby
chrisdziewa/event_manager
/lib/event_manager.rb
UTF-8
3,688
3.109375
3
[]
no_license
require "csv" require 'sunlight/congress' require 'erb' require 'date' Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5" def clean_zipcode(zipcode) zipcode.to_s.rjust(5, "0")[0..4] end def legislators_by_zipcode(zipcode) legislators = Sunlight::Congress::Legislator.by_zipcode(zipcode) end def ...
true
72d7190263f7cf3f2f5b33b45733d0ef6f1d8f71
Ruby
yanjustino/dojos_ruby
/pedra_papel_tesoura/partida.rb
UTF-8
557
3.015625
3
[ "MIT" ]
permissive
class Partida def initialize @vitorias = [['tesoura', 'papel'], ['papel', 'pedra'], ['pedra', 'tesoura']] end def jogar (jogador1, jogador2) @partida = [jogador1, jogador2] definir_vencedor || 'empate' end private def definir_vencedor jogadas.each { |jog...
true
caf075077fad74ee24f82573cfcbd6afd084671b
Ruby
petrul/misc
/stories/analyze/calculate-users-score.rb
UTF-8
3,496
3
3
[]
no_license
#! /usr/bin/ruby # script to get users that were closest or furthest from the final answers # (in order to see if somebody answered randomly) def run_sql_query(sql_query) require "mysql" dbh = Mysql.real_connect("infres5.enst.fr", "dimulesc", "cselumid", "dimulesc") #dbh = Mysql.real_connect("localhost", "dad...
true
3cbf407585c3961a44c5127e4984fc0c6d2fd047
Ruby
jtrtj/laugh_tracks
/spec/models/comedian_spec.rb
UTF-8
1,080
2.78125
3
[]
no_license
RSpec.describe Comedian do describe 'Validations' do describe 'Required Field(s)' do it 'should be invalid if missing a name' do comic = Comedian.create(age: 48) expect(comic).to_not be_valid end it 'should be invalid if missing an age' do comic = Comedian.create(name: '...
true
d4d5a8ddb27cb7f4613cf95fcb219d40abd77788
Ruby
tanaken0515/ruby-examination
/silver/studies/syntax/case04_refactoring.rb
UTF-8
160
3.53125
4
[]
no_license
def hoge(*args, &block) block.call(*args) end hoge(1,2,3,4) do |*args| p args # => [1, 2, 3, 4] p args.length > 0 ? "hello" : args # => "hello" end
true