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
44702113d16d2347584d8a15291f47b359faaac8
Ruby
dommichalec/launch_school
/programming_foundations/exercises/easy3.rb
UTF-8
1,302
4.03125
4
[]
no_license
# Show an easier way to write this array: flintstones = ["Fred", "Barney", "Wilma", "Betty", "BamBam", "Pebbles"] flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) p flintstones # How can we add the family pet "Dino" to our usual array: flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) flintstones <<...
true
5990b6b93769050db998d0d580d75c0b29c8f974
Ruby
RadiactiveJesus/Tic-Tac-Toe
/spec/board_spec.rb
UTF-8
1,080
3.359375
3
[]
no_license
require './lib/board.rb' RSpec.describe Board do let(:board) { Board.new } describe "#add_at" do it "adds an string, depending on the current player, in a specific position of the board" do expect(board.add_at(5, "X")).to eql("X") end end describe "#full?" do it "ret...
true
1d0d1808010882f1b8fb2f15e6cf32973dda736b
Ruby
ensconced/101-programming-foundations
/small_problems/easy 5/clean_up_words_without_regex.rb
UTF-8
192
3.1875
3
[]
no_license
def cleanup(sentence) sentence.chars.map{|x| (('a'..'z').to_a.push(' ').include? x.downcase) ? x : ' '}.join.squeeze(' ') end puts cleanup("---what's my +*& line?") == ' what s my line '
true
8f220ee131f16a6f805c0a632dcca068c76c15bc
Ruby
Tinotoin/RPS-Homework
/models/game.rb
UTF-8
866
3.296875
3
[]
no_license
class Game # Rules = { # :rock => {:rock => :draw, :paper => :paper, :scissors => :rock}, # :paper => {:rock => :paper, :paper => :draw }, # :scissors => {:rock => :rock, :paper => :scissors, :scissors => :draw} # } # end # case if def self.paper(hand1, hand2) hand1 == 'paper' if hand2 == 'rock' return...
true
89d75438dedc93a7745bafa35f329ef871406232
Ruby
Tavio/advent-of-code-2020
/8-2.rb
UTF-8
2,741
3.84375
4
[]
no_license
#!/usr/bin/env ruby class Instruction attr_accessor :name, :number, :visited def initialize(name, number) @name = name @number = number @visited = false end def visit @visited = true self end def reset @visited = false self end def run(i, acc) raise 'implemented by s...
true
87949cfadf277e73e193105e20e32ccb0a7d5037
Ruby
molotof/esearchy_mirai
/plugins/EmailEngines/bing.rb
UTF-8
2,215
2.671875
3
[]
no_license
module ESearchy module EmailEngines class Bing < ESearchy::BasePlugin include ESearchy::Helpers::Search include ESearchy::Parsers::Email ESearchy::PLUGINS[self.name.split("::")[-1].downcase] = self def initialize(options={}, &block) @info = { #This name should ...
true
fd12c967a1f292f4e481fa63f7c07f67d62eeed1
Ruby
kavunshiva/object-relations-assessment-final-web-040317
/solution.rb
UTF-8
1,426
3.328125
3
[]
no_license
class Movie attr_accessor :title ALL = [] def self.all ALL end def self.find_by_title(title) self.all.find do |movie| movie.title == title end end def initialize(title) self.title = title self.class.all << self end def ratings Rating.all.select do |rating| rati...
true
a1af6b1c993e6623d4400c88b7d833793fb9e09b
Ruby
1anchen/Sport_App
/models/game.rb
UTF-8
2,452
3.265625
3
[]
no_license
require_relative('../db/sqlrunner') require_relative('team') class Game attr_reader :id, :home_team_id, :away_team_id, :home_team_score, :away_team_score def initialize(options) @id = options["id"].to_i if options["id"] @home_team_id = options["home_team_id"].to_i @away_team_id = options["away_team_i...
true
0a465be4d397ad028d5eeb290c8302e21b961211
Ruby
wookay/da
/ruby/fun/test_hpricot.rb
UTF-8
492
3.03125
3
[]
no_license
# test_hpricot.rb # wookay.noh at gmail.com def assert_equal expected, got puts expected == got ? "passed: #{expected}" : "Assertion failed\nExpected: #{expected}\nGot: #{got}" end require 'rubygems' require 'hpricot' doc = Hpricot("<html><body>test</body></html>") assert_equal "<...
true
c51201751964df9df76c1411f69dac993caf6f74
Ruby
linhb/Recipes
/app/models/ingredient.rb
UTF-8
1,382
2.9375
3
[]
no_license
class Ingredient < ActiveRecord::Base belongs_to :recipe validates :name, :recipe_id, presence: true validates :amount, presence: true, numericality: {greater_than: 0} def self.parse(ingredient_list) ingredient_lines = ingredient_list.lines.delete_if &:empty? ingredients = [] ingredient_lines.e...
true
105f68e37d5564e107f2392abca1bf34bc3f28a4
Ruby
domitian/snake_ladder_game
/die.rb
UTF-8
123
3.125
3
[]
no_license
module Die def roll_die num = rand(1..6) puts "Die rolled,.. you got #{num}" num end end
true
9b6c5c9f16a86c777343575645ac8c3ed0906dcd
Ruby
jmschles/codeeval
/moderate/interrupted_bubble_sort.rb
UTF-8
548
3.59375
4
[]
no_license
class Array def interrupted_bubble_sort(iterations) sorted = false iterations.times do sorted = true (0..(length-2)).each do |i| if self[i] > self[i+1] sorted = false self[i], self[i+1] = self[i+1], self[i] end end break if sorted end self ...
true
b06c720f8ccae6974231e192ca91dec8dbf1f394
Ruby
realityforge/napts
/lib/text_formatter.rb
UTF-8
624
3.078125
3
[]
no_license
class TextFormatter RedClothFormat = 1 BlueClothFormat = 2 RubyPantsFormat = 3 PlainFormat = 4 TEXT_FORMAT = { "RedCloth" => RedClothFormat, "BlueCloth" => BlueClothFormat, "RubyPants" => RubyPantsFormat, "Plain" => PlainFormat }.freeze def self.format_content(format,content) case f...
true
cb9de9606f90b4f4b59e4004e78547fe14b53f14
Ruby
noahschutte/phase-0
/week-9/ruby-review-1/assert.rb
UTF-8
728
3.734375
4
[ "MIT" ]
permissive
# U2.W6: Testing Assert Statements # 1. Review the simple assert statement require_relative "ruby-review" def assert_equals actual, expected, message puts "*" * 50 puts message puts "*" * 50 puts actual == expected end name = "work" todo = reverse_words() assert_equals todo "if reverse_words includes str, retu...
true
26c39da89f7bf6735124d8c3e87fb6e5a29eb6cb
Ruby
nadavmatalon/Talent
/spec/models/developer_spec.rb
UTF-8
2,658
2.796875
3
[]
no_license
describe Developer do it 'can be created' do email, password = 'developer@test.com', 'password' expect(Developer.new(email: email, password: password, password_confirmation: password).valid?).to be true end it 'can be saved in the database' do expect(Developer.count).to eq 0 create_developer expect(Deve...
true
05d5f0db4eff7c039e5e285be7f0c33ae53902e1
Ruby
imcodingideas/learning_ruby
/day_3/basic_math_methods.rb
UTF-8
363
4
4
[]
no_license
=begin Create four methods that correspond with the 4 basic arithmetic operations: add, substract, multiply and divide. =end def add (a, b) a + b end def substract(a, b) a - b end def multiply(a, b) a * b end def divide(a, b) answer = a / b.to_f answer end # Test p add(10, 2) == 12 p substract(10, 2) == 8 p m...
true
281b10c5f8102f5fcd74b0182bb984be7d1790e1
Ruby
edgarmsilva/UnitTests
/temperature/temperature.rb
UTF-8
582
4.21875
4
[]
no_license
class Temperature C = 'celsius'.freeze F = 'fahrenheit'.freeze K = 'kelvin'.freeze def initialize(value, unit) @value = value @unit = unit end def to_fahrenheit to_celsius * (9 / 5.0) + 32 end def to_celsius case @unit ...
true
7664652d67b717eac53c92766fc5072234d52268
Ruby
newmanbradm/the-bachelor-todo-nyc-web-060418
/lib/bachelor.rb
UTF-8
1,219
3.578125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def get_first_name_of_season_winner(data, season) data[season].each do |contestant| if contestant["status"] == "Winner" return contestant["name"].split(" ").first end end end def get_contestant_name(data, occupation) data.each do |season, contestants| contestants.each do |contestant_hash| ...
true
1355fdfdcc41fb0e5102a9b8dcd0473534399983
Ruby
haijin-development/ruby-sirens
/lib/sirens/models/icons.rb
UTF-8
736
2.546875
3
[]
no_license
require 'pathname' module Sirens class Icons def self.icons() @icons ||= Hash[ ::Module => 'module.png', ::Class => 'class.png', ::Array => 'array.png', ::Hash => 'hash.png', ::TrueClass => 'true.png', ...
true
4e965c5e83675a94ffc1c5f4d61876fc23382628
Ruby
renatobiohazard/TADS2014
/2014.2/Lista Ruby Primeiro semestre/Lista 00/questao5.rb
UTF-8
40
2.78125
3
[]
no_license
nome=gets.chomp puts nome puts nome.size
true
2da1bf9343fea19e46485b852bef3470dbfe606f
Ruby
DanielaCarvajal/ttt-6-position-taken-rb-v-000
/lib/position_taken.rb
UTF-8
657
3.28125
3
[]
no_license
#def position_taken?(board,index) # if index == " " # return false # elsif index == "" # return false # elsif index == "X" # return true # elsif index == "O" # return true # else return false #end #end #def position_taken?(board, index) #return false if position_taken?(index == " ") #return fal...
true
69e8392c23aedaf4da212f86a2d53546d0b03832
Ruby
puppetlabs/puppetlabs-stdlib
/lib/puppet/parser/functions/base64.rb
UTF-8
2,770
3.0625
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. module Puppet::Parser::Functions newfunction(:base64...
true
42f0e4e026e6b4b0a8bbf614db73414442e8e8dd
Ruby
geeksam/todo_case_app
/features/step_definitions/pending_steps.rb
UTF-8
2,653
2.90625
3
[]
no_license
When /^I "(.*?)"$/ do |arg1| pending # express the regexp above with the code you wish you had end When /^I choose to create a new todo list$/ do pending # express the regexp above with the code you wish you had end Then /^the system asks me what I want to call the new todo list$/ do pending # express the regex...
true
38f46ab0f73f93f0ea6260b05a2810620ae33acb
Ruby
geoffwv/oo-basics-online-web-ft-100719
/lib/shoe.rb
UTF-8
375
3.75
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Make your shoe class here! class Shoe #Create Arrtibute accessors attr_accessor :brand, :color, :size, :material, :condition #Define the initialize method def initialize(brand) @brand = brand end #Define the cobble method and change shoe condition(instance variable) def cobble puts "Your shoe...
true
031d5d237d66513c2ba0b708df10afc995b46beb
Ruby
imajes/filmshoots.nyc
/app/services/import_company_service.rb
UTF-8
1,098
2.859375
3
[ "MIT" ]
permissive
class ImportCompanyService attr_reader :company, :proposed_name def initialize(name) @proposed_name = name end def process! company.name = @proposed_name if company.name.blank? company.original_names = @proposed_name company.save end def company @company ||= Company.where(commo...
true
fc875e21032f4d5f3bb162562fb81032061d0c56
Ruby
prasantahalder2013/robot-ruby
/lib/simulator.rb
UTF-8
1,485
3.515625
4
[]
no_license
require 'table_surface' require 'robot' class Simulator def initialize @table = TableSurface.new() @robot = Robot.new(0,0,:east) end def execute(command, params) execute_command(command, params) end def execute_command(command, params) case command when 'place' place(params) ...
true
07c35ca5bf3ca285f5d5ade3e68f00f8717c6e75
Ruby
axadn/app-academy-projects
/W5D1/goal_proj/spec/models/user_spec.rb
UTF-8
2,301
2.59375
3
[]
no_license
require 'rails_helper' RSpec.describe User, type: :model do it {should validate_presence_of(:username)} it {should validate_presence_of(:password_digest)} it {should validate_length_of(:password).is_at_least(6)} # subject(:laura) {User.new(username: "Laura", password: "croft123")} describe "#is_password?" d...
true
9e3d43918f467026e98309193ce167c3eeda00e8
Ruby
brunasdejesus/Automation_Pratice
/features/pages/login_page.rb
UTF-8
1,085
2.5625
3
[]
no_license
module Pages class LoginPage < SitePrism::Page # Está herdando os métodos de SitePrism::Page set_url '/index.php?controller=authentication&back=my-account' # O usuário está sendo direcionado para a URL passada no documento env.rb (Vou explicar melhor quando falar desse documento) ...
true
12f0d1a392a0cec265a8f3f4f8aa7e3707ceef63
Ruby
haldarmahesh/calculator
/spec/Calculate/calculator_spec.rb
UTF-8
891
2.703125
3
[]
no_license
require 'spec_helper' describe 'Calculator' do let(:num1) {Calculator.new()} let(:num2) {Calculator.new(-5)} let(:num3) {Calculator.new(4)} let(:num4) {Calculator.new(8)} it 'add number' do expect(num1.add(5)).to eq(5) end it 'subtract number' do expect(num1.subtract(2)).to eq(-2) end it...
true
5e05e1f6250a5d628f66c4295974ebd60e7e33bf
Ruby
apperen/NPDV-1
/lessons1-7/lesson7/cycles.rb
UTF-8
1,320
3.796875
4
[]
no_license
# encoding: utf-8 # объявляем переменную и задаем начальное значение. Попробуйте удалить эту строку и выполнить # программу. count = 1 while count <= 5 do puts count count += 1 # операция += означает "прибавить единицу" к текущему значению count sleep 0.5 # театральная пауза после каждого слова :) end puts "я ...
true
f3d485a713cd5363967ba3ae3eed43c1821c962b
Ruby
crguezl/goog_currency_tutorial
/lib/goog_currency.rb
UTF-8
1,174
2.96875
3
[]
no_license
require "rest_client" require "json" require "pp" module GoogCurrency def self.method_missing(meth, *args) puts "Method missinf: #{meth}" pp args from, to = meth.to_s.split("_to_") puts "from =#{from} to=#{to}" super(meth, *args) and return if from.nil? or from == "" or to.nil? or to == "" ...
true
9f761b6bcd79ef26cd9902327cff9431deaed8ef
Ruby
Scalarm/scalarm_experiment_manager
/test/integration/experiment_auto_convert_test.rb
UTF-8
4,209
2.859375
3
[ "MIT" ]
permissive
require 'csv' require 'minitest/autorun' require 'test_helper' require 'mocha/test_unit' require 'db_helper' class ExperimentAutoConvertTest < MiniTest::Test include DBHelper def setup super end def teardown super end def create_experiment(factory_method) user_id = ScalarmUser.new(login: 'te...
true
d93c021c9d437d66bf69da06c4c8392d34b7cb06
Ruby
mwagner19446/wdi_work
/w03/d03/Sandy/superhero/superhero_pg.rb
UTF-8
2,130
3.53125
4
[]
no_license
require 'pg' db_conn = PG.connect( :dbname => 'super', :host => 'localhost' ) puts <<PROMPT What would you like to do? (I) Index - List all Super Heros (C) Add a Super Hero (R) View all info for a specific Super Hero (U) Update a Super Hero (D) Remove a Super Hero PROMPT answer = gets.chomp.downcase case answer wh...
true
1b9b7228d297b9dadb8144e7afbd99d5d0f1b53e
Ruby
DFID/devtracker-from-api
/helpers/formatters.rb
UTF-8
1,630
3.046875
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
#require "kramdown" require 'uri' module Formatters def format_million_stg(v) "&pound;#{(v/1000000.0).round(1)}m" end def format_round_million(v) "#{(v/1000000.0).round(2)} million" end def format_round_m(v) "#{(v/1000000.0).round(1)}m" end def format_billion_stg(v) "&pound;#{(v/100...
true
d48c0f0ed59e90ef204fca4ef54c406f88c4d8de
Ruby
crushlovely/acts_as_toggleable
/lib/acts_as_toggleable/active_record/acts/toggleable.rb
UTF-8
2,189
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module ActiveRecord module Acts module Toggleable extend ActiveSupport::Concern included do extend ClassMethods end module ClassMethods # Public: Create a toggleable attribute on the model. # # toggleable_attribute - A symbol representing the name of the a...
true
27ca84642ede1cbb778302f47258700531f5b7f9
Ruby
daisukesone/Atcoder
/187/large_digits.rb
UTF-8
133
3.390625
3
[]
no_license
a,b = gets.split(" ") a_sum = a.chars.map(&:to_i).sum b_sum = b.chars.map(&:to_i).sum if a_sum > b_sum p a_sum else p b_sum end
true
75c3bbfef09b428e243aaabf97fd323dfea0451a
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/hamming/b1f62fe935fa44e496848403cb4fe2a2.rb
UTF-8
248
3.578125
4
[]
no_license
class Hamming def self.compute(strand_one, strand_two) strand_one.chars.zip(strand_two.chars).count do |one, two| self.matches?(one, two) end end private def self.matches?(one, two) (one != two) && (two !=nil) end end
true
8f10de5759151faa5c5033f8b41ed72bccb0c30d
Ruby
saman-zdf/weight_calorie-tracker
/src/calorie_recorder.rb
UTF-8
3,941
3.71875
4
[]
no_license
require_relative "sign_up.rb" require_relative "bmi.rb" require_relative "api.rb" require 'colorize' require 'tty-prompt' require 'terminal-table' require 'json' # create a class to get a user name, and data of food and calorie antake class Calorierecorder # use attr_reader to be able to read the name attr_reader...
true
39f55a0104d45b5b9fdb7fc2557def18f37a0f14
Ruby
lachie/numbr5
/lib/numbr5.rb
UTF-8
11,408
2.578125
3
[]
no_license
require 'rubygems' require 'metaid' require 'rice/irc' require 'rice/observer' require 'pp' require File.dirname(__FILE__)+'/seer' BYEBYE = 'byebye > ' class RICE::Message def nick prefix ? prefix.scan(/^[^!]+/o)[0] : nil end end module Numbr5 Thread.abort_on_exception = true def self.root @root...
true
e497bd0c2b81f3b9fc9b64a04fce176fcf48c122
Ruby
natydev/municipitaly
/spec/municipitaly/search_spec.rb
UTF-8
11,626
2.609375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'municipitaly/search' RSpec.describe Municipitaly::Search do context '.zone_from_code' do context 'with an existant param zone code' do it 'returns a Zone object' do expect(described_class.zone_from_code('5')) .to be_kind_of(Municipitaly::Zone) ...
true
a8e914dfc5b4c6520c9aeb334db183ea5f90a135
Ruby
zoomix/yobot
/lib/yobot/behaviors/cowsay.rb
UTF-8
290
2.65625
3
[]
no_license
class Yobot::Behaviors::Cowsay def describe '- I can let the cow say what you mean. Go mrdata, cowsay dude!'.to_s end def react(room, message) return room.paste(%x(cowsay #{$1})) {} if message.match(/^cowsay (.+)/i) # room.text('pong') {} if message == 'ping' end end
true
15e18f533d3d4b1fd1949da4519e352dd15b6e59
Ruby
aygh0914/AC
/ABC016/B.rb
UTF-8
206
3.3125
3
[]
no_license
A, B, C = gets.split.map(& :to_i) if A + B == C if A == 0 or B == 0 puts "?" else puts "+" end elsif A - B == C if A == 0 or B == 0 puts "?" else puts "-" end else puts "!" end
true
62e511f6a271f8b1063b26e1b76edd57c7f07ef1
Ruby
orangejulius/followermaze
/src/sequencer.rb
UTF-8
453
3.296875
3
[]
no_license
class Sequencer def initialize(destination) @destination = destination # while not a queue in a data structure sense, # this is where events are queued up to be sent @queue = {} @next_sequence = 1 end def send_event(event) @queue[event.sequence] = event flush end private def f...
true
07f8bd5dfd463a117b110e427cd2f40096a38ff5
Ruby
mozg1984/eva-lang
/spec/self_eval_spec.rb
UTF-8
669
2.6875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'eva' require 'parser/EvaParser' RSpec.describe Eva do subject(:eva_machine) { Eva.new } describe '#eval with self eval expression' do context 'when no expression' do let(:expr) { nil } it 'raises error' do expect { eva_machine.eval(expr) }.to raise_...
true
8fecc8a8856df41428f8cb81793302d2b508cfae
Ruby
dlee16/oxford-comma-nyc-web-career-021819
/lib/oxford_comma.rb
UTF-8
205
3.1875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def oxford_comma(array) if array.length ==1 return array.join elsif array.length ==2 return array.join(" and ") else array.length >= 3 return array[0..-2].join(", ") + ", and " + array.last end end
true
ed258419e2285339951d8970cb172c2ba2e1ddfa
Ruby
iande/code_bucket
/fixnum_extensions.rb
UTF-8
247
3.03125
3
[ "Apache-2.0" ]
permissive
module FixnumExtensions # Returns [x, y] such that x and y are solutions to: # self * x + b * y = self.gcd(b) def extended_gcd(b) return [0, 1] if self % b == 0 x, y = b.extended_gcd(self % b) [y, x - y * (self / b)] end end
true
a7a4e1865ecd1cb2e3dd001f487bbac82fd2e5cc
Ruby
bibstha/advent2019
/day10/soln_test.rb
UTF-8
4,882
3.3125
3
[]
no_license
require 'minitest/autorun' max_x = 10 max_y = 10 base = [1, 1] dst = [4, 5] class AstroidBelt attr_reader :visible_counts def initialize(input) @coordinates = [] input.map.with_index do |line, y| line.chars.each_with_index do |c, x| @coordinates << [x, y] if c == '#' end end ...
true
462ac9f9e55ea3d22079fee64da2f194f2b6f0a1
Ruby
aduane/gphotos-metadata-restorer
/restore.rb
UTF-8
6,616
2.78125
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
def fix_file_metadata(file, metadata_file) # now that we've identified the correct metadata file, we should read the # data from it and ensure the correct tags are set on the file. end Dir.glob('/Users/personal/Downloads/photos/Takeout/Google Photos/*').select {|f| File.directory? f}.each do |photo_directory| D...
true
504f1f4bad460dc83a4b28e51899f11a7f12c15c
Ruby
dougbradbury/asteroid_sparring
/lib/collision.rb
UTF-8
860
3.03125
3
[]
no_license
module Collision ELASTICITY = 1 def collided?(vessel1, vessel2) dx = vessel1.position[0] - vessel2.position[0] dy = vessel1.position[1] - vessel2.position[1] distance = Math.sqrt(dx*dx + dy*dy) distance <= (vessel1.radius + vessel2.radius) end def collide(vessel1, vessel2) normal = (vessel...
true
2939194d3a5f98f627abe1e023ab33d9a59049f4
Ruby
rpanachi/core_ext
/test/core_ext/duration_test.rb
UTF-8
6,908
2.875
3
[ "Ruby", "MIT" ]
permissive
require 'abstract_unit' require 'core_ext/inflector' require 'core_ext/time' require 'core_ext/json' require 'time_zone_test_helpers' class DurationTest < CoreExt::TestCase include TimeZoneTestHelpers def test_is_a d = 1.day assert d.is_a?(CoreExt::Duration) assert_kind_of CoreExt::Duration, d ass...
true
18bb4d8e00d5d598ea56e2e26607a3a3148f37cb
Ruby
shkfnly/rubybuildingblocks
/bubblesort.rb
UTF-8
749
3.28125
3
[]
no_license
def bubblesort(array) switches = 1 while switches != 0 switches = 0 for number in (0...array.length) if (array[number] <=> array[number+1]) == 1 placeholder = array[number] array[number] = array[number+1] array[number+1] = placeholder switches += 1 end end e...
true
ac99d0fb0f95feccccf6f2304ef72aaf73868dd8
Ruby
zawsx/app-civic-whichbus
/lib/api.rb
UTF-8
1,223
2.703125
3
[ "MIT" ]
permissive
require 'open-uri' require 'cgi' module API @data_count = 0 def get_json(url, verbose=true) @data_count += 1 puts "JSON REQUEST #{@data_count}: #{url}" if verbose JSON.parse(open(url, 'Content-Type' => 'application/json').read) end def open_trip_planner(method, params) method = "transit/#{method}" unles...
true
c78e099438cc449e08eb639ead79f2b7b43ef2f3
Ruby
BloomAndWild/royal_mail_api
/lib/royal_mail_api/xml_builder.rb
UTF-8
960
2.640625
3
[ "MIT" ]
permissive
require 'erb' require 'ostruct' class XmlBuilder < OpenStruct attr_reader :request, :type SPECIAL_CHARACTER_MAP = { '"' => "&quot;", "&" => "&amp;", "'" => "&apos;", "<" => "&lt;", ">" => "&gt;" } def initialize(request, attrs={}, type='shipping') @request = request @type = type ...
true
cf7713cf8529b2a6f64d622f151126c44f1e3916
Ruby
Kinselan/learn-to-program
/hash/ex5.rb
UTF-8
216
3.375
3
[]
no_license
# Exercise 5 # What method could you use to find out # if a hash contains a specific value in it? hash1 = { key1: "value1", key2: "value2", key3: "value3" } p hash1.has_value?("value3")
true
2e890bd25e77af920a278f808c8fd6440e728556
Ruby
daydreamboy/HelloRuby
/ruby_task/12_folder-batch-rename.rb
UTF-8
2,611
3.109375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby #encoding: utf-8 require 'optparse' require_relative '../ruby_tool/log_tool' class Subcommand_rename @@options = {} def self.create_subcommand return OptionParser.new do |opts| opts.banner = "Usage: rename [options] -p 'pattern' -o 'new_folder' path/to/folder" opts.separator...
true
332da895dd48b0a7510bc6afd05977a438b62c3c
Ruby
siryu-saito/Udemy_Study_Ruby
/if_animal.rb
UTF-8
155
3.453125
3
[]
no_license
animal = 'tomato' if animal == 'cat' puts 'meow' elsif animal == 'dog' puts 'bowwow' elsif animal == 'cow' puts 'moomoo' else puts 'Not found' end
true
c4d4b26bb173c029bb76c6ea054717249abe3bd7
Ruby
rhtaylor/ruby-music-library-cli-online-web-pt-071519
/lib/artist.rb
UTF-8
1,193
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative "./song.rb" require_relative "./genre.rb" require_relative "./concerns/module.rb" require 'pry' class Artist @@all = [] attr_accessor :name, :song, :songs, :artist extend Concerns::Findable def initialize(name, song = nil, genre = nil) #@@all << self @song = song @songs = [] @name = n...
true
7b5cdac462142c41f134b34c400a3c50a6c3d555
Ruby
phrodod/stepic
/find_approximate_matches.rb
UTF-8
698
3.03125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require_relative 'dna' require_relative 'stepic' content = <<-END_SAMPLE Sample Input: ATTCTGGA CGCCCGAATCCAGAACGCATTCCCATATTTCGGGACCACTGGCCTCCACGGTACGGACGTCAATCAAAT 3 Sample Output: 6 7 26 27 END_SAMPLE if ARGV.length > 0 content = File.open(ARGV[0], 'r').read end stepic ...
true
77de39265fa54ea4849c2146faf6a9e60112a7bc
Ruby
azgul/adventofcode-solutions
/12/js_abacus_framework_io.rb
UTF-8
2,239
3.65625
4
[]
no_license
#!/usr/bin/env ruby require 'json' TESTS_PART_ONE = [ { assertion: '[1,2,3] and {"a":2,"b":4} both have a sum of 6.', input: ['[1,2,3]', '{"a":2,"b":4}'], sum: 6 }, { assertion: '[[[3]]] and {"a":{"b":4},"c":-1} both have a sum of 3.', input: ['[[[3]]]', '{"a":{"b":4},"c":-1}'], sum: 3 ...
true
f5ebdf9f9706b12b133dba010143bb63592a7967
Ruby
smdecker/my-each-v-000
/my_each.rb
UTF-8
162
3.5625
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def my_each(array) i = 0 while i < array.length yield (array[i]) i = i + 1 end array end array = [] my_each(array) do |word| word end
true
a3b3b209eb7f36bb38eee371d3ffb98a6528d87f
Ruby
Greutz/Exos
/exo_17.rb
UTF-8
295
3.578125
4
[]
no_license
puts "Donne ton age stp" print "> " age = gets.chomp.to_i naiss = 0 age.times do naiss += 1 age -= 1 if age == naiss puts "il y'a #{age} ans tu avais la moitié de l'age que tu as aujourd'hui" else puts "Il y a #{age.to_s} ans tu avais #{naiss.to_s} ans" end end
true
c405bdf7267d6d02da2032c8b17e57bd9500d62e
Ruby
enowmbi/algorithms
/running_sum_of_1d_array.rb
UTF-8
389
3.3125
3
[]
no_license
# @param {Integer[]} nums # @return {Integer[]} def running_sum(nums) new_nums = [] new_nums << nums.first pointer1 = 0 pointer2 = 1 while(pointer2 < nums.length) if new_nums.empty? new_nums << nums[pointer1] else sum = new_nums[pointer1] + nums[pointer2] new_nums << sum poi...
true
deb114955c67e118aa4cc015e9c81ae81abdc541
Ruby
tivikv/task__one
/weight_perfect.rb
UTF-8
319
3.171875
3
[]
no_license
puts 'Введите ваше имя' name = gets.chomp puts 'Укажите ваш рост' tall = gets.chomp weight_perfect = (tall.to_i - 110.0)*1.15 if weight_perfect < 0 puts "#{name}, Ваш вес уже оптимальный" else puts "#{name}, Ваш вес идеальный" end
true
01adcdc3dc4b61b6726bfde32785f28f2ba384e0
Ruby
emrancub/Basic-Ruby-Programming-Practice
/chapter_6/variable.rb
UTF-8
66
2.75
3
[]
no_license
def basic_method puts $x end $x = 10 basic_method puts $x
true
0bb2cb3ce29b9e1130939fcb1d0df5da0121ef86
Ruby
KingCyrus/ttt-3-display_board-example-bootcamp-prep-000
/lib/display_board.rb
UTF-8
223
3.09375
3
[]
no_license
# Define a method display_board that prints a 3x3 Tic Tac Toe Board def display_board a = " " puts a+"|"+a+"|"+a puts (print "-----------") puts a+"|"+a+"|"+a puts (print "-----------") puts a+"|"+a+"|"+a end
true
aaea76a03e9a85fffde42bb57d082c791af9413b
Ruby
albertjou/ballin-octo-happiness
/Week1/Lab3.rb
UTF-8
249
4.4375
4
[]
no_license
puts "What is 2 to the 16th power?" answer = gets.chomp.to_i while (answer != 2 ** 16) puts "Sorry that's not the correct answer" puts (answer < 2** 16) ? "Go Higher" : "Go Lower" answer = gets.chomp.to_i end puts "Well done, you got it right"
true
88382015719cfc4a36e8d78b801ae261bf8f3cf2
Ruby
geraldb/geraldb.github.io
/old_webby_sites/rubybook/lib/finder.rb
UTF-8
1,107
2.875
3
[]
no_license
def is_article?( page ) # only postings in top-level (exclude index, tags and feed page) are articles page.dir.empty? && page.ext == 'txt' && !(['index', 'tags', 'feed'].include? page.name) end def find_articles( opts = {} ) articles = Webby::Resources.pages.find(:all, opts) do |page| # puts...
true
496d5cdbd9482b70821ec3fbc6dd1e46d8b27faf
Ruby
AnnaAleynik/Shop
/Test.rb
UTF-8
130
3.328125
3
[]
no_license
# n class Test def initialize (num = 10) @num = num end def num @num end end test = Test.new(20) puts test.num
true
26e03ec2b3a06ed9bb586d658c452169bebc2e19
Ruby
unlimitedfocus/rubylearning_class
/7_week/3e_month_days.rb
UTF-8
330
4.375
4
[]
no_license
# Exercise3. Write a method called month_days, that determines the number of days in a month. Usage: days = month_days(5) # 31 (May) days = month_days(2, 2000) # 29 (February 2000) # Remember, you could use the Date class here. Read the online documentation for the Date class. You must account for leap years in this ...
true
b72c41be0aa590b0140d7535ffb3e28ba5d97a0f
Ruby
Brunomm/br_boleto
/test/br_boleto/calculos/fator_vencimento_test.rb
UTF-8
2,103
2.8125
3
[ "MIT" ]
permissive
# encoding: utf-8 require 'test_helper' describe BrBoleto::Calculos::FatorVencimento do describe "#base_date" do it "should be 1997-10-07" do BrBoleto::Calculos::FatorVencimento.new(Date.parse("2012-02-01")).base_date.must_equal Date.new(1997, 10, 7) end end describe "#calculate" do it 'should return an e...
true
7e43765040f0840c3d0b285b96a4b54fb02eeea6
Ruby
bibio/algo-ruby
/test_bellmanford.rb
UTF-8
1,592
3
3
[]
no_license
require 'test/unit' require 'bellmanford' class TC_BellmanFord < Test::Unit::TestCase def setup end # testdata # 2 # >a---b* # def test_twonode nodes = %w(a b).map { |l| BellmanFord::Node.new(l) } edges = [[0,1,2]].map { |l| BellmanFord::Edge.new(nodes[l[0]],nodes[l[1]],l[2]) } bf = Bellman...
true
2d3d2b8cf505842b97d137f27b45b6985c8d90bf
Ruby
xiuxian123/loyals
/projects/mustache_render/lib/mustache_render/mustache/data.rb
UTF-8
4,517
2.734375
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- module MustacheRender class Mustache::Data < ::Hash def initialize(options={}) self.merge! options end [:render, :file_render, :impl_render].each do |method_name| define_method method_name do |path_or_template| ::MustacheRender::Mustache.send method_name, pa...
true
fe199815a42a97f3ecd239e314d116f3259a4751
Ruby
dengsauve/text-to-html
/lib/text-to-html/html_table.rb
UTF-8
619
2.96875
3
[]
no_license
# function: pulls text w/line breaks from clipboard, adds <p></p> to line breaks, and puts back on clipboard verbose = ARGV.include?("-v") raw_in = `pbpaste`.gsub("\r", '').gsub("\"", '').split("\n") puts raw_in.inspect if verbose p_string = "" raw_in.each do | line | #p_string << "<p>\n\t#{line}\n</p>\n" if line...
true
c1e9593573de835708258829ac8707cfac6e2ba7
Ruby
PhilHuangSW/Leetcode
/unique_paths_iii.rb
UTF-8
2,523
3.84375
4
[]
no_license
#################### UNIQUE PATHS III #################### # On a 2-dimensional grid, there are 4 types of squares: # - 1 represents the starting square. There is exactly one starting square. # - 2 represents the ending square. There is exactly one ending square. # - 0 represents empty squares we can walk over. # -...
true
037c74e9e907668816486d3b33da64c2bf093bf0
Ruby
gb-archive/gbtiles
/lib/gbtiles/gbt/import/mod_file.rb
UTF-8
1,877
2.671875
3
[ "MIT" ]
permissive
require "gbtiles/helpers/fixnum" require "gbtiles/gbt/mod_data/mod_data" require "gbtiles/gbt/mod_data/sample" require "gbtiles/gbt/mod_data/pattern" module GBTiles module GBT module Import class MODFile attr_accessor :mod_data def initialize @mod_data = GBTiles::GBT::MODData::...
true
d15518f993538156d0919872ee0fb24dcaac96b3
Ruby
hrodz13/circuit-oneops-1
/components/cookbooks/presto-coordinator-v1/recipes/coordinator_helper.rb
UTF-8
2,514
2.71875
3
[]
no_license
# coordinator_helper - Library functions # # These functions contain logic that is shared across multiple components. # Parse the ciName to extract the cloud ID from it # # INPUT: # ciName: The CI name to parse # # RETURNS: # A string containing the numeric cloud ID, or '' if no # name was specified # def cloudid_from...
true
9cc46dd2c537ab018ab2620d20a3d4dc162edfbe
Ruby
nguyenthanhhoan/demeter
/app/services/speed_sms_service.rb
UTF-8
702
2.59375
3
[]
no_license
class SpeedSMSService # Send messsage to phone number via SpeedSMS API # Get user detail by curl # curl -i -u "{API access token}:x" "http://api.speedsms.vn/index.php/user/info" def send_message(message, phones) require 'rest-client' url = "http://api.speedsms.vn/index.php/sms/send" token = ENV['sp...
true
50f9bec50dd7e6b3d6613d643689e7e3202cd691
Ruby
Myagami/SimuTools
/BaseCreate/BoxCreate.rb
UTF-8
877
2.9375
3
[]
no_license
#!/usr/bin/env ruby require 'rmagick' require 'optparse' class BoxCreate @@Image_Ins def initialize(tx,ty,sc) @@Image_Ins = Magick::Image.new(tx.to_i*sc.to_i , ty.to_i * sc.to_i){ self.background_color = '#e7ffff' } end def CreateBox(file) @@Image_Ins.write(file)...
true
8e8bb912404959b0058285f76145b5116daa832b
Ruby
epfl-lasa/TutorialICRA2019.io
/vendor/ruby/2.3.0/gems/POpen4-0.1.4/tests/popen4_test.rb
UTF-8
2,029
2.640625
3
[ "GPL-2.0-only", "Ruby", "Unlicense" ]
permissive
$: << File.join( File.dirname( __FILE__ ), '../lib/') require 'test/unit' require 'popen4' require 'platform' class POpen4Test < Test::Unit::TestCase case Platform::OS when :win32 CMD_SHELL = "cmd" CMD_STDERR = "ruby -e \"$stderr.puts 'ruby'\"" CMD_EXIT = "ruby -e \"$stdout.puts ...
true
3b5572e626524a5c17fbd27cd19be0d1cd24518a
Ruby
lkaatz99/Answers
/Question4.rb
UTF-8
836
3.984375
4
[]
no_license
class Question4 attr_accessor :primeIndex # Create object def initialize(index = 0) @primeIndex = index end # Get prime number for given index def GetPrimeNumber @num = 0 @index = 1 #puts "index #{@primeIndex}" while @index <= @primeIndex do @num += ...
true
de59cb4a8cf0268e306525f7b3c3f81c96dab637
Ruby
BendingSpoons/fastlane
/fastlane_core/spec/queue_worker_spec.rb
UTF-8
1,501
2.71875
3
[ "MIT" ]
permissive
describe FastlaneCore::QueueWorker do describe '#new' do it 'should initialize an instance' do expect(described_class.new { |_| }).to be_kind_of(described_class) expect(described_class.new(1) { |_| }).to be_kind_of(described_class) end end describe '#enqueue' do subject { described_class....
true
4e251a27d90f162cf0eae075c36749b398f2eabf
Ruby
minhtule/dotfiles-public
/bootstrap.rb
UTF-8
2,947
2.84375
3
[]
no_license
#!/usr/bin/ruby require 'rubygems' require 'erb' require 'ostruct' require 'fileutils' require 'yaml' require 'inquirer' DEFAULTS = File.exist?("defaults.yml") ? YAML::load_file("defaults.yml") : {} def run(cmd) puts "[Running] #{cmd}" `#{cmd}` unless ENV['DEBUG'] end def install puts "======================...
true
d1a838a499cbd1b98bac4b1d4e9a2fdfaf51f877
Ruby
DalavanCloud/cts-mpx
/lib/cts/mpx/driver/assemblers.rb
UTF-8
3,766
2.5625
3
[ "Apache-2.0" ]
permissive
module Cts module Mpx module Driver # # collection of methods used to assemble various parts of a request. # module Assemblers module_function # assembles user service and account_id into a host string # @param [Cts::Mpx::User] user user to make calls with ...
true
138071923bb01bd2c46fba8a54995947490c4c76
Ruby
emmett-walsh/advent-of-code
/2017/lib/inverse_captcha.rb
UTF-8
813
3.765625
4
[]
no_license
class InverseCaptcha def consecutive_sum(captcha) determine_consecutive_digits(captcha) end def halfway_sum(captcha) determine_midpoint_matching_digits(captcha) end private def determine_consecutive_digits(captcha) subtotal = 0 previous_number = captcha[-1] captcha.each_char do |numbe...
true
da91ac655ed9b9151e4818d9184c05ae0a2c4b68
Ruby
LeeTigges/LS_ruby
/rb100/ruby_basics_exercises/breakfast_lunch_or_dinner1.rb
UTF-8
199
3.546875
4
[]
no_license
def count_sheep 5.times do |sheep| puts sheep if sheep >= 2 return end end end p count_sheep def tricky_number if true number = 1 else 2 end end p tricky_number
true
1134b03234bb5bc5d5227419fb5336ed50e27066
Ruby
AprilArcus/prep-work
/coding-test-2/practice-problems/lib/02_letter_count.rb
UTF-8
170
3.25
3
[]
no_license
def letter_count(str) str.delete(' ').chars.inject({}) do |result, char| if result.include?char result[char] += 1 else result[char] = 1 end result end end
true
f4ed09e87d61991b2bb6efb9b3f6523a3fcc3691
Ruby
bdphilly/chess
/board.rb
UTF-8
3,412
3.640625
4
[]
no_license
require_relative "./pieces.rb" class Board attr_accessor :board def initialize @board = Array.new(8) { Array.new([]) * 8 } self.generate_board end class EmptyTile attr_accessor :display def initialize(pos) (pos.first + pos.last).even? ? self.display = "\u2b1c" : self.display = "\u2b1b...
true
0a74bb498c6e9432818503c3c13010bb546263a6
Ruby
Vaxied/Mastermind
/player.rb
UTF-8
1,385
3.71875
4
[]
no_license
# require_relative 'game' module Mastermind # class for player(s) class Player attr_accessor :name, :points # Variable for managing the state of the computer @comp = nil class << self attr_accessor :comp end def initialize(input) @name = input[:name] @points = 0 end ...
true
94039f53545f4220adad0ce1a1b466c52f4a7054
Ruby
traviswalkerdev/launch-school-ruby-basics
/returns/ex7.rb
UTF-8
237
3.84375
4
[]
no_license
def count_sheep 5.times do |sheep| puts sheep end end puts count_sheep # prints 0, 1, 2, 3, 4, 5 # 0-4 come from the .times block running # .times block returns the initial integer so 5 is the # return value from count_sheep
true
a0a8e0967db7bf26ed960e13c9ad697c1172ce74
Ruby
dddttt/temp
/1-week/3-day/hash.rb
UTF-8
1,049
3.21875
3
[]
no_license
song_title = 'Hello' song_artist = 'lionel richie' song_released = 1983 song = ['hello', 'lionel richie', 1983] song = { 'title' => 'hello', 'artist' => 'lionel richie', 'released' => 1983 } song = { 0 => 'hello', 1 => 'lionel richie', 2 => 1983 } :who_am_i.class "who_am_i".class :who_am_i.object_id "who_am_i"....
true
f37092342895d95c851fe86e12aca630ea65d842
Ruby
kkuchta/bub_bot
/lib/bub_bot/slack/command.rb
UTF-8
2,304
3.109375
3
[ "MIT" ]
permissive
require 'bub_bot/server_manager.rb' require 'bub_bot/deploy_manager.rb' require 'slack-ruby-client' class BubBot::Slack::Command def self.can_handle?(command) aliases.include?(command) end def self.aliases # Guess the command name from the class name [self.name.demodulize.downcase] end def init...
true
819a1b892295e9c91a2fdefc246f3b958d7db634
Ruby
rsdelhi91/Ruby-on-Rails-News-Articles-Digest
/706453-project-2/app/controllers/users_controller.rb
UTF-8
2,547
2.6875
3
[]
no_license
# This controller is used to manage the user, like creating a user, updating their # details, and destroying a users profile. We set the authentication required to # perform edit, update and show on a users profile here. # # Author:: Rahul Sharma (Student No: 706453, student ID: sharma1) # class UsersController < App...
true
5bcd9807e9d02cc18a9a7a4b1a0722999ee41596
Ruby
john19840502/CTM-Web
/lib/docmagic/filter.rb
UTF-8
383
2.609375
3
[]
no_license
module DocMagic class Filter def self.by_most_recent_package_version listing_array listing_array.select{|listing| is_latest_for_loan?(listing, listing_array)} end private def self.is_latest_for_loan? listing, listing_array listing_array.select{|l| l.loan_number == listing.loan_number &...
true
cd6220389dbc8d9d888709a2152c183e9ccb0efd
Ruby
nakakou0703/furima-34877-
/spec/models/item_spec.rb
UTF-8
3,664
2.53125
3
[]
no_license
require 'rails_helper' RSpec.describe Item, type: :model do before do @item = FactoryBot.build(:item) end describe '商品情報登録' do context '商品情報登録ができる時' do it "image,name,text,category_id,condition_id,charge_id,source_id,ship_day_id,priceが記入されていれば登録できる" do expect(@item).to be_valid end ...
true
4a85d95baaa55ac936219fd772f0c0462b3bd129
Ruby
Team-Delta/GitMyCurriculum
/app/controllers/concerns/git_functionality/repo.rb
UTF-8
513
2.703125
3
[]
no_license
module GitFunctionality # Manages repos for git funcitonality class Repo # load the bare curriculum # # +curriculum+:: curriculum object def get_bare_repo(curriculum) path = ::GitFunctionality::Path.new.get_bare_path(curriculum) Git.bare(path) end # load working curriculum #...
true
ef96b6cedededbedba334246828194f0dbdec40f
Ruby
anubiskhan/refactor-test
/lib/boat.rb
UTF-8
236
2.96875
3
[]
no_license
require './lib/engine' class Boat def initialize @motor_1 = Engine.new @motor_2 = Engine.new end def start @motor_1.start @motor_2.start end def running? @motor_1.running? && @motor_2.running? end end
true
e47f0afa2befde15706e8c403e8d493c4892a074
Ruby
travisbm/battleship_2.0
/app/models/game.rb
UTF-8
2,821
3.265625
3
[]
no_license
class Game < ActiveRecord::Base serialize :game_board, Array serialize :ship_count, Array before_create :init ARRAY_SIZE = 10 NUM_SHOTS = 50 SCORE_HIT = 500 SCORE_MISS = 50 OPEN = "open" HIT = "hit" MISS = "miss" BOAT = Boat.new VESSEL = Vessel.new CARRI...
true
f291f31a146dda970dbdb69eeb87c19981c17d6b
Ruby
samover/learn_to_program
/ch09-writing-your-own-methods/ask.rb
UTF-8
1,127
3.953125
4
[]
no_license
# LEARNING TO PROGRAM WITH CHRIS PINE, 9.5 ex 1 ############################################### # Improved ask method. That ask method I showed you was OK, but I bet you # could do better. Try to clean it up by removing the answer variable. You'll # have to use return to exit from the loop. (Well, it will get you out o...
true
c1860578d4dc2d9086075b8d06decf9c94b08f0c
Ruby
Alanleeb/week6_brain_teaser
/brain_teaser.rb
UTF-8
331
3.6875
4
[]
no_license
require 'pry' def repeat puts "Please enter a sentence of words" word = gets.split counter = 0 most_repeats = nil word.each do |w| most = w.length - w.split('').uniq.length if most > counter most_repeats = w counter = most end end puts most_repeats ...
true
a2f1f124ab42b7fa49a382d7ce6ee441d6e7647d
Ruby
yuyueugene84/Tealeaf
/Arrays/increment.rb
UTF-8
133
3.34375
3
[]
no_license
arr = [1,2,3,4,5] arr2 =[] def increment(arr, arr2) arr.each do |num| arr2 << num + 2 end p arr2 end increment(arr, arr2)
true