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
edcbd300e203ff8284518db9a2f6574ef16c5f59
Ruby
arbovm/scratchweb
/spec/lib/scratchweb/http/header_spec.rb
UTF-8
3,553
2.59375
3
[]
no_license
require File.dirname(__FILE__) + '/../../../../lib/scratchweb' describe Scratchweb::Http::Header do POST_HEADER = <<EOH POST /uploads HTTP/1.1 User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3 Host: localhost:8081 Accept: */* Content-Length: 3273 Expect: 100-continue Co...
true
7bb2dfac94d9c4a12c9c6c9894eb4c0b28996179
Ruby
TheBoyMoe/Book-Repo
/Effective-Testing-with-RSpec3/basics/chap2/spec/coffee_spec.rb
UTF-8
3,572
3.03125
3
[]
no_license
require_relative '../spec_helper' require 'coffee' =begin NOTE: 1. use the 'coderay' gem to add syntax highlighting to the cli (in bundler projects add coderay to your gem, otherwise install it using 'gem install coderay') 2. to identify slow running tests use the --profile option, e.g. $ rspec spec/test...
true
66f628dffa84608890d84d7e2e33b2311f474a8d
Ruby
BaptisteBecmeur/fullstack-challenges
/02-OOP/05-Food-Delivery-Day-One/01-Food-Delivery/app/repositories/customers_repository.rb
UTF-8
1,269
3.21875
3
[]
no_license
require 'csv' require_relative '../models/customer' class CustomersRepository attr_reader :customers def initialize(csv_path) @customers = [] @csv_path = csv_path # load_csv if File.exist?(csv_path) @next_id = @customers.empty? ? 1 : (@customers.map {|c| c.id }.max.to_i + 1) # si le tableau d...
true
dc9adbd791850e9bd0d7132ab8adfa924b48a17f
Ruby
Hawleywoo/programming-univbasics-4-square-array-den01-seng-ft-051120
/lib/square_array.rb
UTF-8
272
3.546875
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def square_array(array) # your code here #new_array = array.collect{|i| i**2} #puts new_array count= 0 new_array = [] while count < array.length do new_array.push(array[count]**2) count += 1 end new_array end #array =[4,8,12] #square_array(array)
true
47eec247057ca0478496c6e717f4cab9f9a1aa33
Ruby
threepistons/advent-of-code
/2019/05/lib/05.rb
UTF-8
4,209
3.796875
4
[]
no_license
require 'expect' class Intcode attr_reader :result attr_accessor :input attr_reader :output def initialize @result = '' @input = 0 @output = 'cat' thearray = [] end # this didn't work for reasons I have yet to work out def calculate(program) operator = '' a = 0 b = 0 the...
true
9989115221506a28bcc8670d9468018642168d57
Ruby
sogapalag/contest
/atcoder/abc117/c.rb
UTF-8
183
2.90625
3
[]
no_license
n,m=gets.split.map &:to_i x=gets.split.map &:to_i x.sort! a=[] for i in 0 .. m - 2 a << x[i + 1] - x[i] end a.sort! ans = 0 for i in 0 ... [0, m - n].max ans += a[i] end puts ans
true
5c03b49434b56305404241986d00dc5d422d3cd8
Ruby
BlookHo/api_sinatra_pg
/models/company.rb
UTF-8
2,216
2.5625
3
[]
no_license
class Company < Sequel::Model one_to_many :jobs plugin :validation_helpers def validate super errors.add(:name, "can't be empty") if name.empty? validates_presence [:name, :location] validates_unique [:name] end def to_api # Not for array!! { id: id.to_s, name: name, l...
true
e969757e9bae7f6683304125e5e026cc0fa94198
Ruby
leopoldkwok/borisbikes
/spec/garage_spec.rb
UTF-8
522
2.890625
3
[]
no_license
require 'garage' describe Garage do let(:broken_bikes) { [broken_bike = Bike.new.break!] } let(:garage) { Garage.new(:capacity => 123, :bikes => broken_bikes)} it "should allow setting default capacity on initialising" do expect(garage.capacity).to eq(123) end it "should fix broken bikes" do ga...
true
49eb7a7244cfee043f811151b9dbe5d7de283fe8
Ruby
MikeConner/Kula
/lib/burn_link_destination.rb
UTF-8
1,210
2.578125
3
[]
no_license
require 'pg' class BurnLinkDestination # connect_url should look like; # mysql://user:pass@localhost/dbname def initialize(connect_url) @conn = PG.connect(connect_url) #TODO - Insert Cause Statement @conn.prepare('insert_pg_stmt', 'INSERT INTO replicated_burn_links( burn_link_id, burn_b...
true
511923c6893f614581fd785a167bf5457bb9f8fe
Ruby
Sindhuraghavan/Ruby
/fifth.rb
UTF-8
435
3.640625
4
[]
no_license
class Operation def add(value1,value2) if (value1 =~ /[0-9]/ and value2 =~ /[0-9]/) sum= value1.to_f + value2.to_f print sum elsif value1 =~ /[a-zA-Z]/ and value2=~ /[a-zA-Z]/ print value1.concat(value2) else puts "no idea" end end end puts "Enter the value1" value1 = ge...
true
18b4317e5b0a16e3dc1cf9836d1526aea38cc159
Ruby
heroku/heroku-kafka-demo-ruby
/app.rb
UTF-8
4,008
2.609375
3
[ "ISC" ]
permissive
# frozen_string_literal: true require 'kafka' require 'sinatra' require 'json' require 'active_support/notifications' require 'tempfile' KAFKA_TOPIC = ENV.fetch('KAFKA_TOPIC', 'messages') GROUP_ID = ENV.fetch('KAFKA_CONSUMER_GROUP', 'heroku-kafka-demo') def with_prefix(name) "#{ENV['KAFKA_PREFIX']}#{name}" end de...
true
263ea33bb0765aef23a0e360114015ebcc2b55db
Ruby
JustynaStebel/ParkYourCar
/test/models/address_test.rb
UTF-8
719
2.59375
3
[]
no_license
require 'test_helper' class AddressTest < ActiveSupport::TestCase def setup @address = addresses(:krakow) end test "is invalid without city" do @address.city = nil assert @address.invalid? assert @address.errors.has_key?(:city) end test "is invalid without street" do @address.street ...
true
0f8a18599412acf0e7bb0dfee8ca0b9ad77d9d21
Ruby
stupendousC/hotel
/lib/hotelFrontDesk.rb
UTF-8
19,317
3.015625
3
[]
no_license
require_relative 'lib_requirements.rb' require_relative 'room' require_relative 'reservation' require_relative 'block' require_relative 'dateRange' require_relative 'csvRecord' def reset_avail_id(array_of_objs:, class_name:) max = array_of_objs.max_by do |obj| obj.id end class_name.set_available_id(max.id) e...
true
3b750997f74c3dca43a50e211b37163f9a16850d
Ruby
bitliner/constituent-parser
/lib/opener/constituent_parser/cli.rb
UTF-8
1,998
2.8125
3
[ "Apache-2.0" ]
permissive
module Opener class ConstituentParser ## # CLI wrapper around {Opener::ConstituentParser} using OptionParser. # # @!attribute [r] options # @return [Hash] # @!attribute [r] option_parser # @return [OptionParser] # class CLI attr_reader :options, :option_parser ## ...
true
ad64d6af9d7c73d028069e3f8f7c563536df7f38
Ruby
abigezunt/ga-rspec-quiz
/spec/credit-card_spec.rb
UTF-8
1,550
3
3
[]
no_license
require 'spec_helper' require_relative '../lib/credit-card' describe CreditCard do subject {CreditCard.new(5290_1196_4306_7693, '1113', 623, "Matt Clement", 78782)} it "should be valid" do subject.valid?.should be true end end describe "Invalid Credit Card" do let(:wrong_number_card) {CreditCard.new(543_2874_...
true
7d8eda431ab7bfadd983dafb7099bf018fadb464
Ruby
FHappy/Project-Euler-Exercises
/problem4.rb
UTF-8
1,012
4.125
4
[]
no_license
# # PROMPT # A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 × 99. # # Find the largest palindrome made from the product of two 3-digit numbers. # SOLUTION require 'pry' # find all palindromes in range of 3 digit products palindromes = ...
true
de32197c2a13ea4416bd898ef98b45d56f0e031a
Ruby
AlexUkPC/The-Well-Grounded-Rubyist
/Chapter11/11.2.2_Simple_matching_with_literal_regular_expressions.rb
UTF-8
326
3
3
[]
no_license
p /abc/.match?("The alphabet starts with abc.") p "The alphabet starts with abc.".match?(/abc/) puts "Match!" if /abc/ =~ "The alphabet starts with abc." puts "Match!" if "The alphabet starts with abc." =~ /abc/ p /abc/.match("The alphabet starts with abc.") p /abc/.match("def") p "The alphabet starts with abc." =~ ...
true
5090400c274ea66f2a0ce0441191abe1a3fd67f2
Ruby
szich/simplesite
/script/import.rb
UTF-8
2,709
2.578125
3
[]
no_license
# To use this script # 1) Place this file in the RAILS_ROOT/script directory. # 2) Place the epcp_database.csv file in the same directory. # 3) Open the terminal in the script directory (if you haven't already) # 4) Run it using: ./runner -e production 'load "./import.rb"' require 'rubygems' require 'faster_csv' requi...
true
6fbfdb7cc3806fae566b6622a75c68d5e056b75c
Ruby
afeiship/ruby-programing-book-notes
/docs/2018-08/2018-08-05/001-area_volume.rb
UTF-8
280
2.765625
3
[]
no_license
# = begin # 这里可以写一大断注释 # = end x = 10 y = 20 z = 30 area = (x*y + y*z + z*x) * 2 volumn = x * y * z print "表面积=", area, "\n"; print "体积=", volumn, "\n"; # cd /Users/feizheng/github/ruby-programing-book-notes/docs/2018-08 # ruby area_volume.rb
true
b2c7031c0b45d5a48b67f355893d8289a45a5173
Ruby
doshea/SenaTest
/db/seeds.rb
UTF-8
7,520
2.515625
3
[]
no_license
require 'httparty' require 'json' reset_containers = false reset_politicians = false seed_start_time = Time.now puts "\nBEGINNING SEED" puts "-------------" User.delete_all if reset_politicians Politician.delete_all else puts 'Politicians not deleted to save time.' end if reset_containers State.destroy_all Ch...
true
39f0d77f011bee6e6534c62792661ff77f9a5483
Ruby
Dariusz-Choinski/tdd-backbone-demo
/lib/modules/router/routes.rb
UTF-8
560
2.890625
3
[ "MIT" ]
permissive
require_relative '../../../config/routes.map' require_relative 'route' class Routes include RoutesMap attr_accessor :routes def initialize @routes = [] build_map_convertion_methods convert_maps_to_route_objects end private def convert_maps_to_route_objects map end Methods = %w( get po...
true
a4b40e7efdd5c26cf94a70a61e97fe5f0b660fee
Ruby
grubern/rtesseract
/lib/processors/mini_magick.rb
UTF-8
873
2.59375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# encoding: UTF-8 # Add to rtesseract a image manipulation with MiniMagick module RTesseract::Processor::MiniMagickProcessor def self.setup require 'mini_magick' end def self.a_name?(name) %w(mini_magick MiniMagickProcessor).include?(name.to_s) end def self.image_to_tif(source, _points = {}) tmp...
true
7bce2a6cc57d8b63d6a8235d475f30f1d80f4959
Ruby
RolandStuder/odin_project_solutions
/oop/tic-tac-toe/lib/ai_player.rb
UTF-8
2,222
3.28125
3
[]
no_license
require 'pry' class AIPlayer < Player def initialize(name, strategy = nil) super @moves = [] @winning_sequences = [] @strategy = strategy end def prompt_for_action(moves) @moves = moves # return random_available_move if @moves.length == 0 case @strategy when :both ...
true
b484b4fbf721e764670c3aba0ca6b3bbfb61d831
Ruby
raravena80/zulia
/pangram/pangram.rb
UTF-8
583
3.875
4
[ "Apache-2.0", "MIT" ]
permissive
#!/usr/bin/env ruby # This solution is using ascii codes in decimal # pangram = "The quick brown fox jumps over the lazy dog" pangram.tr!(' ,!@#$%', '').downcase! pangramArray = pangram.split("") letters = [] pangramArray.each do |c| if (c.ord >= 97 || c.ord <= 122) letters.push(c.ord) end end # sort and ge...
true
fc70109681f1d3d6120e721e27a8aa47b6d47a5b
Ruby
tsonntag/interfaces
/lib/interfaces/zip_filter.rb
UTF-8
566
2.515625
3
[ "MIT" ]
permissive
require 'zip' module Interfaces class ZipFilter < Filter attribute :zip_filename validates_presence_of :zip_filename def do_filter_files pathes dir = File.dirname pathes.first target_path = File.join dir, zip_filename Zip::ZipOutputStream.open(target_path) do |zos| pathes.each ...
true
18ca004d7f7ab4c36da52013fa68872145a39008
Ruby
LE-HU/odin_project_le-hu
/archive/tictactoe_eh.rb
UTF-8
806
3.875
4
[]
no_license
class TicTacToe def initialize(board) @board = board end def play n = 0 while n < 4 # 4 moves for now n += 1 def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts separator = "-----------------" puts " #{board[3]} | #{board[4]} |...
true
c700ec229fac71324bb1607dd1eeac3901c20e7d
Ruby
jstirk/pennytel
/lib/pennytel/default.rb
UTF-8
17,007
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'xsd/qname' # {http://pennytel.com}PennyTelAccount # balance - SOAP::SOAPFloat # blocked - SOAP::SOAPBoolean # currency - SOAP::SOAPString # lastUsageDate - SOAP::SOAPDateTime # others - SOAP::SOAPString # zeroBalanceDate - SOAP::SOAPDateTime class PennyTelAccount attr_accessor :balance attr_ac...
true
d55871a88e0c9237c38422f265ff4b5d8601aec1
Ruby
conradszklarz/object_oriented_ruby
/runner_code.rb
UTF-8
699
3.125
3
[]
no_license
store_item_1 =StoreFront::StoreItem.new( color: "blue", price: 5.50, fruit: "blueberries" ) store_item_2 =StoreFront::StoreItem.new( color: "red", ...
true
fdb283be46fafb6d6846108786097e6d9639518e
Ruby
Carrison57/ruby_functions
/multiplication/multiply.rb
UTF-8
116
3.109375
3
[]
no_license
def my_multiply(first_num, second_num, third_num) num = first_num * (second_num * third_num) end puts num
true
12ed50bfc6b0d55053e9471987da268f36d44ff2
Ruby
greggroth/knapsack
/test_examples/fast/spec_test.rb
UTF-8
304
2.84375
3
[ "MIT" ]
permissive
require 'test_helper' class FakeCalculator def add(x, y) x + y end def mal(x, y) x * y end end describe FakeCalculator do before do @calc = FakeCalculator.new end it '#add' do @calc.add(2, 3).must_equal 5 end it '#mal' do @calc.mal(2, 3).must_equal 6 end end
true
920804522c977ab5fde17ef142f3f7b13ea305f5
Ruby
VincentLloyd/the_final_cafe
/menu.rb
UTF-8
1,473
2.859375
3
[]
no_license
module FinalCafe class MenuItem attr_accessor :name, :price def initialize(name, price) @name = name @price = price end end class Menu FOOD_ENTREE = [ MenuItem.new('Oysters', 13), MenuItem.new('Parma', 15), MenuItem.new('Eggplant Casserole', 15), MenuItem.new(...
true
7c701772a4083deb848466f6a13c3664055e5766
Ruby
meitel/Pre-course-
/LeapYears.rb
UTF-8
371
3.90625
4
[]
no_license
puts 'What is the start year?' startyear = gets.chomp.to_i puts 'And what is the end year?' endyear = gets.chomp.to_i puts 'Below are the following leap years in between ' + startyear.to_s + ' and ' + endyear.to_s + ':' while (startyear <= endyear) if ((startyear % 4 == 0 and startyear % 100 !=0) or startyear % 400 ==...
true
6c35dec37c4b32a3abc24117856756a77bfe859b
Ruby
kbarley/toc-vis
/2-extract-isbn.rb
UTF-8
478
2.9375
3
[]
no_license
require 'json' json_files = Dir["*.json"] - Dir["extract-*.json"] files = json_files.map{|file| JSON.parse(File.open(file).read)}.flatten # Basic url: http://search.barnesandnoble.com/title/author/e/isbn # But title and author can be omitted and url still works isbns = files.map do |file| file["books"].map do |bo...
true
cda46892a46faf8e628ef43957397d54e5577f81
Ruby
compilerla/simmons
/data_processors/mergeall.rb
UTF-8
12,732
2.703125
3
[]
no_license
require 'csv' require 'rest-client' require 'merc_convert' require 'geocoder' require 'securerandom' require '../property_deduper.rb' Geocoder.configure( :lookup => :google, :use_https => true, :api_key => 'AIzaSyDzL_IIGdqVTs0_E6Oln6uYoJMXEffHfyk', :region =>...
true
c41188c90877b78866ef98f5462d681e3df7b71f
Ruby
maloneyl/WDI_LDN_3_Work_Clone
/maloneyl/w2d5/homework/movies_app/main.rb
UTF-8
2,239
2.75
3
[]
no_license
require "sinatra" require "sinatra/contrib/all" require "sinatra/reloader" require "pg" require "pry" require_relative "./model/movie.rb" require_relative "./model/actor.rb" also_reload "./model/movie.rb" also_reload "./model/actor.rb" before do @db = PG.connect(dbname: "movies", host: "localhost") @movie = Movie...
true
7edf83240be4cbb446894ba49d526de0a504199e
Ruby
dnuffer/dpcode
/print_table/ruby/start.rb
UTF-8
621
2.875
3
[]
no_license
if __FILE__ == $1 exit 1 unless system "rspec #{__FILE__}" end require 'rspec' describe "print_table" do it "formats a table with a single element" do print_table([["x"]]).should == "x\n" end it "formats a table with a single element in two rows" do print_table([["1"], ["2"]]).should == "1\n2\n" e...
true
de0928c56c40c8f134d423b613fee8e4ad331e7f
Ruby
mathycoder/ruby-music-library-cli-online-web-sp-000
/lib/artist.rb
UTF-8
844
3.171875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' require_relative '../lib/concerns/findable' class Artist extend Concerns::Findable attr_accessor :name, :songs @@all = [] def self.all @@all end def initialize(name) @name = name @songs = [] end def self.destroy_all @@all.clear end def save @...
true
7ad032568b0a9ce4999aaa9e9de7673753345adc
Ruby
chadellison/lib
/the_cracker.rb
UTF-8
2,075
3.46875
3
[]
no_license
require_relative 'wheel' class TheCracker attr_reader :encrypted_message, :the_wheel, :crack_rotator, :cracked_message, :crack_indices, :key_location, :end_of_message def initialize @encrypted_message = encrypted_message @the_wheel = Wheel.new @crack_rotator = [] @crack_indices = [] @cracked_m...
true
0ab17b61f06ffc7dba1581d6ab472c5abacc1203
Ruby
flazzarotto/ruby_morpion-game
/app.rb
UTF-8
825
2.984375
3
[]
no_license
require 'bundler' Bundler.require $:.unshift File.expand_path("./../lib", __FILE__) require 'app/board' require 'app/boardcase' require 'app/game' require 'app/player' require 'views/show' class Application def perform # TO DO : méthode qui initialise le jeu puis contient des boucles while pour faire tourner l...
true
b7848a87bf1ab23d35a3cd4d779f722df2ec9538
Ruby
LasVegasRubyGroup/presentations
/2012-03-21 Ruby's Enumerable module - David Grayson/test2.rb
UTF-8
1,121
4.03125
4
[]
no_license
# BASIC USE enum = "a".."f" p enum.to_a # => ["a", "b", "c", "d", "e", "f"] p enum.entries # => ["a", "b", "c", "d", "e", "f"] p enum.count # => 6 p enum.count("b") # => 1 p enum.count { |s| s <= "c" } # => 3 # ITERATION WITH ENUMERATOR enumerable = 1 ..3 enumerator = enumerable...
true
d54dc821f7649b9a5a924b2a3176d8694697783e
Ruby
shiiotaka/pro_ruby
/test/rgh_test.rb
UTF-8
736
2.78125
3
[]
no_license
require 'minitest/autorun' require '../lib/rgb' class RghTest < Minitest::Test def test_to_hex assert_equal '#000000', to_hex(0, 0, 0) assert_equal '#ffffff', to_hex(255, 255, 255) assert_equal '#043c78', to_hex(4, 60, 120) end def test_to_ints assert_equal [0, 0, 0], to_ints('#000000') asse...
true
a84333e9cd492d0b55dc3c8586f0e5152803d0e1
Ruby
jon-dominguez94/alpha-course
/jon_dominguez_tictactoe/lib/board.rb
UTF-8
1,732
3.75
4
[]
no_license
require 'byebug' class Board attr_accessor :grid def initialize(*args) if args.empty? @grid = Array.new(3){Array.new(3)} else @grid = args[0] end end def [](pos) row, col = pos @grid[row][col] end def []=(pos, mark) row, col = pos @grid[row][col] = mark end d...
true
570b2e588b1b7d919180e28c167867c3ab14342b
Ruby
rkettering/exercises
/reverse_array.rb
UTF-8
415
4.15625
4
[]
no_license
#!/usr/bin/ruby # Write a function which reverses the contents of an array in place. $numbers=[] for num in 1..23 $numbers.push num end def flip_array(array) for iter in 0..((array.length-1)/2) flip = array[array.length-1-iter] array[array.length-1-iter] = array[iter] array[iter] = flip end e...
true
24d6652dd6882ec82012f07eecc53253bb1b6734
Ruby
TSSaint/ruby-misc
/ruby_array_manipulations.rb
UTF-8
1,999
4.40625
4
[]
no_license
# pracs with new array manipulations # << adds elements into the end of an array. evaluates to array # array.push adds elements to the end. " " # array.pop removes last element of the array. evals to the removed only # array.unshift adds element to front. evaluates to array # array.shift removes first element. evaluate...
true
025bca0397a41761abed1f6025eb03906b13fa2e
Ruby
yukihirop/fcoin_ruby_client
/lib/fcoin/authorization.rb
UTF-8
2,446
2.734375
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
require 'openssl' require 'base64' require 'active_support' require 'active_support/core_ext' module Fcoin class Authorization # @param http_method [String] # @param path [String] # @param payload [Hash] # @param endpoint [String] # @api_key [String] # @secret_key [String] def initialize(...
true
02f6444b8f38c16d001ee821dd82e6057a0d3874
Ruby
reruns/archive
/poker-master/array_lib.rb
UTF-8
1,724
3.75
4
[]
no_license
class Array def my_uniq elements = [] self.each do |el| elements << el unless elements.include?(el) end elements end def two_sum container = [] self.each_with_index do |value, index| (index + 1).upto(self.size - 1) do |index2| container << [index, index2] if value + se...
true
cc73f1d78b53149e417766b07d37d2556edbd7f7
Ruby
grossjo/tododoo
/bin/todo
UTF-8
1,926
2.890625
3
[]
no_license
#!/usr/bin/env ruby require 'httparty' require 'json' require 'pp' URL_ROOT = "http://localhost:3000" # List Todos result = HTTParty.get('http://localhost:3000/todos') puts result.code puts result.body pp JSON.parse(result.body) # Create body = { todo: { title: "New Todo 1" } } result = HTTParty.pos...
true
23bfdc79abc3ab538a27dd26e0a25e2ae1d0d05f
Ruby
tomhowarth76/pig_latin_kata
/exercise_5.rb
UTF-8
1,761
4.15625
4
[]
no_license
# Develop your work so far to handle sentences # e.g. "The quick fox jumped over the lazy dog" -> # "Ethay ickquay oxfay umpedjay overway ethay azylay ogday" def pig_latin(word) if word[0..0] =~ /[A-Z]/ iscap = true else iscap = false end if word.slice(0) == "a" || word.slice(0) == "e" || ...
true
96227f443a8efb32e5c68ab27c89e38eab1a6a7f
Ruby
ynportfolios/vending-machine-2
/vending_machine.rb
UTF-8
4,161
3.546875
4
[]
no_license
require './beverage' require './line' class VendingMachine # ステップ0 お金の投入と払い戻しの例コード # ステップ1 扱えないお金の例コード # 10円玉、50円玉、100円玉、500円玉、1000円札を1つずつ投入できる。 MONEY = [10, 50, 100, 500, 1000].freeze # (自動販売機に投入された金額をインスタンス変数の @slot_money に代入する) def initialize # 最初の自動販売機に入っている売上金額は0円 @earn_money = 0 # 最初の自動販売...
true
2cf0a899101b7a3cb4a5c57f1c98c558ac051be9
Ruby
snusnu/substation
/lib/substation/dispatcher.rb
UTF-8
2,526
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# encoding: utf-8 module Substation # Encapsulates all registered actions and their observers # # The only protocol actions must support is +#call(request)+. # Actions are intended to be classes that handle one specific # application use case. class Dispatcher include Concord.new(:actions, :env) ...
true
7c5f448921e0ac09254699f09e305059af05bbcf
Ruby
ruby-amqp/amq-client
/spec/unit/client/settings_spec.rb
UTF-8
3,735
2.578125
3
[ "MIT" ]
permissive
# encoding: utf-8 require "spec_helper" require "amq/client/settings" describe AMQ::Client::Settings do describe ".default" do it "should provide some default values" do AMQ::Client::Settings.default.should_not be_nil AMQ::Client::Settings.default[:host].should_not be_nil end end describe "...
true
27a1e6620c7918404dcf3343c196840cef2c1dec
Ruby
gomeswes/Coursera_Ruby
/course_1/module_2/playground_methods.rb
UTF-8
451
3.875
4
[]
no_license
def can_divide_by?(number) return false if number.zero? true end puts "can divide by 3? #{can_divide_by? 3}" puts "can divide by 0? #{can_divide_by?(0)}" def factorial(number = 7) number == 0 ? 1 : number * factorial(number - 1) end puts "Factorial of 3: #{factorial(3)}" puts "Default Factorial: #{factorial}" ...
true
7c891dd98e1b0dd207cc6b6bb3b9f7f994dd508c
Ruby
erixhartman/ruby_fundamentals2
/exercise5.rb
UTF-8
193
3.796875
4
[]
no_license
def faren(num) return (num - 32) * (5.0/9) end puts "WHAT IS THE TEMPERATURE!?!?! (F)" temp = gets.chomp.to_i puts "According to the rest of the world" puts "The temperature is #{faren(temp)}"
true
cadfec0777ddd106a08954160ba46f2b6bf22c13
Ruby
weelliam/mpm-magic
/lib/misc/log.rb
UTF-8
699
2.71875
3
[]
no_license
class Log attr_accessor :world, :description, :card, :target, :action, :time def initialize(world:nil, description: "", card: nil, target: nil , action: nil) @world = world @description = description @time = DateTime.now @card = card @action = action @target = target end def js_i...
true
de3c7eb4a5eff2ebe7dd19d8a7014716fa28a160
Ruby
rom5566/Wii.rb
/archive.rb
UTF-8
7,858
2.921875
3
[]
no_license
#!/usr/bin/env ruby # Wii.rb -- A Wii toolkit written in Ruby # # Author:: Alex Marshall "trap15" (mailto:trap15@raidenii.net) # Copyright:: Copyright (C) 2010 HACKERCHANNEL # License:: New BSD License # The header for a U8 archive. class U8Header attr_accessor :tag, :rootnode_off, :header_sz, :data_off, :pad def i...
true
a66e5f1e1facad73538c4d7f4009506694d852ae
Ruby
f1nesse13/aA_chess_game
/board.rb
UTF-8
2,440
3.578125
4
[]
no_license
require_relative 'pieces' require_relative 'display' class Board attr_accessor :rows def initialize(fill_board = true) @sentinel = NullPiece.instance create_grid(fill_board) end def [](pos) pos.each { |num| num.to_i } a, b = pos @rows[a][b] end def []=(pos, value) a, b = pos @r...
true
fba0d50cbc5635e4b7a739ee2c8395fc8240203f
Ruby
JoshCheek/PresentationFiles
/UnderstandAllTheThings/presentation/01-ruby-feedback/03-rake--trace/Rakefile
UTF-8
68
2.859375
3
[ "MIT" ]
permissive
def add_two(n) puts n + 2 end task :default do add_two '2' end
true
766c129041c87915dc751f1d64322e3246cf2900
Ruby
pindell-matt/maze_maker
/test/maze_test.rb
UTF-8
1,836
3.3125
3
[]
no_license
require 'minitest/autorun' require_relative '../lib/maze' require 'pp' class MazeTest < Minitest::Test attr_reader :maze, :grid def setup @def_size = 5 @maze = Maze.new(@def_size) @grid = @maze.generate_grid(@def_size) end def test_maze_has_fixed_size desired_size = 10 maze = Maze.new(de...
true
5b8dc1ab36294b4211b2ff547a3624084f11cf0e
Ruby
thebravoman/software_engineering_2013
/class10_homework/Teodor_Draganov.rb
UTF-8
912
2.75
3
[]
no_license
require 'rexml/document' def line(svg,x1,x2,y1,y2,red=0,green=0,blue=0) line=svg.add_element "line" line.attributes["x1"]=x1 line.attributes["x2"]=x2 line.attributes["y1"]=y1 line.attributes["y2"]=y2 line.attributes["stroke"]="rgb(#{red},#{green},#{blue})" line.a...
true
27165e32f650f2ff74257eb50b6d070bd82fe77a
Ruby
stijlist/jarvis
/spec/calendar_spec.rb
UTF-8
4,339
2.609375
3
[]
no_license
require 'vcr' require_relative '../spec/vcr_helper.rb' require_relative '../lib/calendar.rb' describe Calendar do it 'lists events' do VCR.use_cassette('google-calendar-event-listing') do c = Calendar.new expect(c.events.count).to be > 1 end end it 'adds events' do ...
true
c3629e2e1faa22f893f47372f243b170ee2f96e8
Ruby
techbelly/roguecommuter
/site/db.rb
UTF-8
989
2.578125
3
[]
no_license
require 'datamapper' require 'json' require 'v8' class Runtime def log(message) puts "#{message}" end end class Personality include DataMapper::Resource property :id, Serial property :name, String property :bluetooth_id, String, :length=> 0..40 property :code, Text property :state, String, :defa...
true
20ff943a5fcb37ddc08d3b244b65b47dec2a922d
Ruby
sealink/ruby_core_extensions
/lib/ruby_core_extensions/class.rb
UTF-8
74
2.53125
3
[ "MIT" ]
permissive
class Class def downcase_symbol self.to_s.downcase.to_sym end end
true
90d465064167f32f5ec4969f1e28f3d3eb9d443e
Ruby
vickyGao/unity-learning
/ruby/spine/supernova/service.rb
UTF-8
3,480
2.609375
3
[]
no_license
require 'singleton' require 'securerandom' module SuperNova class Service include Singleton @@services = Array.new attr :sleeptime, true attr :restarts attr :name def self.[] (key) @@services.detect { |service| service.name == key } end d...
true
ae52c13ad8ba621047f07a3b00ef4245592187eb
Ruby
brastoner/now_serving
/test/line_man_test.rb
UTF-8
1,703
2.734375
3
[]
no_license
require 'rubygems' require 'test/unit' require 'sequel' require '../lib/line_man_base' require '../lib/line_man_queue' require '../lib/line_man_queue_element' require '../lib/line_man_repository' class LineManTest < Test::Unit::TestCase def setup end def teardown end def test_create_queue repo = get_repo ...
true
dc5776fe6cc560531186711540c231235eb2ce81
Ruby
akshatj/launchschool-ruby-intro
/exercises/3.rb
UTF-8
53
3.265625
3
[]
no_license
odds = (1..10).select { |i| i % 2 != 0 } puts odds
true
b558141b5c70b76dee8f9c63e87dd673a20cc0d7
Ruby
morenoh149/TheAlgorithmDesignManual
/dynamicProgramming/min_coin_sum.rb
UTF-8
571
3.53125
4
[]
no_license
# Given a list of N coins, their values (V1, V2, ... , VN), and the total sum S # Find the minimum number of coins the sum of which is S (we can use as many # coins of one type as we want), or report that it's not possible to select # coins in such a way that they sum up to S. def min_coin_sum(coins, sum) memo = Arr...
true
4f08033d24b485187e7336320dada13177796bed
Ruby
wisq/autocrew
/lib/autocrew/solver/range_error_function.rb
UTF-8
2,799
2.96875
3
[]
no_license
require 'autocrew/solver/error_function_base' require 'autocrew/vector' require 'autocrew/coord' module Autocrew::Solver class RangeErrorFunction < ErrorFunctionBase include Autocrew def arity return 5 end def evaluate(pos_x, pos_y, nvel_x, nvel_y, speed) super(Coord.new(pos_x, pos_y), ...
true
913ad11e2525529e98fb939fde6884c58eb9413a
Ruby
hortencia718/ruby-oo-inheritance-defining-inheritance-nyc04-seng-ft-071220
/lib/car.rb
UTF-8
231
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative "./vehicle.rb" class Car < Vehicle def go "VRRROOOOOOOOOOOOOOOOOOOOOOOM!!!!!" end end # We use the < to inherit the Car class from Vehicle. Notice that there are no methods defined in the Car class.
true
7fd392413a0ad5c08f3078e17185e7cf7a173907
Ruby
yohei-koba-tokyo/playground
/exist123.rb
UTF-8
197
3.375
3
[]
no_license
def array123(nums) nums.include?(1) && nums.include?(2) && nums.include?(3) ? (puts "True") : (puts "False") end array123([1, 1, 2, 3, 1]) array123([1, 1, 2, 4, 1]) array123([1, 1, 2, 1, 2, 3])
true
0383850f414d988ad1acf7578d0c5337f1c0019b
Ruby
with-a-k/enigma
/test/decryptor_test.rb
UTF-8
1,502
2.75
3
[]
no_license
require 'minitest' require 'minitest/autorun' require './lib/decryptor' class DecryptorTest < Minitest::Test def test_decryptors_exist_and_take_three_arguments assert Decryptor.new("sample text.", 25326, "140415") end def test_decryptors_make_their_own_key testdecryptor = Decryptor.new("sample text.", 2...
true
53d3d2665467333c0e625a667d6e24d3568653ca
Ruby
iLtc/launch-school
/101/lesson2/calculator.rb
UTF-8
1,325
4.5
4
[]
no_license
def prompt(message) puts "=> #{message}" end def valid_number?(num) num.to_i != 0 end prompt("Welcome to Calculator! What's your name?") name = nil loop do name = gets.chomp if name.empty? prompt("Make sure to use a valid name.") else break end end prompt("Hi #{name}!") loop do # main loop n...
true
cd120a732a05c5a7c8603f96595164ee81f60290
Ruby
jfo/hello
/jeff.rb
UTF-8
2,233
3.078125
3
[]
no_license
class Human attr_reader :corporeal_being, :consciousness def initialize @corporeal_being = true @consciousness = true end #TODO: figure out universal truths, meaning of life, etc... (why is there no Stack Overflow thread on that?) end class Jeff < Human attr_reader :s, :l, :edumactions, :jorbs, ...
true
a9ff270f9ab2edea24a4b618eb001ac31b140102
Ruby
thiensau/N2M_Openshift_Hosting
/db/seeds.rb
UTF-8
2,862
2.6875
3
[]
no_license
Product.delete_all Product.create!(title: 'Perfect Shape Bra', description: %{<p> The everyday go-to bra you love pairs push-up padding and the coverage you want with soft, sleek cups and a smoothing U-shaped back.<br> Lift & Lining: Extreme lift, Full coverage underwire cups.<br> Straps & Hooks: Ful...
true
6f5ac7e5042556c626b3128bdd5f3c8c22b59834
Ruby
cananth/rails-app
/RailsApp/ruby_programs/text_dollar.rb
UTF-8
2,150
3.484375
3
[]
no_license
class TextDollar def initialize hash @hash = hash end def text_dollar file_name begin File.open(file_name, "r").each do | value | integer_array = value.split(" ") integer_array = integer_array[0].split(" ") integer_array.each do | integer_array | result_value = get_hash (integer_array) p...
true
d610d39abbfd0a4db097973c59569d6163db9d3f
Ruby
bdewey/git-stack
/features/support/town_helpers.rb
UTF-8
1,406
2.546875
3
[ "MIT" ]
permissive
# frozen_string_literal: true def add_perennial_branch branch old_value = perennial_branch_configuration new_value = [old_value, branch].reject(&:blank?).join(' ') set_configuration 'perennial-branch-names', new_value end def delete_main_branch_configuration run 'git config --unset git-town.main-branch-name'...
true
e962f6fdeb5c680df2e276b0322e1610ffb1f725
Ruby
MikeSilvis/shindig
/app/lib/refresh_google_token.rb
UTF-8
803
2.609375
3
[]
no_license
class RefreshGoogleToken attr_accessor :client, :google_account def initialize(google_account) @google_account = google_account end def get_new_token refresh_token = google_account.refresh_token.gsub("/", "%2F") resp = client.post do |req| req.url "/o/oauth2/token" req.bo...
true
4e8d5934ea25aa9b70a7ca3983ad5a8210373624
Ruby
nakulsapkal/two_player_math_game
/questions.rb
UTF-8
221
3.421875
3
[]
no_license
class Questions attr_accessor :question, :answer def initialize() @number_1=rand(1..20) @number_2=rand(1..20) @answer= @number_1 + @number_2 @question="What does #{@number_1} plus #{@number_2} equals?" end end
true
dc5cbbc7a042aee8af1f9cb15b02933e71b1adf6
Ruby
alexxck/RoR-Ruby-Basics
/1 Lesson/48.rb
UTF-8
204
2.6875
3
[]
no_license
#Дан целочисленный массив и интервал a..b. Найти максимальный из элементов в этом интервале. m=[1,2,3,45,4,6] a=3 b=5 p m[a..b].max
true
da306a1a9af5dc3810fe8ca4bc2c5269a2f4b06c
Ruby
jimanx2/translatable_model
/lib/translatable_model.rb
UTF-8
1,769
2.625
3
[ "MIT" ]
permissive
require "translatable_model/version" require "translatable_model/railtie" if defined?(Rails) module TranslatableModel class ActiveRecord::Base class << self def translatable(column, option = {}) # check if coloumn exists raise "Column #{column} does not exist in Model #{self.name}" un...
true
cfde32255fec331e6fda7ce6abfd645a21e7a209
Ruby
masterkain/concurrent-ruby
/tasks/stresstest/support/stressor.rb
UTF-8
2,012
3.21875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require_relative 'word_sec' module Stressor FILE_PATH = File.dirname(__FILE__) TEST_FILES = { test_data_a: { file: 'TestdataA.txt', total: 13, highest_count: 4 }, test_data_b: { file: 'TestdataB.txt', total: 80, highest_count: 10 }, test_data_c: { fil...
true
19dd92c6a2ee5945191b573a034358102272ab85
Ruby
appirio-tech/cs-api
/app/models/salesforce.rb
UTF-8
5,409
2.640625
3
[]
no_license
require 'uri' class Salesforce include HTTParty format :json headers 'Content-Type' => 'application/json' def self.esc(str) URI.escape(str) end def self.set_header_token(access_token) headers 'Authorization' => "OAuth #{access_token}" end def self.access_token(type=:public) clie...
true
6065d97ad36a61742452274fb28e132d6a351969
Ruby
tstaros23/seattle_grace_2105
/lib/doctor.rb
UTF-8
204
2.765625
3
[]
no_license
class Doctor attr_reader :name, :specialty, :salary def initialize(doctor_info) @name = doctor_info[:name] @speciality = doctor_info[:specialty] @salary = doctor_info[:salary] end end
true
9bc4f19c5470aa09b535eb36c3fe30dbeb7587ae
Ruby
bah87/app-academy-daily-projects
/W1D4/minesweeper/board.rb
UTF-8
514
3.109375
3
[]
no_license
class Board attr_reader :grid def initalize (grid = Array.new(9){Array.new(9)}) @grid = grid end def self.populate(num_tiles) tiles = [] grid = Array.new(num_tiles**0.5){Array.new(num_tiles**0.5)} grid.each_with_index do |row, i| row.each_with_index do |val, j| pos = [i, j...
true
13bafeea9d1d2cef7d7a5026e5ec214a20683341
Ruby
mjaric/r-calc
/spec/spec_helper.rb
UTF-8
1,043
3.015625
3
[ "MIT" ]
permissive
require 'r_calc' #require 'supermodel' #require 'minitest/spec' #require 'minitest/autorun' module RCalcHelpers class Calculator < RCalc::FormulaProcessor # Let's just add all of the usual operators include ::RCalc::ParentheticalGrouping # () include ::RCalc::AssignmentOperator # = include ::RCalc::...
true
9abfc8aab49935440026d1e15defe6d212dba38e
Ruby
yuzixun/algorithm_exercise
/main/20170327-122.rb
UTF-8
641
4.09375
4
[]
no_license
# Say you have an array for which the ith element is the price of a given stock on day i. # Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same tim...
true
5f7409b3c40cc50b1f21c42e2cc3d3ac59bf708a
Ruby
prakash-dubey/Training
/Ruby/mixin.rb
UTF-8
237
3.046875
3
[]
no_license
module A def a1 puts "in a1" end def a2 puts "in a2" end end module B def b1 puts "in b1" end def b2 puts "in b2" end end class Sample include A exclude A end Sample.a1 a = Sample.new a.a1
true
b9c9bb30df20ce526ed28e2a999eaf8f17ec5fe1
Ruby
Michael-S-cott/SerialMatrix
/Playback.rb
UTF-8
438
2.671875
3
[]
no_license
# Welcome to Sonic Pi v3.1 ary = [61, 72, 83] i = 0 j = 0 data = Array.new voice = Array.new linea = '' use_synth :tri File.open('/Users/michaelscott/desktop/SerialMatrix/SonicPiInput.txt','r') do |f1| while linea = f1.gets while i <linea.length-1 data = linea[i]+linea[i+1] voice = voice.pu...
true
993ccb5c92dcb2fb01ebb2414c0ea4c039f12db6
Ruby
eakmotion/RubyPracticeProblems
/password_generator.rb
UTF-8
663
3.375
3
[]
no_license
# You need to write a password generator that meets the following criteria: # 6 - 20 characters long # contains at least one lowercase letter # contains at least one uppercase letter # contains at least one number # contains only alphanumeric characters (no special characters) # Return the random password as a string....
true
418d49ef1775b118bc1dfca381ba361f158d69f4
Ruby
ln1draw/selfsite
/my_app.rb
UTF-8
1,164
2.765625
3
[]
no_license
require 'sinatra' require 'yaml' class MyApp < Sinatra::Base before do @posts = Dir.glob("views/posts/*.erb").map {|path| path.split("/").last.gsub(".erb", "") } @sorted_posts = meta_data.sort_by {|post, data_hash| data_hash["date"]}.reverse end get '/' do erb :index end get '/about' do er...
true
77d209a5feaa1255d149bd83a7a9bc082604470e
Ruby
SteRobWms/oo-my-pets-houston-web-012720
/lib/owner.rb
UTF-8
1,372
3.4375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'pry' require_relative 'cat.rb' require_relative 'dog.rb' class Owner @@all = [] attr_reader :name, :species def initialize(name) @name = name @species = "human" @@all << self end def say_species "I am a #{@species}." end def self.all @@all end def self.count @@all.cou...
true
56147b96e9c9b0e42535ab5fb5c8c7982b2705c9
Ruby
synion/Codeval
/new_exerise/file_open.rb
UTF-8
375
3.28125
3
[]
no_license
filename = " " in_file = nil print "Enter the filename" filename = gets.chomp! if File.exists?(filename) && File.readable?(filename) in_file = File.open(filename, "r") in_file.each do |line| puts line end in_file.close puts "finish" elsif !File.exists?(filename) puts "File not exstist" elsif !Fil...
true
c8ecc07155dc5c7e892f53e8399c16319e236f2d
Ruby
thoughtbot/kumade
/lib/kumade/rake_task_runner.rb
UTF-8
578
2.53125
3
[ "MIT" ]
permissive
module Kumade class RakeTaskRunner def initialize(task_name) @task_name = task_name end def invoke return unless task_defined? Kumade.configuration.outputter.success("Running rake task: #{@task_name}") Rake::Task[@task_name].invoke if task_should_be_run? end private ...
true
162662d28d6aa6ffa41268109515c2ba2c57c650
Ruby
RIVASW/tennis
/spec/sets/initial_spec.rb
UTF-8
3,370
2.875
3
[]
no_license
# frozen_string_literal: true require 'sets/initial' RSpec.describe Sets::Initial do subject do described_class.new( player1_games: player1_games, player2_games: player2_games, player1_name: player1_name, player2_name: player2_name, score_counter: score_counter, ) end let(...
true
551dc309186b05e2202a0132014542b252a591be
Ruby
santiagosan93/like_tutorial
/db/seeds.rb
UTF-8
1,018
2.59375
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
true
03de7c0ad140a45b041f1045f69ed0bfcc7dc59c
Ruby
g5search/yield_star_client
/spec/yield_star_client/models/rent_summary_spec.rb
UTF-8
2,055
2.734375
3
[ "MIT" ]
permissive
require "spec_helper" module YieldStarClient describe RentSummary do context "attributes" do subject { described_class } it { is_expected.to have_attribute(:effective_date, Date) } it { is_expected.to have_attribute(:external_property_id, String) } it { is_expected.to have_attribute(:flo...
true
3291ad3560febf3a6edfcf48b15dc41bbc6c655d
Ruby
Carolsien/MetodyObliczeniowe
/lib/hermitcore.rb
UTF-8
3,772
3.328125
3
[]
no_license
class Hermit @n # Liczba podprzedzialow @a # Poczatek przedzialu @b # Koniec przedzialu @x # Punkty wezlowe siatki @y # Wartosci f(x) @z # Wartosci f'(x) @t # Generowana lista dwukrotnych x @f0 # Generowana lista wartosci @f # Wynikowa lista metody @debug = false # Flaga wyswietlania danych kontrolnych ...
true
c045b1c999c408b2037b704790584e72975e3d16
Ruby
agiratech-keerthana/ruby_sample
/arms_st.rb
UTF-8
98
2.953125
3
[]
no_license
a=123 len = a.to_s.length c = 0 puts len a.to_s.each_char{|b| c = c + b.to_i**len} puts c
true
41d6c33e7938ace9b54743d0e996aea1be6c1f94
Ruby
scottiler/rubybabble
/tile_group.rb
UTF-8
355
3.421875
3
[]
no_license
class TileGroup attr_accessor :tiles def initialize() @tiles = [] end def append(tile) @tiles << tile end def remove(tile) @tiles.delete_at(@tiles.index(tile)) end def hand hand = "" @tiles.each {|tile| hand += tile.to_s} return hand end def is_empty re...
true
0e7985655bcd1b855cf72a7a028a7faf04865911
Ruby
SiCuellar/Code_Wars
/Ruby/Isograms/algo.rb
UTF-8
331
3.265625
3
[]
no_license
require 'pry' class Algo def is_isogram(word) if word.downcase.chars.uniq!.nil? == true true else false end end end # def is_isogram(string) # string.downcase.chars.uniq == string.downcase.chars # end # def is_isogram(string) # letters = string.downcase.chars # letters == letters....
true
9f1fe0ec8f39fcf33bbeab56513a7ec2cb19cc3f
Ruby
cored/codingkatas
/ruby/find_sum/find_sum_spec.rb
UTF-8
781
3.3125
3
[]
no_license
require 'minitest/autorun' module FindSum extend self def call(array) array.each.with_index.inject(0) do |sum, (inner_array, idx)| sum += inner_array[idx % array.size] end end end describe FindSum do it 'returns the diagonal sum for a two dimensional array of lenght 4' do example_array = ...
true