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
4593aa4a307b564a2c188fc2d5bbfe0d1ee28a02
Ruby
renecasco/backend_prework
/day_7/lib/fizzbuzz.rb
UTF-8
1,039
4.5625
5
[]
no_license
class FizzBuzz attr_reader :starting_number attr_reader :ending_number def initialize(starting_number, ending_number) @starting_number = starting_number @ending_number = ending_number end def numbers_array array_length = (@ending_number - @starting_number) + 1 Array.new(array_length){|i...
true
80c8640717f7727b35c0372e5b47d022f1bb06bd
Ruby
jjidt/numbers_to_words_ruby
/spec/numbers_in_words_spec.rb
UTF-8
1,528
3.75
4
[]
no_license
require("rspec") require("numbers_in_words") describe("hundreds_in_words") do it("takes a number less than 20 and returns the english word") do hundreds_in_words(17).should(eq("seventeen")) end it("takes a number between 21 and 99 and returns the english word") do hundreds_in_words(97).should(eq("ninety...
true
248baf15a996cfb07a63dbc65f5256e4491b2640
Ruby
goodwink/fixed_width
/lib/fixed_width/section_group.rb
UTF-8
662
2.75
3
[]
no_license
class FixedWidth class SectionGroup attr_reader :name, :sections, :options attr_writer :header def initialize(name, options={}) @name = name @sections = [] @options = options end def section(name, options={}, &block) raise DuplicateSectionNameError.new("Duplicate sec...
true
fa3ba543a3dd042a8c9474f659241b6bcb22011c
Ruby
TylerSmall19/pixee-dust-api
/app/models/day.rb
UTF-8
459
2.796875
3
[ "MIT" ]
permissive
class Day < ApplicationRecord has_many :thoughts validates :thoughts, presence: true before_save :expire_entry def expired? expiration_date < Time.now.utc end # OVERRIDE the thoughts setter method to allow array input def thoughts=(thoughts_array) thoughts_array.each do |text| self.thought...
true
e3d88ef9cb21ac3bc21684c5097c724f513a763f
Ruby
Dujota/Ruby-comprehensive-examples-for-students
/ArrayHash/hashBlkExtract.rb
UTF-8
763
3.65625
4
[]
no_license
puts "=== Extracting Hashes with Block ===" names = {"fred" => "jones", "jane" => "tucker", "joe" => "tuchker", "mary" => "SMITH"} puts "names=#{names}" exe1 = 'names.detect {|k,v| v == "tucker"}' puts " #{exe1} --> #{eval(exe1)}" exe2 = 'names.find {|k,v| v == v.upcase}' puts " #{exe2} --> #{eval(exe2)}" exe3 =...
true
985601ae97ed93800a442ccf010190be4ae43071
Ruby
gperrin01/ga_proj2_PayFriends
/app/models/user.rb
UTF-8
1,269
2.75
3
[]
no_license
class User < ActiveRecord::Base has_secure_password validates :password, presence: true, on: :create validates :email, presence: true, uniqueness: {case_sensitive: false} validates :name, presence: true, length: {minimum: 2}, uniqueness: true has_many :deals_as_payer, class_name: "Deal", foreign_key: "...
true
c0cc45c623a6394453864bdfa186ef4ec2b016b4
Ruby
bpstein/airport_challenge
/lib/airport.rb
UTF-8
774
3.234375
3
[ "MIT" ]
permissive
require_relative 'plane' require_relative 'weather' class Airport DEFAULT_CAPACITY = 50 attr_reader :capacity def initialize(capacity = DEFAULT_CAPACITY) @planes = [] @capacity = DEFAULT_CAPACITY @weather = weather end def stormy? @stormy end def launch(plane) fail 'Already in...
true
897a023e1c5b20602b4fa1887ab6dc65b52c4aa8
Ruby
agrussellknives/minimal_match
/spec/minimal_search_spec.rb
UTF-8
1,382
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'minimal_match' require 'ripper' class Array include MinimalMatch::MinimalSearchMixin end describe "minmal array searching" do before :all do #create a big fat searchable array dir = File.dirname(__FILE__) @array = Ripper::...
true
f8d3892f92bd49f23f95958027ed030a02e35a3e
Ruby
bhb/gemcutter_sample_webhook
/gemcutter_sample_webhook.rb
UTF-8
118
2.53125
3
[]
no_license
require 'sinatra' post "/gemcutter" do puts request.body.string status 200 "Got: #{request.body.string}\n" end
true
81c88b62dbd1b5789ef77aa8cd66ccbb5ea6b620
Ruby
slowjack2k/yaoc
/examples/02_procs_as_constructors.rb
UTF-8
1,542
2.546875
3
[ "MIT" ]
permissive
require 'bundler/setup' Bundler.require(:development) require 'yaoc' include Yaoc::Helper puts "\n" * 5 OldUser2 = Struct.new(:id, :fullname, :r_role) User2 = Struct.new(:id, :firstname, :lastname, :role) reverse_source = ->(attrs)do OldUser2.new.tap do |old_user| attrs.each_pair do |key, value| old_u...
true
5a1be589379391a03613b3d3155cd5853ad9a5b8
Ruby
RSRBX07/old-exo-donovan
/Vehicles/jet.rb
UTF-8
239
2.625
3
[]
no_license
require_relative './plane.rb' class Jet < Plane def self.builded all_builded = super end def acceleration amount super(amount* 2) end end jet = Jet.new jet_2 = Jet.new boing = Plane.new puts Vehicle.builded.inspect
true
e1b2761defe4e8184d12059793a48b04b8df7408
Ruby
AnguillaJaponica/Ruby_Library_For_Contests
/ABC/ABC142/C.rb
UTF-8
167
3.328125
3
[]
no_license
n = gets.to_i numbers = gets.split(' ').map(&:to_i) rearranged = Array.new(n) n.times do |idx| rearranged[numbers[idx] - 1] = idx + 1 end puts rearranged.join(' ')
true
cfd5155917d1e0f56a57dc17f3bb6b5451d065a3
Ruby
CapitalJuniorCollege/data_types
/data_types.rb
UTF-8
3,299
3.53125
4
[]
no_license
@my_integer = 9 def get_my_integer @my_integer end def set_my_integer(other_integer) @my_integer = other_integer end def puts_my_integer puts @my_integer end def puts_my_integer_as_string # METODO SECRETO DE LOS PROGRAMADORES DE RUBY PARA COMVERTIR LO QUE SEA A STRING puts @my_integer.to_s end def class_...
true
2e3951128b6f66704fc366f1c3137cb63b03cb42
Ruby
drunkwater/leetcode
/hard/ruby/c0085_446_arithmetic-slices-ii-subsequence/00_leetcode_0085.rb
UTF-8
1,382
3.8125
4
[]
no_license
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #446. Arithmetic Slices II - Subsequence #A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference betwe...
true
b92076673f0db3b1ad626b767aa06ad6d024a3ed
Ruby
kchens/Project_Euler
/ex7.rb
UTF-8
910
4.15625
4
[]
no_license
def prime?(num) y = Math.sqrt(num).floor (2..y).each do |j| #Euler's math theorem return false if (num % j == 0) end return true end def num_prime(idx) #wrong, look at second method counter = 2 x = 3 while counter <= idx return x if counter == idx counter +=1 if prime?(x) x += 2 end end def num_...
true
964ef1311e32c2e9d2c5c0964408df0362b5ef46
Ruby
TheObtuseAutodidact/ruby_thingy
/spec/csv_parser_spec.rb
UTF-8
1,561
3.171875
3
[]
no_license
require "rspec" require "csv_parser" describe CSVParser do it "should be a CSVParser" do p = CSVParser.new expect(p.class).to eq(CSVParser) end it "should convert datetime string" do p = CSVParser.new expect(p.convert_time("10/2/04 8:44:11 AM")).to eq("2004-10-02T05:44:11...
true
3bb7deed867454a2445fb0392b1052544d4d2246
Ruby
yoshida-keita/aoj
/course/Algorithms/4_C.rb
UTF-8
140
2.75
3
[]
no_license
dic={} gets.to_i.times{ o,w=gets.chomp.split() case o when "insert" dic[w]=1 when "find" puts dic[w] ? "yes" : "no" end }
true
b7d8f16cd812f9f5f47c135771d5c1cffdee35b6
Ruby
massud/takeaway-challenge
/spec/menu_spec.rb
UTF-8
353
2.59375
3
[]
no_license
require 'menu' describe Menu do let(:menu) { described_class} it 'can order a meal' do burger = double 'Burger' expect(subject.order burger ).to eq [burger] end xit 'can order more than one meal' do #pizza = double 'Pizza' #chicken = double 'Chicken' #expect(subject.quantity (pizza, chicken))....
true
d0207f4ce156e7a1418d4275e5be77d1c76d64af
Ruby
matttoensing/war_or_peace
/spec/turn_spec.rb
UTF-8
5,146
2.953125
3
[]
no_license
# frozen_string_literal: true require_relative 'spec_helper' RSpec.describe Turn do context 'Basic' do before :each do @card1 = Card.new(:heart, 'Jack', 11) @card2 = Card.new(:heart, '10', 10) @card3 = Card.new(:heart, '9', 9) @card4 = Card.new(:diamond, 'Jack', 11) @card5 = Card.n...
true
92eef017e297ae238d055db2efd50d2b2cbb09ae
Ruby
fadhili-ed/course-revision
/week4/sinatra/myapp.rb
UTF-8
1,475
3
3
[]
no_license
require 'sinatra' get '/' do erb :index end get '/sum' do erb :sum end get "/calculation_results" do @first_number =params[:first_number].strip @second_number =params[:second_number].strip @empty_error = nil @invalid_values = nil # if @first_number == nil or @second_number == nil ...
true
89e482bccbb6887f475f7b66a9825db6925a3e79
Ruby
ELBootcamp/RubyCamp2018
/23-11-2018/monika/nokia_texter/spec/nokia_texter_spec.rb
UTF-8
891
2.921875
3
[]
no_license
require 'spec_helper' require_relative '../lib/nokia_texter' RSpec.describe NokiaTexter do describe '#squeeze' do it 'squeezes text' do expect(NokiaTexter.new('').squeeze).to eq('') expect(NokiaTexter.new('zaraz wracam').squeeze).to eq('ZARAZwracam') expect(NokiaTexter.new('Nie czekaj z kolacja'...
true
c31afd5be4b550b51e5a5f3f5a030f070f13ab69
Ruby
kinsona/project_ruby_game_center
/blackjack/player.rb
UTF-8
1,236
3.953125
4
[]
no_license
class Player attr_accessor :cash attr_reader :name def initialize(attrs) @name = attrs[:name] @cash = attrs[:cash] end def make_bet print "How much do you want to bet?\nCash available: $#{@cash}.\n $" validate_bet end def validate_bet input = nil loop do input = gets...
true
059fc42dc61315b35ddc76e993af1e85e7a1854c
Ruby
jmcaffee/mathtest
/spec/mathtest/interface_spec.rb
UTF-8
874
2.90625
3
[ "MIT" ]
permissive
require "spec_helper" describe Mathtest::Interface do it "can be instantiated" do expect(Mathtest::Interface.new).not_to be nil end it "displays a multiplication math problem" do problem = { left: 2, right: 3, op: :times, answer: 6 } expect(Mathtest::Interface.new.show(problem)).to eq("2 x 3 = ") ...
true
7adb207e4616768c1e2f4d2c9a49acf2f60bc122
Ruby
greygoo/ispycontrol
/ispy.rb
UTF-8
854
3.0625
3
[]
no_license
#!/usr/bin/ruby require 'socket' class ISPY def initialize(host, port) @socket = TCPSocket.new(host,port) end def disconnect @socket.close end def send(command) case command when "move_forward" puts "Moving forward" @socket.write [ 0x31, 0x31, 0x32, 0x31 ].pack('C*') whe...
true
62268efb1b6dd32191d7ad891875c4a62f3e3e4b
Ruby
jhake/AvionRubyExercises
/exercise01/age.rb
UTF-8
151
3.953125
4
[]
no_license
puts "How old are you?" age = gets.to_i [10, 20, 30, 40].each do | added_age | puts "In #{added_age} years you will be:" puts age + added_age end
true
99e111149c8171e86a6baa83c8102ee50fe0bb18
Ruby
Parth317/phase-0-tracks
/ruby/secret_agents.rb
UTF-8
1,202
4.46875
4
[]
no_license
def encrypt (string) alphabet = "abcdefghijklmnopqrstuvwxyz" count = 0 #move every letter of a string one letter forward (abcd becomes bcde) string_2 = ' ' while count < string.length alpha_list = alphabet[alphabet.index(string[count]) + 1] string_2 += alpha_list count += 1 end puts string_2 end def de...
true
bf5573350b0a5d42729e06600e204736c764c9f1
Ruby
yuki3738/AtCoder
/abc/abc062/tasks/abc062_a.rb
UTF-8
215
3.625
4
[]
no_license
g1 = %w(1 3 5 7 8 10 12) g2 = %w(4 6 9 11) g3 = %w(2) x, y = gets.split if g1.include?(x) && g1.include?(y) || g2.include?(x) && g2.include?(y) || g3.include?(x) && g3.include?(y) puts 'Yes' else puts 'No' end
true
3125d3dd9e23515eb29c3512855e1b3796326cec
Ruby
mfpiccolo/self_systeem
/test/dummy_app/app/services/user_creator.rb
UTF-8
382
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class UserCreator attr_reader :user def initialize(email:, name:, password: SecureRandom.uuid) @user = User.new(email: email, name: name, password: password) end def create if user.save UserInvitor.call(user) end user end def self.create(email:, name:, password: SecureRandom.uuid) ...
true
f6e3f226f9e12b5c3a5314a1b91b1c6756774061
Ruby
mrmicahcooper/ocean_candy
/spec/lib/station_spec.rb
UTF-8
981
2.8125
3
[]
no_license
require 'station' describe Station do subject { described_class } describe '.find' do it "returns the station by station id" do expect(subject.find(8410834).name).to eq("PETTEGROVE POINT, DOCHET ISLAND") end end describe ".all" do it "returns all the stations" do expect(subject.all.c...
true
07b937ecbbf676e0faf0243783d94ce09859a242
Ruby
reyes271292/ruby_basic
/example/personal_contact.rb
UTF-8
426
3.40625
3
[]
no_license
class PersonalContact attr_reader :name @name;@last_name;@telephone;@e_mail def initialize(name,last_name,telephone,e_mail) @name=name @last_name=last_name @telephone=telephone @e_mail=e_mail end def showPersonalContact() puts "" puts "Datos del contacto: " puts "nombre: "+@nam...
true
3c9dd7bae8902677d584a4c4fc20f27258a154ac
Ruby
simaob/our_milheones
/app/helpers/application_helper.rb
UTF-8
795
2.671875
3
[]
no_license
module ApplicationHelper def formatted_bet bet, solution=nil return 'No bet made' unless bet result = [] ['numbers', 'stars'].each do |i| sol = solution ? solution[i] : [] tmp = [] bet.send(i).each do |n| tmp << content_tag(:span, class: "#{"match" if sol.include?(n)}") do ...
true
00cf59fd7bc598661ef742f06f171c34dde3c6e5
Ruby
alem0lars/basel
/lib/basel/extensions/string.rb
UTF-8
471
3.328125
3
[ "Apache-2.0" ]
permissive
# Custom {String} class extensions. class String def self.phrase_end_signs ["!", "?", "."] end def phrase_ended?(signs = nil) Array(signs || String.phrase_end_signs).any? { |sign| self.end_with? sign } end def end_phrase_with!(sign) self.chop! while phrase_ended? self << sign end def ad...
true
2d456b1eb431172e4d5c6c621014f4153fb9b136
Ruby
acquia/http-hmac-ruby
/test/helpers/rack_app_test_base.rb
UTF-8
6,936
2.515625
3
[ "MIT" ]
permissive
require 'rack/test' require 'acquia-http-hmac/rack_authenticate' require_relative '../../example/app' module TestRackAppBase include Rack::Test::Methods # Need to define methods in test classes: # get_password_storage # get_password # Helper method def prepare_get(id, password, args = {}) mac = Acqu...
true
42bf8a779df06e58e6bc4d975b6438c596f4431f
Ruby
zdennis/rawline
/lib/rawline/terminal/windows_terminal.rb
UTF-8
1,707
2.734375
3
[ "BSD-3-Clause" ]
permissive
#!usr/bin/env ruby # # windows_terminal.rb # # Created by Fabio Cevasco on 2008-03-01. # Copyright (c) 2008 Fabio Cevasco. All rights reserved. # # This is Free Software. See LICENSE for details. # module RawLine # # This class is used to define all the most common character codes and # escape...
true
1b0e10c31da38bb9861c53951b48f7eeefb6e200
Ruby
BouquetTristan/TentsAndTrees
/Interface/fFin.rb
UTF-8
1,114
2.78125
3
[]
no_license
require 'gtk3' require './Classes/Page.rb' #====== Fenetre de fin de partie du jeu class FFin < Page #Initialise la page # @param monApp //l'application # @param header //le titre de la page # @param anciennePage //Le lien de la dernière page # @param unJoueur //le joueur concerné # @param statue /...
true
9d973b79c28b3d8317b4cf24124365625b3fcb23
Ruby
MargoSolo/stared-repos-p2
/AppAcademy/Curriculum/12 Career Quest/W24D5 Pair Boarding Complete/13B.rb
UTF-8
1,166
4.09375
4
[]
no_license
# Square Root # Implement a square root function that uses only addition, subtraction, multiplication and division in less than linear time. You may assume that input is always a perfect square. # Hint: One naive solution has a better time complexity than many people realize--iterating from 0 until the square root is ...
true
1aac89a133ddf77b625009bcb994db0a271aacc6
Ruby
jatranscendentalne/code_sensei_course
/pierwszy_zjazd/2.rb
UTF-8
67
2.546875
3
[]
no_license
puts "put" puts "s" print "prin" print "t" print "a\n \n \n \nb"
true
4c40b907fdfd5a0593c0434691f3e7bec491f626
Ruby
billystack/misc
/javaConnectToOracle.rb
UTF-8
911
2.90625
3
[]
no_license
require 'java' require "C:/jruby-1.6.5/lib/ojdbc14.jar" def connect_to_db() odriver = Java::JavaClass.for_name("oracle.jdbc.driver.OracleDriver") url = "jdbc:oracle:thin:@localhost:1521:XE" puts "About to connect..." $connection = java.sql.DriverManager.getConnection(url, "SYSTEM", "password"); ...
true
d21b21cf87dbd43eb0437d7840dabdb88e8189b6
Ruby
benbenedek/betting
/app/helpers/application_helper.rb
UTF-8
552
2.65625
3
[]
no_license
module ApplicationHelper def is_number?(str) if !/\A\d+\z/.match(str) false else true end end # Logs in the given user. def log_in(user) session[:user_id] = user.id end # Returns the current logged-in user (if any). def current_user @current_user ||= User.find_by(id:...
true
1f3dceddfdd49201e9295c2d8d5bbef17521dd98
Ruby
pluginaweek/polymorphic_identity
/lib/polymorphic_identity.rb
UTF-8
1,888
2.984375
3
[ "MIT" ]
permissive
# Adds dynamic attributes for polymorphic associations based on the name of # the class for the polymorphic record. For example, # # class Tag < ActiveRecord::Base # belongs_to :taggable, :polymorphic => true # end # # class Article < ActiveRecord::Base # has_many :tags, :as => :taggable # end # ...
true
00f69652ebc9c951e2290bc46829621fdcf40e8a
Ruby
aramsalimi91/Payback
/lib/tokenable.rb
UTF-8
705
2.71875
3
[]
no_license
# This module is an extraction of something that is generally associated with # a token and expires after a period of time. For example, it's used in reset # tokens and group invitations. module Tokenable def generate_token begin self.token = SecureRandom.urlsafe_base64 end while self.class.exists?(tok...
true
78d458e415a9ad61cc925c3413149728c831f7aa
Ruby
jmac11/gecko-pusher
/lib/gecko-pusher/channel/number.rb
UTF-8
1,174
2.703125
3
[ "MIT" ]
permissive
module Gecko module Pusher module Channel class Number < Base def push(*args) options = extract_options(args) data = {item: extract_values(args)} data[:type] = options[:type] unless options[:type].nil? data[:absolute] = options[:absolute] unless options[:abso...
true
6012141d9176364ced037536fe704d856ad5b8ae
Ruby
joshvh/ruote
/lib/openwfe/participants/store_participants.rb
UTF-8
8,928
2.5625
3
[ "MIT" ]
permissive
#-- # Copyright (c) 2007-2009, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy...
true
50d5cd29d6ed77bf762b1fa9925ac43ba2f2969e
Ruby
flavorjones/lorax
/lib/lorax/fast_matcher.rb
UTF-8
3,585
2.703125
3
[ "MIT" ]
permissive
module Lorax class FastMatcher attr_accessor :match_set def initialize(doc1, doc2, dependency_injection={}) @document1 = doc1 @document2 = doc2 @match_set = dependency_injection[:matcher_match_set] || MatchSet.new(doc1, doc2, dependency_injection) end def match match_node @do...
true
7dc000c1fc8e38f9f32504760d513c98f7095fc5
Ruby
fiddler-crabs-2014/flash_cards
/flash_cards/app/controllers/users.rb
UTF-8
1,474
2.53125
3
[ "MIT" ]
permissive
get '/login' do # @message = false # @text = "what you like to do" @message = session[:message] erb :login end post '/login' do email = params[:email] password = params[:password] @user = User.authenticate(email, password) if @user session[:user_id] = @user.id session[:name] = @user.name ...
true
68ad376046c13928e36ce80deee712a9d9dd50b1
Ruby
c1iff/triangle
/lib/triangle.rb
UTF-8
588
3.125
3
[ "CC-BY-3.0", "MIT" ]
permissive
class Triangle define_method(:initialize) do |side_1, side_2, side_3| @side_1 = side_1 @side_2 = side_2 @side_3 = side_3 end define_method(:is_equilateral) do @side_1 === @side_2 && @side_1 === @side_3 end define_method(:is_isosceles) do @side_1 === @side_2 || @side_2 === @side_3 || @sid...
true
5ac4b00564bba39f1847604a927568e0ce0b939d
Ruby
amatoro/MIR_Challenges
/solution6.rb
UTF-8
482
2.90625
3
[]
no_license
require 'sinatra' get '/' do erb :form end post '/answer' do # user_input = params['userinput'] # if params['userinput'].empty? || request.query_string.empty? != "" # "<h1>Hola desconocido!</h1>" # else # "<h1>Hola #{user_input}!</h1>" # end user_input = params['userinput'] "¡Hola #{params['...
true
31aec9e1b6c81e4496c90f73ffd53de5ac1eef7d
Ruby
jetabajrami/hotel
/test/hotel_controller_test.rb
UTF-8
4,005
3.03125
3
[]
no_license
require_relative "test_helper" describe Hotel::HotelController do before do @hotel_controller = Hotel::HotelController.new @date = Date.parse("2020-08-04") @rooms = Array.new(20){|i| Hotel::Room.new(i+1)} end describe "wave 1" do describe "initializer" do it "Creates an instance of hotel c...
true
cebc9fecaf43aa3428fae56db1f4b346e20f0f5b
Ruby
AnguillaJaponica/Ruby_Library_For_Contests
/ABC/ABC115/B.rb
UTF-8
150
3.25
3
[]
no_license
n = gets.to_i item_prices = [] n.times do item_prices.push(gets.to_i) end sorted = item_prices.sort puts sorted[-1]/2 + sorted[0..-2].inject(:+)
true
263734400b2d4e051b41048a64bce6b8de4cbd31
Ruby
stellakunzang/battleship
/test/cell_test.rb
UTF-8
2,034
3.125
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/ship' require './lib/cell' require "pry" class CellTest < Minitest::Test def test_it_exists cell = Cell.new("B2") assert_instance_of Cell, cell end def test_it_has_attributes cell = Cell.new("B2") assert_equal "B2", cell.coordin...
true
cca9fd78f3db722493c22589671105fb1a89483d
Ruby
allwchen/AppAcademyHomework
/ruby/Allen_Chen_07_memory_puzzle/computerplayer.rb
UTF-8
1,471
3.6875
4
[]
no_license
require "byebug" class ComputerPlayer attr_reader :name attr_accessor :previous_guess def initialize(game_size) @name = "Computer" @game_size = game_size @known_cards = {} @matched_cards = {} @previous_guess = nil end def get_input(message="") puts message if !message.empty? prom...
true
2658f4dcd4826074a0b3be394557c23d6f02e6a5
Ruby
learn-co-students/nyc-web-080320
/04-oo-associations/console.rb
UTF-8
1,190
2.84375
3
[]
no_license
require 'pry' require_relative './app/models/user' require_relative './app/models/animal' hermione = User.new('hermione', 18) teddy = User.new('teddy', 18) erik = User.new('erik', 18) alicia = User.new('alicia', 18) greg = User.new('greg', 18) russell = User.new('russell', 47) kain = User.new('kain', 47) animals = [ ...
true
bf5c81542ab476628ef2e703bd2710cc90614c5b
Ruby
lukasjones/support_hero
/spec/helpers/scheduled_months_helper_spec.rb
UTF-8
792
2.71875
3
[ "MIT" ]
permissive
require 'rails_helper' # Specs in this file have access to a helper object that includes # the ScheduledMonthsHelper. For example: # # describe ScheduledMonthsHelper do # describe "string concat" do # it "concats two strings with spaces" do # expect(helper.concat_strings("this","that")).to eq("this that") ...
true
2fc999fbe10775c4aff658fb36f58daff5a1e726
Ruby
zzurang/event_watcher
/lib/event_watcher/watcher.rb
UTF-8
931
2.546875
3
[]
no_license
require "rubygems" require "active_record" module EventWatcher class Watcher include ActiveSupport::Inflector attr_accessor :watched_method_name alias :watched_callback_name :watched_method_name @@watchers = {} def self.find(key) @@watchers[key] end def initialize(attributes) ...
true
65825c846f365b232a2c2973ae38b701330f3071
Ruby
mindplace/ongoing-study
/Kickstart/session1/challenge/7_string.rb
UTF-8
740
4.28125
4
[ "MIT" ]
permissive
# given a string, return the character after every letter "r" # # pirates_say_arrrrrrrrr("are you really learning Ruby?") # => "eenu" # pirates_say_arrrrrrrrr("Katy Perry is on the radio!") # => "rya" # pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr" def pirates_say_arrrrrrrrr(string) ret...
true
f2476d93722db57deadaee1d663aeb79240fb846
Ruby
btsk18/badges-and-schedules-cb-000
/conference_badges.rb
UTF-8
566
3.90625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def badge_maker(name) "Hello, my name is #{name}." end def batch_badge_creator(names) messages = [] names.each { |name| messages << badge_maker(name) } messages end def assign_rooms(speakers) assignments = [] speakers.each_with_index { |speaker, index| assignments << "Hel...
true
ad8831da4f6d6d2cd0dea67c2afed5d5b43bab5a
Ruby
max-konin/valera
/lib/main_menu_factory.rb
UTF-8
574
2.734375
3
[]
no_license
require_relative './components/menu' class MainMenuFactory MENU_ITEMS = [ { title: 'Save', command: 'save', action: :save }, { title: 'Load', command: 'load', action: :load }, { title: 'Exit', command: 'exit', action: :exit } ].freeze def initialize(only:) @only = only || MENU_ITEMS.map { |item|...
true
9f895df209cc8fb5bb326914363401ec67bd7548
Ruby
stonesaw/AtCoder
/ABC/ABC167_A.rb
UTF-8
107
3.453125
3
[]
no_license
s = gets.chomp t = gets.chomp t[t.length - 1] = "" if (s == t) puts "Yes" else puts "No" end
true
05ff8c7192e81b289f77a65817f150c3d065d9b3
Ruby
BradyBonnette/closest_fibonacci
/test/test_closest_fibonacci.rb
UTF-8
1,479
3.46875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'helper' require 'closest_fibonacci' class TestClosestFibonacci < Test::Unit::TestCase # Create a map that contains the first 10 test numbers (as keys) mapped to their # respective expected results (as values). More can be added here when necessary @test_data = {0=>0, 1=>1, 2=>2, 3=>3, 4=>3, 5=>5, 6=>...
true
359b6c0e4d650b3bcdf387fda43d0f47814fd4d9
Ruby
SFEley/acts_as_icontact
/lib/acts_as_icontact/resources/account.rb
UTF-8
1,444
2.546875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
module ActsAsIcontact # The top-level Accounts resource from iContact. Currently only supports retrieval -- and is # highly targeted toward the _first_ account, since that seems to be the dominant use case. class Account < Resource # This is the one major resource that comes directly from the main path. ...
true
f69437857b3852145e1e96d748d2dbc79dd0d37c
Ruby
KwakDesign/phase-0-tracks
/ruby/hashes.rb
UTF-8
2,891
3.53125
4
[]
no_license
# Interior Designer Client Info Application Pseudo Code # Collect client's information which include the client's name, age, number of children they have, decor theme, favorite color, their spending budget and if they have pets. # In the case the user has entered incorrect information on any of the questions, allow the...
true
28aedd8ccf8b98e41beff1e3824fdee75b4ce4c3
Ruby
tomxuetoy/Ruby_yield
/Ruby_yield.rb
UTF-8
290
3.140625
3
[]
no_license
def sequence(n,m,c) i=0 while(i<n) yield i*m+c #yield是占位符,先占着 ,至于怎么处理,不知道,看后面 i+=1 end end sequence(5,2,2) {|x| puts x} #后面一部分就是真正实现了yield的处理输出 #Run result: #2 #4 #6 #8 #10
true
2916ea00f7b642b52ede06e56693830f43d53b25
Ruby
Adam-abuba/Sparta_UI_Testing
/capybara/capybara_class/capybara.rb
UTF-8
520
2.765625
3
[]
no_license
require 'capybara/dsl' class BbcHomepage # page object HOMEPAGE_URL = "http://www.bbc.co.uk" SIGN_IN_LINK_ID = "#idcta-link" def initialize Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) end @driver = Capybara::Session.new(:chrome) end d...
true
b2d6fed8c92641625b55e2d77eb4e15a2c5266de
Ruby
eriksk/Platonic
/platonic/heart.rb
UTF-8
200
2.71875
3
[]
no_license
module Platonic class Heart < Particle def update dt @current += dt @position.x += @velocity.x * dt @position.y += @velocity.y * dt @rotation = Math::sin(@current * 0.01) end end end
true
03830122eb8d0568ef8b5eb823bfe7566fca5bc3
Ruby
apotonick/nit
/lib/nit/command/status.rb
UTF-8
2,419
2.703125
3
[ "MIT" ]
permissive
module Nit class Command class Status < Command # Encapsulates the process of computing the file index from `git status`. class State # DISCUSS: alternative names: Screen, ScreenState, FileIndexes? # TODO: test me. def initialize(screen_state, config) @screen = Lines.new(scre...
true
c68bc3f79fe971a76189e0d803a4fbf558751681
Ruby
siakaramalegos/rubypractice
/stringlength.rb
UTF-8
137
3.90625
4
[]
no_license
puts "Give me a word or phrase!" user_input = gets.chomp.to_s puts "Your input has exactly #{user_input.length} characters!! Amazing!!"
true
7f453f9f9409f3ab93c9b6995622c935b9d39e1f
Ruby
JVThomas/project-euler-smallest-multiple-e-000
/lib/oo_smallest_multiple.rb
UTF-8
408
3.5625
4
[]
no_license
# Implement your object-oriented solution here! class SmallestMultiple def initialize(input) @ceiling = input @arrNum = [] end def lcm num = 0 value_found = false for i in 1..@ceiling @arrNum.push(i) end while value_found == false num += @ceiling value_found = ...
true
e20a1be490d8a1a20c0548177a95f65161c9f07a
Ruby
risafj/mr_messenger
/app/models/message.rb
UTF-8
571
2.640625
3
[]
no_license
class Message < ApplicationRecord validates :scheduled_date_time, :sender_number, :receiver_number, :content, presence: true validates :content, length: { minimum: 2, maximum: 100 } before_save :check_numbers_validity private def check_numbers_validity sender_check = /^\+\d+$/.match(sender_number) ...
true
dde145cf5923365352e845dcb299a56ebc0a6df4
Ruby
Havko/recursion
/warmup.rb
UTF-8
349
3.734375
4
[]
no_license
def fib(n) prev = 1 newnum = 0 sum = 0 array = [] (0..n-1).each do |i| array << newnum current = newnum newnum+=prev prev = current end return array end def fibs_rec(n) if n < 2 then return n else return fibs_rec(n - 1) + fibs_rec(n -2) end ...
true
12409552d013c7883e6a3df465b099114aa1ea8c
Ruby
rayning0/codility
/10-3-peaks.rb
UTF-8
2,780
3.625
4
[]
no_license
# https://codility.com/demo/results/trainingY67YP5-4QB/ # require 'minitest/autorun' <--- for Minitest # O(n*n). 100% correct, 20% performance. def slow_solution(a) return 0 if [1, 2].include?(a.size) peaks = [] blocks = 0 length = a.size (1..length - 2).each do |i| if a[i] > a[i - 1] && a[i] > a[i + 1]...
true
aa20bfc05d7f914a3376f2082c93a8aa1f34055b
Ruby
squidci/squid-rspec
/lib/squid-rspec/example.rb
UTF-8
827
2.734375
3
[ "MIT" ]
permissive
module Squid class Example def self.convert(example) new(example).convert end def initialize(example) @example = example end def convert { test_group: type, description: description, started_at: result[:started_at], finished_at: result[:finish...
true
d3d694b147623a9e0361eb00e93bb641a0922ed4
Ruby
ozzman84/independent_challenges
/ic/seattle_grace_2105/lib/network.rb
UTF-8
1,013
3.40625
3
[]
no_license
class Network attr_reader :name, :hospitals def initialize(name) @name = name @hospitals = [] end def add_hospital(hospital) @hospitals << hospital end def highest_paid_doctor doctor_list = @hospitals.flat_map(&:doctors) doctor_list.max_by(&:salary) end def doctors_...
true
6c658bf796c27109ca986184542a39deaf15951f
Ruby
lprogg/LearnRuby
/02_calculator/calculator.rb
UTF-8
335
3.578125
4
[]
no_license
def add(first_arg, second_arg) first_arg + second_arg end def subtract(first_arg, second_arg) first_arg - second_arg end def sum(arg) arg.empty? ? 0 : arg.sum end def multiply(*args) args.inject(:*) end def power(first_arg, second_arg) first_arg**second_arg end def factorial(n) n.zero? ? 1 : n * factor...
true
fd605fe5f642fe8915220b9e35a8d79ea16cb8e2
Ruby
kabisa/mt940
/spec/mt940_triodos_spec.rb
UTF-8
1,525
2.5625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require_relative 'spec_helper' describe "Triodos" do before :each do @file_name = File.dirname(__FILE__) + '/fixtures/triodos.txt' @bank_statements = MT940::Base.parse_mt940(@file_name)["390123456"] @transactions = @bank_statements.flat_map(&:transactions) @transaction = @transactions.first end ...
true
94fa345982c9b3d3cf8cfbd4fa2b26e21fed7ac7
Ruby
hiimchinh/rb101
/easy_3/squaring_an_argument.rb
UTF-8
165
3.671875
4
[]
no_license
def multiply(number1, number2) number1 * number2 end def power_to_the_n(num, n = 2) multiply(num ** n, 1) end puts power_to_the_n(8, 3) puts power_to_the_n(-5)
true
24266ea87f3ad95e603bbcd7f402f107f6ddad70
Ruby
patorash/csv2excel
/exe/csv2excel
UTF-8
710
2.671875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require "csv2excel" require 'optparse' options = {} OptionParser.new do |opts| opts.on('-f', '--file VALUE', String, 'CSV file path') { |v| options[:file] = v } opts.on('-d', '--dir VALUE', String, 'Directory path') { |v| options[:directory] = v } opts.on('-v', '--version', 'Prints version'...
true
3482a19c01ea3bdfd1346ec067a66588b41c0124
Ruby
jywei/ruby-toys
/averages.rb
UTF-8
119
3.296875
3
[]
no_license
class Calculator def average(object) object.each do |k, v| puts (v[0] + v[1] + v[2])/3 end end end
true
6bb838ae881c54ba61ea331c9ba0a5845a429799
Ruby
webbedfooty/w02-rps
/main_rps.rb
UTF-8
2,988
4.09375
4
[]
no_license
#require "pry" require_relative "lib/players.rb" player_one = Player.new player_two = Player.new player_one.wins = 0 player_two.wins = 0 x = 0 ####################################################### def rounds_to_play(n_rounds) while n_rounds % 2 == 0 puts "Please select an odd number of rounds to play" n...
true
913f77455a68fa4265fcb85cafaa2b0d5a7a19bc
Ruby
src22/ruby-fowler
/dynamic-reception/builder.rb
UTF-8
1,222
3.09375
3
[]
no_license
require_relative 'model' class PromotionBuilder def initialize @rules = [] end def content return Promotion.new(@rules) end def score anInteger @rules << PromotionRule.new(anInteger) return PromotionConditionBuilder.new(self) end def add_condition arg @rules.last.add_condition arg e...
true
f7af0762560ca17c53cb4b7eb9411bdd1cb3fea3
Ruby
Nerajno/module-one-final-project-guidelines-atlanta-web-042219
/lib/AppController.rb
UTF-8
8,966
3.3125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class AppController attr_reader :name @@current_user = nil def initialize welcome mood_check main_menu end # This code will be optimized with the prompt gem but this is just to get it all up and running with a # basic structure #Add optional verification step with r...
true
a5dcfbd96e57b4cfa9914c8b3acab0d5af3c2cd6
Ruby
sspatari/DesignPatterns
/lab3/behaviour_patterns/staff_observer.rb
UTF-8
290
2.890625
3
[]
no_license
module StaffObserver def initialize @observers = [] end def add_staff(observer) @observers << observer end def delete_staff(observer) @observers.delete(observer) end def notify_staff @observers.each do |observer| observer.work(self) end end end
true
bf168c8bbe7058e891522a3a7c421bb4d13ef561
Ruby
voxpupuli/puppet_webhook
/lib/puppet_webhook/chatops.rb
UTF-8
1,933
2.828125
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true module PuppetWebhook # Chatops object for sending webhook notifications to chatops tools # # @example # chatops = PuppetWebhook::Chatops.new('slack', 'https://webhook.slack.com/blah', '#general', 'slack_user') # chatops.notify('It works!') class Chatops # Public: Initi...
true
b1b9d8a27b1ba631eccb643c6a9cd56b22cb8feb
Ruby
DLSutariya/Selenium-Framework
/lib/template_tools.rb
UTF-8
1,540
2.96875
3
[]
no_license
module MA1000AutomationTool class TemplateTools #BUR constants UR_CHECKSUM_OFFSET_BYTE1 = 4 UR_CHECKSUM_OFFSET_BYTE2 = 5 UR_CHECKSUM_OFFSET_START = 6 UR_ID_START = 8 #BUR get checksum bytes def self.bur_get_checksum_bytes(byt_arr) p = byt_arr plen = byt_arr.size cs = 0 ...
true
2413e31ca30909eaffb900e64ac9c0ab4beff8b5
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/cs169/800/feature686/whelper_source/16803.rb
UTF-8
255
3.140625
3
[]
no_license
def combine_anagrams(words) hash = Hash.new(0) words.each do |word| sword = word.downcase.split(//).sort.join if hash.has_key?(sword) then hash[sword].insert(-1, word) else hash[sword] = [word] end end hash.values end
true
d6e1d8836659a7390abc059a773af83812ab08f5
Ruby
vise890/DBC_portfolio
/phase1/p3/nested_arrays_to_hash.rb
UTF-8
983
3.6875
4
[]
no_license
# CAUTION: operates destructively on roster def convert_roster_format(roster) headers = roster.shift roster.map! { |row| row.map! { |cell| prepare_cell(cell) } } roster.map! { |row| headers.zip(row) } return roster.map { |row| Hash[row] } end def prepare_cell(cell) case cell when /^\d+$/ cell.to_i el...
true
1a89b79c13f490fe6a55e133757631da70660a92
Ruby
hackrole/restful_web_services_code
/ruby/ch8/fetch-oreilly-conditional.rb
UTF-8
745
2.734375
3
[]
no_license
#!/usr/bin/ruby # fetch-oreilly-conditional.rb require 'rubygems' require 'rest-open-uri' uri = 'http://www.oreilly.com' # Make an HTTP request and then describe the response. def request(uri, *args) begin response = open(uri, *args) rescue OpenURI::HTTPError => e response = e.io end puts " Statu...
true
48d26e170d47a6d4c4be7a168cbe41440c8cf075
Ruby
ammonc/notleftoversagain
/app/controllers/previous/menu_planner_controller.rb
UTF-8
14,160
2.5625
3
[]
no_license
class MenuPlannerController < ApplicationController MEALS_PER_DAY = 3 def index redirect_to :action => 'show_existing_n_week_menus' end def drag_n_drop_n_week_menu_planner n_week_menu_id = params[:n_week_menu_id] @n_week_menu = NWeekMenu.find(n_week_menu_id) @single_meal_menus = Sing...
true
3e59996ba231e1c779c1818276e06cb2899413ff
Ruby
lucaslimasouza/supermarket
/spec/lib/checkout_spec.rb
UTF-8
2,193
2.671875
3
[]
no_license
require 'spec_helper' require 'checkout' RSpec.describe Checkout do let!(:curry_sauce) { instance_double('Product', code: '001', price: 1.95) } let!(:pizza) { instance_double('Product', code: '002', price: 5.99) } let!(:t_shirt) { instance_double('Product', code: '003', price: 25) } describe '#total' do ...
true
5caa19971751053c8e41938511a4958e336e59a3
Ruby
cis-manish-prajapat/session_test123
/lib/prime.rb
UTF-8
92
3.234375
3
[]
no_license
require 'prime' def is_prime?(num) p num.prime? end (1..5).each do |n| is_prime?(n) end
true
d8b00f0b409c2bcc67f28ae9a6164e0b4e182323
Ruby
maartenvg/jekyll-icheckmovies
/test/test_get_imdb_ids.rb
UTF-8
2,035
2.578125
3
[ "MIT" ]
permissive
require "test/unit" require "icheckmovies" require 'webmock' include WebMock::API class TestImdbIds < Test::Unit::TestCase def setup @body = <<-BODY <ul> <li class="listItemMovie"> <a class="optionIMDB" href="http://www.imdb.com/title/tt0390381/">Title</a> </li> <li class="listItemM...
true
122dd778afcd4154012d64e4f651ebd135f57dd3
Ruby
lshimokawa/activegraph
/lib/active_graph/node/id_property/accessor.rb
UTF-8
1,655
2.59375
3
[ "MIT" ]
permissive
module ActiveGraph::Node::IdProperty # Provides get/set of the Id Property values. # Some methods module Accessor extend ActiveSupport::Concern attr_reader :default_property_value def default_properties=(properties) @default_property_value = properties[default_property_key] end def de...
true
24f5891fa9c491ca5edae7504d566a1f10f83cc6
Ruby
vghn/vscripts
/lib/vscripts/aws/ec2.rb
UTF-8
2,661
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
module VScripts module AWS # EC2 Module smells of :reek:UncommunicativeModuleName # @ec2 smells of :reek:UncommunicativeVariableName # ec2 smells of :reek:UncommunicativeMethodName # A collection of methods used for interaction with Amazon Web Service # Elastic Compute Cloud. module EC2 ...
true
bea649a9decd11c25b08fcab1b41eccf5b5570ef
Ruby
maleko/automaton
/spec/lib/automaton/board_spec.rb
UTF-8
1,508
2.84375
3
[ "MIT" ]
permissive
require 'spec_helper' describe Automaton::Board do describe "constants" do it "should have a max of 4 for x" do expect(Automaton::Board::MAX_X).to eql 4 end it "should have a max of 4 for y" do expect(Automaton::Board::MAX_Y).to eql 4 end it "returns 0 to 4 for the list of allowab...
true
107e6e394fd0d1c4439d283e7faa686d3bf28c68
Ruby
jgirao/rails-tutorial
/03 - Models/publicationdb/app/models/author.rb
UTF-8
746
2.609375
3
[]
no_license
class Author < ActiveRecord::Base has_many :publication has_many :papers, :through => :publication attr_accessible :name, :email, :gender, :male validates :name, :presence => true, :length => {:minimum => 1, :maximum => 254} validates :email, :presence => true, ...
true
96f4b35670ba96466b4170b7565f59fed87c01df
Ruby
katharinetamashiro/studies
/ep-exercicios/m5/e2/m5-e2.rb
UTF-8
563
2.546875
3
[]
no_license
class M5E2 def cpf_validation(cpf) if cpf.match(/\d{3}\.?\d{3}\.?\d{3}-?\d{2}/) return true else return false end end def email_validation(email) if email.match(/^(\w+\.*)+@([a-zA-Z]*\d*\.*)+$/) return true else return ...
true
8b8002af65afe08ecc4c00408f1d1a3035142bb9
Ruby
ghostlambdax/recognizeapp
/infrastructure/create_release_workflow.rb
UTF-8
1,905
2.609375
3
[]
no_license
# NOTE: this uses gh to setup the OAuth application token # https://cli.github.com/manual/ # MAC: brew install gh # gh auth login # then follow the prompts to go through browser authentication # # USAGE: (in irb) # require './infrastructure/create_release_workflow' # CreateRelease...
true
79b0ce06024a6f688f54e0353d96c10801a637de
Ruby
StupidCodeFactory/rcoremidi
/lib/rcoremidi/rythm_sequence.rb
UTF-8
954
2.578125
3
[ "MIT" ]
permissive
require 'rcoremidi/probability_generator' module RCoreMidi class RythmSequence def initialize(pitch, beat_resolution, probabilities) self.pitch = pitch self.beat_resolution = beat_resolution self.probabilities = probabilities end def generate(enable_probability, channel) ...
true
93318da8b8ad2d26fb09c6f5b8df707ac48c807f
Ruby
ThunderKey/dirwatch
/spec/support/exit_matcher.rb
UTF-8
1,347
2.71875
3
[ "MIT" ]
permissive
module CallExitHelper def exit_status yield nil rescue SystemExit => e e.status end end RSpec::Matchers.define :call_exit_with do |expected| include CallExitHelper supports_block_expectations match do @exit_status = exit_status(&actual) @exit_status == expected end match_when_neg...
true
7ab23b03f7897c18bf14f38d045a5a23cdf07fb6
Ruby
Smithe941/maxwell-exercise-2
/store_spec.rb
UTF-8
1,088
2.640625
3
[]
no_license
# frozen_string_literal: true require 'rspec' load 'store.rb' RSpec.describe Store do subject do store = Store.new store.calculate(order) end describe 'calculate' do let(:valid_order) { [1, 2, 2, 3, 1, 1, 4, 2] } let(:invalid_order) { [6, 5, 12] } let(:expected_hash) do { item...
true
c527edcf343653ab0f50154adcd752c21a28f16e
Ruby
textchimp/wdi-22
/week11/recursion/array.rb
UTF-8
585
3.859375
4
[]
no_license
a = [1,2,3,4,5,6] # a.each do |i| # puts i # end def recursive_iterate( arr, indent=0 ) # print the first item # call ourselves with the rest of the array # stop when there's nothing left in the array # first = arr[0] # rest = arr[1..-1] # first = arr.first # rest = arr.drop(1) first, *rest = ...
true