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
faebe5d84edb7cbf44add2a824165c7da3d055a6
Ruby
pilarcormo/SNP_distribution_method
/Test/unit_tests_VCF.rb
UTF-8
1,885
2.671875
3
[]
no_license
#encoding: utf-8 require_relative '../lib/vcf' require_relative '../lib/write_it' require 'test/unit' class TestVCF < Test::Unit::TestCase def setup @vcf_ngs = "test/ngs.vcf" @chromosome = 1 @vcfs_info = {"ADP"=>"17", "WT"=>"0", "HET"=>"1", "HOM"=>"0", "NC"=>"0"}, {"ADP"=>"25", "WT"=>"0", "HET"=>"1", "HOM"=>"0"...
true
84cbaebfe75c8b2dbd452e0f04c104902544aa56
Ruby
deminew/remarkable
/lib/remarkable/active_record/macros/validations/validate_acceptance_of_matcher.rb
UTF-8
2,301
2.84375
3
[ "MIT" ]
permissive
module Remarkable # :nodoc: module ActiveRecord # :nodoc: module Matchers # :nodoc: class ValidateAcceptanceOfMatcher < Remarkable::Matcher::Base include Remarkable::ActiveRecord::Helpers undef_method :allow_blank, :allow_blank? arguments :attributes optional :accept ...
true
0194c4d8c1d72c6de23348fed4273a6b5ba49d18
Ruby
bikio/dpl-challenges
/ruby/person.rb
UTF-8
1,223
4.03125
4
[]
no_license
require_relative 'helper' class Person include Helper attr_accessor :attributes, :energy def initialize(attributes = {}) @attributes = attributes @energy = 10 end # This returns a string of the person's name def name attributes[:name] end # This returns a string of the person's first nam...
true
beb37cd4d2c0e91302ee346548c4a410ef5a9afc
Ruby
mv/aws-cf-builder
/lib/rake/for-all.rb
UTF-8
1,447
2.5625
3
[]
no_license
# vim:ft=ruby require 'json' ### ### Hack(?) ### namespace :'for-all' do desc "Usage: rake for-all:regions task='task-name'" task :regions do |task| if ! ENV.has_key?('task') printf "\n Error: you must define a task name.\n\n" exit end output = %x{ aws ec2 describe-regions \ ...
true
43cae66c9e8162deac22f694e67bd6bea5960ab5
Ruby
krunaljhaveri/RubyPost
/app/models/ability.rb
UTF-8
3,193
2.890625
3
[]
no_license
class Ability include CanCan::Ability def initialize(user) # Defines abilities for the passed in user here. For example: # # user ||= User.new # guest user (not logged in) # if user.admin? # can :manage, :all # else # can :read, :all # end # # The first argum...
true
741fda529b9bb9233aef689565e30658782fe391
Ruby
dimasumskoy/ruby
/part_1/task_4.rb
UTF-8
752
3.859375
4
[]
no_license
# Квадратное уравнение puts "Коэффициент a" a = gets.chomp.to_f puts "Коэффициент b" b = gets.chomp.to_f puts "Коэффициент c" c = gets.chomp.to_f d = b ** 2 - (4 * a * c) # Вычисляем дискриминант # Вычисляем корни, если они есть if d < 0 puts "Корней нет. Дискриминант равен #{d}" elsif d > 0 d_sqrt = Math.sqr...
true
8553c4ad63b0b9fe2c8bf9cbe9dcd2e751129cfc
Ruby
marlitas/war_or_peace
/lib/deck.rb
UTF-8
520
3.59375
4
[]
no_license
require 'pry' class Deck attr_reader :cards def initialize (cards) @cards = cards @high_cards = [] end def rank_of_card_at (index) @cards[index].rank end def high_ranking_cards @high_cards = @cards.select do |x| x.rank >= 11 end end def percent_high_ranking ((@high_card...
true
f9eaea9f1ba34751a03f15e6c16e7bcd9ee8d780
Ruby
darkzeroman/ruby-experiments
/FacebookHackerCupTry2.rb
UTF-8
701
3.21875
3
[]
no_license
cases = gets.chomp!.to_i def nCr(n,k) nfact = (1..n).inject(:*) kfact = (1..k).inject(:*) nminuskfact = (1..(n-k)).inject(:*) return nfact / (kfact * nminuskfact) end cases.times do |t| n_k = gets.split(' ').map{|i| i.to_i} n = n_k[0] k = n_k[1] arr = gets.split(' ').map{|i| i.to_i} next if ((n == 0)...
true
420e14e05e1a44ca325fae0633db0b6dac12603e
Ruby
venkataramana/Jquery-examples
/Ruby only/Triangles/descend.rb
UTF-8
249
3.078125
3
[]
no_license
arr=[4,7,1,6,5,9,3,8,0,2] #temp=[] for i in 0..arr.length-1 for j in (i+1)..arr.length-1 if(arr[i] < arr[j]) x=arr[i] arr[i]=arr[j] arr[j]=x end end # for i in 1..arr.length-1 # puts arr[i] end puts arr
true
0f364d4d460542797bb89f8f0b27bfb1aa8d6f68
Ruby
salamidrus/ruby_101
/files_io/writing_files.rb
UTF-8
412
3.21875
3
[ "MIT" ]
permissive
# Append data to a file # File.open("./files_io/data.txt", "a") do |file| # file.write("\nPutri, Developer") # end # Create new file # File.open("./files_io/index.html", "w") do |file| # file.write("<h1>hello world</h1>") # end # Read and write file File.open("./files_io/data.txt", "r+") do |file| file.re...
true
eb9b8a18ad43b67b98274d79437473ad81504b17
Ruby
Etsap/my-advent
/adventofcode2015/problem14.rb
UTF-8
981
3.234375
3
[]
no_license
input = "" File.open("input14.txt", 'r') {|f| input = f.read} inputdata, bestdistance, maxpoints = [], 0, 0 input.split(/\n/).each do |line| deer, speed, flyduration, restduration = line.match(/(\w+) can fly (\d+) km\/s for (\d+) seconds, but then must rest for (\d+)/).captures inputdata << {"speed" => speed.t...
true
a29cc0f41089b122714aa6102affad22e7da91e4
Ruby
RhysStansfield/ruby_prac
/ex5.rb
UTF-8
683
3.921875
4
[]
no_license
#! /usr/bin/env ruby name = 'Rhys Stansfield' age = 25 # not a lie height = 74 # inches weight = 180 # lbs eyes = 'Brown' teeth = 'White...ish' hair = 'Brown' height_cm = height.to_f * 2.54 weight_k = weight.to_f * 0.453592 puts "Lets talk about %s." % name puts "He's %d inches tall, or %d in centimeters." % [height,...
true
ebad6c459c5d35285899638237c34fe691a98cd9
Ruby
amhursh/battleship
/lib/computer_player.rb
UTF-8
2,868
3.296875
3
[]
no_license
require './lib/player' require './lib/validation' require './lib/board' require './lib/ship' require 'pry' class ComputerPlayer < Player include Validation attr_accessor :computer_board attr_reader :shells_fired, :computer_ships, :board_size def initialize(board_size) @board_s...
true
6189dc86a788fb5f966c4898ecfaa742560a8cce
Ruby
rocking42/Ruby-fun
/class_test/class.rb
UTF-8
416
3.8125
4
[]
no_license
require_relative 'student' class Class def initialize(name, teacher) @name = name.upcase @teacher = teacher.capitalize @class = [] end def add_student(student) @class << student end def year_up @class.each { |t| t.grade_up} end def all_students puts "There is #{@class.length} ...
true
1b8684b1d4b2a84234e7f502301d7a039d7ee362
Ruby
geoffyoungs/rack-magic-incoming-url
/lib/rack/magic-incoming-url.rb
UTF-8
1,589
2.90625
3
[ "MIT" ]
permissive
=begin Magic Incoming URL is a piece of rack middleware that redirects a URL to another one - but only when it's not from a local link. It's designed for sites that respond to multiple domains, where different domains should lead to different landing pages. e.g. You run Simon's Shoes and have two domains: simon...
true
f06049dd1cdc0131edd0007bae4c179d15149ed2
Ruby
jakedjohnson/DBC-highlights
/week-2/orange-trees-1/runner.rb
UTF-8
1,035
3.84375
4
[ "MIT" ]
permissive
require_relative 'orange' require_relative 'orange_tree' tree = OrangeTree.new # Let seasons pass until the tree is ready to bear fruit. tree.pass_growing_season until tree.mature? # Report yearly harvest information for the lifetime of the tree. until tree.dead? harvested_oranges = [] while tree.has_oranges...
true
506c33bccec7c4dcc722cf157e19d2e4e6af4228
Ruby
vecerek/css_compare
/lib/css_compare/css/value/url.rb
UTF-8
502
2.625
3
[ "MIT" ]
permissive
module CssCompare module CSS module Value # Wraps the SassScript `url` Funcall. class Url < Base # Checks, whether two url calls are equal. # # @param [Url] other the other url call # @return [Boolean] def ==(other) return false unless super ...
true
18bc599afff8b7e0a6f450d1d0ca2f282a1d4195
Ruby
PatreevIgor/NewCyberBot
/app/models/order.rb
UTF-8
2,698
2.53125
3
[]
no_license
class Order < ApplicationRecord def create_buy_orders(profitable_orders) profitable_orders.each do |order| Connection.send_request(format(Constant::CREATE_ORDER_URL, class_id: order_info_hash(order)[Constant::ITEM_HASH_CLASS_ID_KEY], in...
true
aa4dd06179dfcaa7893f6ff87df0ff95feb037be
Ruby
cbow27/lsrubybk
/Exercises/14.rb
UTF-8
181
2.796875
3
[]
no_license
a = ['white snow', 'winter wonderland', 'melting ice', 'slippery sidewalk', 'salted roads', 'white trees'] arr = [] a.each{|word| arr.push(word.split)} arr.flatten! print arr
true
e491f5b4fa0f29b6e3963ff417aa4d664b83acc5
Ruby
hmalueg/Cipher
/cipher.rb
UTF-8
1,571
3.90625
4
[]
no_license
require 'pry' # # cipher ==> regular function f(x) = (x+5) mod 26 # decipher ==> inverse f-(x) = (x-5) mod 26 # # one-to-one relationship between the key and value of a hash data structure # a gets mapped to 0, b gets mapped to 1, c gets mapped to 3 and so on # since we have a one to one relationship, we can do an in...
true
3d21cbcd5b8af79196c9e350511d48a57e725ebd
Ruby
jdliss/robot_world
/generate-world/generate.rb
UTF-8
702
2.671875
3
[]
no_license
require 'faker' require 'time' require_relative '../app/models/robot_world' class RobotWorldApp def robot_world world = Sequel.sqlite("db/robot_world.sqlite") @robot_world ||= RobotWorld.new(world) end end robot_world = RobotWorldApp.new.robot_world def generate_robot robot = { :name => Fake...
true
4a67114bac41eea30cb53d67115f48360bba4820
Ruby
MatteBru/prime-ruby-prework
/prime.rb
UTF-8
208
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Add code here! #require "pry" def prime? (num) return false if num <= 1 divisor = (2..Math.sqrt(num).to_i).to_a divisor.each do |div| return false if num % div == 0 end true end #binding.pry
true
b04688f1e8a015869f4bd1c1b9f0bc0e843e5ce4
Ruby
gitter-badger/admiral_stats
/app/controllers/ship_list_controller.rb
UTF-8
2,990
2.53125
3
[ "MIT" ]
permissive
class ShipListController < ApplicationController before_action :authenticate def index set_meta_tags title: '艦娘一覧' # URL パラメータ 'all' が true の場合は、未配備の艦娘も表示 if ActiveRecord::Type::Boolean.new.deserialize(params[:all]) @ships = ShipMaster.all.to_a else @ships = ShipMaster.where('implement...
true
931b230e88c0cd06180c0d51267506eff6b08708
Ruby
gmazelier/mongo-meta-driver
/ruby/lib/bson/int64.rb
UTF-8
611
2.671875
3
[]
no_license
# encoding: utf-8 module BSON # Represents a $maxKey type, which compares less than any other value in the # specification. # # @see http://bsonspec.org/#/specification # # @since 2.0.0 class Int64 # A boolean is type 0x08 in the BSON spec. # # @since 2.0.0 BSON_TYPE = 18.chr.force_encod...
true
5f4c70b58bba95f559aeee04b0583ffb79340cd0
Ruby
ttscott2/launch_school_book
/capitalize.rb
UTF-8
145
3.078125
3
[]
no_license
def capitalize(string) if string.length > 10 string.upcase else string end end p capitalize('tim') p capitalize('fastfoodnation')
true
5263377b7c688e43a190ca5ab67fb8088806772c
Ruby
TechLit/interview-kiosk
/data/catalog/setup.rb
UTF-8
476
2.53125
3
[]
no_license
#!/usr/bin/env ruby require 'csv' require 'pg' DB = PG.connect puts 'setup: creating books table' DB.exec <<~SQL create table books ( id serial primary key, uid varchar, title varchar, author varchar, category varchar) SQL puts 'setup: seeding books' sql = 'insert into books (uid, title, autho...
true
2b5dded7d5967d1002ef722ac039bc0393bb86c5
Ruby
msabrina/countdown-to-midnight-001-prework-web
/countdown.rb
UTF-8
317
3.546875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def countdown(number) number = 10 10. times do puts "#{number} SECOND(S)!" number = number - 1 end "HAPPY NEW YEAR!" end countdown(10) def countdown_with_sleep (num_secs) number = 10 10. times do puts "#{number} SECOND(S)!" number = number - 1 sleep 1 end end countdown(4)
true
ff5ee19bbe42938c7ec627e593790d187dc99e17
Ruby
tompng/mathfont
/mathfont.rb
UTF-8
9,657
2.65625
3
[]
no_license
module Font def self.register c, &block @faces ||= {} @faces[c.to_s] = Face.new &block end def self.face c @faces[c.to_s[0]] || @faces[c.to_s[0].downcase] || none end def self.none @none ||= Face.new{-1} end def self.aa_table [ 'MM#TT', 'Qd0V*', 'par<?', 'gu!:^'...
true
f6f134e7af84febbf2d46da6207562fcc0a3e9ff
Ruby
netarc/structured_object
/test/structured_object/serialize_test.rb
UTF-8
2,851
2.953125
3
[ "MIT" ]
permissive
require "test_helper" class SerializeTest < Test::Unit::TestCase class Foo < StructuredObject struct do uint16 :l1 uint16 :l2 int16 :l3 byte :a1, :array => {:fixed_size => 3} char :a2, :array => true struct :s1 do byte :x char :y end struct :s2, :...
true
a15915514b6901227a5ae9af71b68f520f6b204b
Ruby
stazman/ruby-collaborating-objects-lab-v-000
/lib/song.rb
UTF-8
472
3.171875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_accessor :name, :artist, :songs, :song def initialize(name) @name = name end def self.new_by_filename(filename) split_file_name_song = filename.split(" - ")[1] name = filename.split(" - ")[0] song = self.new(split_file_name_song) ...
true
9df55fd38b93d4ef68b571c057d766982f41d1fb
Ruby
AJFaraday/re-rpg
/scripts/declarative_battle.rb
UTF-8
2,899
3.75
4
[ "MIT" ]
permissive
# Combatants: alice, bob and charlie # their health is 10 # their damage is 2 # Each turn, a character chooses a target and attacks them. # attacking # They have a 90% chance to hit (nullify) # They have a 20% chance of a critical (x 2, multiply) # defending # They have a 50% chance to block (half damage, multiply) # ...
true
5dd447e2b815c4b5d22fff5c30fe5ae5c95186ab
Ruby
sahilbathla/tv_guide
/app/helpers/home_helper.rb
UTF-8
260
2.671875
3
[]
no_license
module HomeHelper # @param [TvShow] tv_show: Tv Show for which you need repeating days def repeating_days(tv_show) tv_show.repeats_on.split(',').uniq.map do |wday| ::Constants::DAYS_MAP[wday.to_i] end.join(', ') end end
true
4983bb2545b378ef5cee30aa790b660b247a2113
Ruby
oddruud/art-crawl
/image.rb
UTF-8
903
3.078125
3
[]
no_license
require 'RMagick' include Magick module ArtCrawl class Image attr_reader :img attr_reader :mean_color def initialize filename puts "analyzing image #{filename}..." begin @img = Magick::Image.read( filename )[0] rescue end unless @img.nil? puts @img.to_s @img =...
true
8bc371b9c05c93927d1c24302f6d5e6896f8c9ee
Ruby
yukijina/nyc-pigeon-organizer-online-web-prework
/nyc_pigeon_organizer.rb
UTF-8
450
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def nyc_pigeon_organizer(data) # write your code here! obj = Hash.new{|h,k| h[k] = {color: [], gender: [],lives: []}} data.each_with_object(obj) do |(key, value), obj| value.each do |item,array| array.each do |string| obj[string][:color] << item.to_s if key == :color obj[stri...
true
c2f529c62737c50f4117e36664efcb2c80eaa522
Ruby
yaqizhao/projet_THP
/Ruby/exo_09.rb
UTF-8
204
3.15625
3
[]
no_license
puts "Bonjour, c'est quoi votre prénom ?" user_first_name = gets.chomp puts "Après, c'est quoi votre nom de famille ?" user_last_name = gets.chomp puts "Bonjour, #{user_first_name} #{user_last_name} !"
true
1ce94de185c5b56ce4fbda61de8304ba64c31547
Ruby
sroop/Takeaway
/lib/takeaway.rb
UTF-8
715
3.28125
3
[]
no_license
require_relative './text.rb' class Takeaway include Text attr_reader :menu def initialize(menu = []) @menu = menu end def add_menu(menu) @menu << menu @menu end def view(menu) menu.view_menu end def user_input puts "Type the name of the dish:" @user_input_dish = gets.chomp puts "Type the q...
true
07a10e7d9c519a9ee42e0657f4e74dd2a9e30891
Ruby
ufo2mstar/cuker
/lib/cuker/helpers/writers/summary_x_l_writer.rb
UTF-8
2,831
2.859375
3
[ "MIT" ]
permissive
require_relative 'abstract_writer' require 'rubyXL' require 'rubyXL/convenience_methods' module Cuker class SummaryXLWriter < RubyXLWriter def initialize # @ext = '.xlsm' super @template_file_name = "template_excel_summary.xlsm" @log.debug "initing #{self.class}" end def make_new...
true
d731d81196ee35802fcf8edae0285d5af9450568
Ruby
HeyCampbell/GoParkYourself
/app/models/street_section.rb
UTF-8
1,478
2.765625
3
[]
no_license
class StreetSection < ActiveRecord::Base SYMBOLS_TO_BOROUGHS = {"M" => "Manhattan", "B" => "Bronx", "K" => "Brooklyn", "Q" => "Queens"} has_many :signs, :foreign_key => 'status_order', :primary_key => 'status_order' before_save :set_encoder_class, :set_encoder, :encode_cross_streets def borough_name SYMB...
true
1ee73aa7f43689b3496eaf4a0595912d1db89935
Ruby
randhirray/dell-cisconexus5k
/lib/puppet_x/cisconexus5k/ssh.rb
UTF-8
678
2.53125
3
[ "Apache-2.0" ]
permissive
#This class is responsible for SSH specific transport to the switch require 'puppet/util/network_device/transport/ssh' module PuppetX module Cisconexus5k class Ssh < Puppet::Util::NetworkDevice::Transport::Ssh #These switches require a carriage return as well, instead of just new line. So we override Pup...
true
6f7c795644fbd3b67583338a3e52f5e732988b58
Ruby
uranussg/aA_classwork
/W1D4/rspec_exercise_3/lib/part_2.rb
UTF-8
352
3.484375
3
[]
no_license
def element_count(arr) count = Hash.new(0) arr.each do |el| count[el] += 1 end count end def char_replace!(str, hash) str.each_char.with_index do |char, idx| if hash.has_key?(char) str[idx] = hash[char] end end str end def product_inject(arr) arr.inj...
true
3063744907a30396333b586e524bbbf60fb8071f
Ruby
SarahBunker/rb101_programming_foundations
/ruby_written_assessment_practice/practice_spot_8_11.rb
UTF-8
2,522
4.46875
4
[]
no_license
=begin Pete likes to bake some cakes. He has some recipes and ingredients. Unfortunately he is not good in maths. Can you help him to find out, how many cakes he could bake considering his recipes? Write a function cakes(), which takes the recipe (object) and the available ingredients (also an object) and returns the ...
true
880988f8506e7b8ffbb866a21aea7b5937cfd31c
Ruby
rafaelzuim/preflight-0.3.0
/lib/preflight/profile.rb
UTF-8
3,397
2.78125
3
[]
no_license
# coding: utf-8 module Preflight # base functionality for all profiles. # module Profile def self.included(base) # :nodoc: base.class_eval do extend Preflight::Profile::ClassMethods include InstanceMethods end end module ClassMethods def profile_name(str) ...
true
6b35b9bd4d787a8c3c8e3f9fcf1358ce9a72611a
Ruby
jekyll/jekyll
/lib/jekyll/utils/win_tz.rb
UTF-8
1,625
2.796875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Jekyll module Utils module WinTZ extend self # Public: Calculate the Timezone for Windows when the config file has a defined # 'timezone' key. # # timezone - the IANA Time Zone specified in "_config.yml" # # Returns a string ...
true
ef0fd0d1251d7e8a2828bc68a00f17a48571495d
Ruby
aigecko/Kemonomimi
/src/StatusWindow/Button.rb
UTF-8
496
2.5625
3
[]
no_license
#coding: utf-8 class StatusWindow::Button def initialize(str,name,x,y) @str=str @name=name @x=x @y=y @str_pic=Font.render_texture(str,20,*Color[:attrib_font]) @w,@h=@str_pic.w,@str_pic.h @button=Rectangle.new(@x,@y,@w,@h,Color[:attrib_val]) end def update_coord(x,y) @button.x=...
true
85395bb7a5791f6b2896d1b99e0902de5e16249e
Ruby
dcvezzani/zzt-parser
/zzt_parser.rb
UTF-8
1,702
2.796875
3
[]
no_license
require "rubygems" require "bundler/setup" require File.dirname(__FILE__) + "/models/zzt_game_header" require File.dirname(__FILE__) + "/lib/zzt_parser_utils" # require your gems as usual require "ruby-debug" class ZZTParser include ZZTParserUtils attr_accessor :game_file, :hex_array, :game_header, :game_boards...
true
2bdbc565d4bab89a12c8995e51b9a7318afb206b
Ruby
vvainio/ratebeer
/spec/models/brewery_spec.rb
UTF-8
1,702
2.75
3
[]
no_license
require 'rails_helper' describe Brewery do it 'has the name and year set correctly and is saved to database' do brewery = Brewery.create name: 'Schlenkerla', year: 1674 expect(brewery.name).to eq('Schlenkerla') expect(brewery.year).to eq(1674) expect(brewery).to be_valid end it 'without a name ...
true
92bd892b0fa954ec5deb721d236323f9eb961abb
Ruby
b-n/obs-control
/lib/obs_control/store.rb
UTF-8
1,038
2.90625
3
[ "WTFPL" ]
permissive
module OBSControl class Store def devices=(devices) @devices = devices @devices.each do |device| device.register -> (event, payload) { receive(event, payload) } end end # Called when an event is fired either by a device # # @param event [Symbol] The event being fired ...
true
5c1cc45182b635b3db62ed5af8705af0a323cdeb
Ruby
riverswb/event_reporter
/lib/event_manager.rb
UTF-8
879
2.875
3
[]
no_license
require 'csv' require 'sunlight/congress' require 'erb' Sunlight::Congress.api_key = "8ed8af10edf6473583d8878e183284f5" def legislators_by_zipcode(zipcode) Sunlight::Congress::Legislator.by_zipcode(zipcode) end # def save_thank_you_letters(id,form_letter) # # Dir.mkdir("output") unless Dir.exists? "output" #...
true
3b9878d05ebf90c2c85afb7c78a745bc5afdae95
Ruby
JulianCedric/programming-univbasics-nds-nds-to-insight-with-methods-nyc-web-030920
/test.rb
UTF-8
2,018
3.0625
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'directors_database' require 'pp' # Find a way to accumulate the :worldwide_grosses and return that Integer # using director_data as input # first_director_name = directors_database.first.values.first # first_director_hash = directors_database.find{ |x| x[:name] ==...
true
5a0cb04fe705843f9e70bcefc3d505104da6a54f
Ruby
jamaleh1111/launch_school
/introduction_to_programming/more_stuff/exception_handling.rb
UTF-8
889
4.21875
4
[]
no_license
# exception handling is a specific process that deals with errors in a manageable and predictable way. # Ruby has an Exception class that makes handling these errors much easier. # reserved words "begin", "rescue", "end" # exception_example.rb names = ['bob', 'joe', 'steve', nil, 'frank'] names.each do |name| ...
true
9391ed9363efb980a4151f6f337a7a907c71375b
Ruby
digideskio/momogs
/getCSVPercentageComplete.rb
UTF-8
4,350
2.734375
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'json' require 'pp' require 'time' require 'date' require 'mongo' require 'date' require 'parseconfig' MONGO_HOST = ENV["MONGO_HOST"] raise(StandardError,"Set Mongo hostname in ENV: 'MONGO_HOST'") if !MONGO_HOST MONGO_PORT = ENV["MONGO_PORT"] raise(StandardError,"Set Mon...
true
93c642fa13141253f949e22df456661420094f9b
Ruby
kbs5280/http
/lib/game.rb
UTF-8
702
3.671875
4
[]
no_license
class Game attr_accessor :answer, :guesses def initialize @answer = rand(1..100) @guesses = [] end def guess(number) guesses << number end def check_guess guess = guesses.last.to_i case when guess > 100 || guess < 1 "Please enter a number between 1 and 100." when guess <...
true
3efa3b16deeeb9b2d8ef5645aba77699daff70a7
Ruby
okayjeffrey/mongthu-sf
/Rakefile
UTF-8
2,481
3.328125
3
[]
no_license
require './environment' require 'csv' desc 'Import data from csv files into the database' task :import do soup_file = "soups-updates.csv" puts "Removing #{Soup.count} existing soups and importing new ones from #{soup_file}" # A transaction keeps us from really fucking things up. If any part of the code # fails...
true
0a9d1a04184ac50cee687aa686cfd6045dd7ea1c
Ruby
ACBullen/algorithms_pratice
/cracking_the_coding_interview/is_uniq.rb
UTF-8
510
3.9375
4
[]
no_license
#Given a string, determine if it has all unqique characters. #what do you do if you can't use other data structures? #using additional data structure, n space def is_unique? string alph_hash = {} string.each_char do |char| return false if alph_hash[char] alph_hash[char] = true end true end #without a...
true
806ca3cea0ac2b0949698d6cb08be05febf87cf5
Ruby
kriom/ray
/lib/ray/text_helper.rb
UTF-8
873
2.84375
3
[ "Zlib" ]
permissive
module Ray module TextHelper module_function if defined? ::Encoding # @param [String] string Any string # @param [String] enc Name of the encoding of String. Gueseed in 1.9. # # @return [String] String in Ray's internal encoding def internal_string(string, enc = "UTF-8") ...
true
feab624d25c711bbe7a688b99924002884453a97
Ruby
treinalinux/Logica_de_Programacao_com_Ruby
/dc/ruby_avancado/namespace_reverse_word.rb
UTF-8
248
2.96875
3
[]
no_license
# frozen_string_literal: true # module ReserveWorld module ReserveWorld def self.puts(text) # Kernel::puts text.reverse.to_s Kernel.puts text.reverse.to_s end end # ReserveWorld::puts 'The result is' ReserveWorld.puts 'The result is'
true
2fa1e0d98832bc355e60013ab02b384696d9f565
Ruby
844196/komono
/doseisan
UTF-8
1,005
2.828125
3
[]
no_license
#!/usr/bin/env ruby class Dosei def self.convert_doseisan_lang(string) before_dosei_char = ['い', 'き', 'く', 'さ', 'し', 'せ', 'そ', 'ち', 'つ', 'て', 'の', 'ひ', 'へ', 'み', 'も', 'や', 'ら', 'り', 'る', 'ん', 'ぎ', 'ぐ', 'ざ', 'じ', 'ぜ', 'ぞ', 'ぢ', 'づ', 'で', 'ば', 'び', 'べ'] after_dosei_char = ['Ɩı', '₹', 'ㄑ', 'ㄜ', 'ι', 'ㄝ', 'ƺ', '...
true
1ea2856c0295953b8190e7f7681962c88c33539c
Ruby
amirrajan/mana-duel
/lib/sokushi.rb
UTF-8
307
2.75
3
[]
no_license
=begin F = violet P = red S = green W = indigo D = yellow C = [blue, blue] (stab) = orange nothing () = Wait =end class Sokushi < Spell def initialize @type = :attack end def sequence [:red, :indigo, :red, :violet, :green, :green, :green, :yellow] end def damage 100 end end
true
99011d73758d0aedf8b074a8d87016fe30968f86
Ruby
xis19/leetcode
/1065.rb
UTF-8
198
3.0625
3
[]
no_license
def index_pairs(text, words) words.map { |word| 0.upto(text.length - 1) .select { |i| text[i..-1].start_with?(word) } .map { |i| [i, i + word.length - 1] } }.flatten(1).sort end
true
22edffdcdde0020999bb548d4b96cd100fc5653c
Ruby
costagavras/ruby-fundamentals-arrays-iterations
/ex10.rb
UTF-8
2,207
4.25
4
[]
no_license
# 1. Start out by creating the following hash representing the number of students in past Bitmaker cohorts: hh_bitmaker_students = { :cohort1 => 34, :cohort2 => 42, :cohort3 => 22 } # 2. Create a method that displays the name and number of students for each cohort. def show_vertical(my_hash) my_hash.each do |coh...
true
fec315d6291fe9a4888eb84e85a495eb5800b4e3
Ruby
Zhann/pr_bot
/app.rb
UTF-8
3,112
2.59375
3
[ "MIT" ]
permissive
require 'bundler' require 'json' Bundler.require Dotenv.load require_relative "lib/strategies/list_strategy.rb" require_relative "lib/strategies/teams_strategy.rb" require_relative "lib/strategies/tiered_strategy.rb" set :bind, ENV['BIND'] || 'localhost' # Let the library traverse all pages, most querries won't fetc...
true
7297f817253de2f92562b928260f5751b9c376b2
Ruby
CSheesley/cross_check
/lib/season_module.rb
UTF-8
1,384
2.84375
3
[]
no_license
module Season def teams_in_season(season) season = hash_games_by_season[season] teams = [] season.each do |game| teams << game.away_team_id teams << game.home_team_id end teams.uniq! end def create_reg_pre_hash(game_hash,team) h = Hash.new {|hash,key| hash[key] = 0} reg_ga...
true
33824daccdc309838292f7b12545408e38c50dfe
Ruby
tenderlove/remotehash
/lib/remotearray.rb
UTF-8
2,411
2.765625
3
[ "MIT" ]
permissive
require 'uri' require 'xmlrpc/client' require 'digest/sha1' require 'logger' class RemoteArray OPENDHT_URI = "http://openlookup.appspot.com/" def initialize key = Time.now.to_i, secret = key, uri = OPENDHT_URI uri = URI.parse(uri) @rpc = XMLRPC::Client.new3( :host => uri.host, :port => uri.p...
true
e4b703eb01cd4e6750bfd4a499067d5950150a27
Ruby
TCraig7/binary_translator
/test/binary_translator_test.rb
UTF-8
1,610
3.0625
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/binary_translator' class BinaryTranslatorTest < Minitest::Test def test_it_exists bt = BinaryTranslator.new assert_instance_of BinaryTranslator, bt end def test_it_can_translate bt = BinaryTranslator.new assert_equal "000001",...
true
4414fba3b5cc49936609bbebbd4d6358bd841850
Ruby
jhogan2072/cwscentral
/app/helpers/contacts_helper.rb
UTF-8
1,500
2.65625
3
[]
no_license
module ContactsHelper def find_last_date(new_assignment_param) current_date = DateTime.strptime(new_assignment_param["effective_start_date(1i)"] + "-" + new_assignment_param["effective_start_date(2i)"] + "-" + new_assignment_param["...
true
84863c58c3c3ff9f2fa9699f7b3f8f9293fc7537
Ruby
toddt67878/udemy-learn-to-code-with-ruby
/STRINGS/overwrite_characters_in_string.rb
UTF-8
712
4.15625
4
[]
no_license
thing = "rocket ship" p thing[0] p thing thing[0] = "P" # 0 index position gets overwritten and "r" turns into "P" p thing thing[1] = "a" p thing thing[9] = "o" p thing fact = "I love blueberry pie" fact[7, 4] = "rasp" p fact fact[7..10] = "blue" p fact fact[2..5] = "absolutely adore" p fact #case method deals wit...
true
f42b132bb2f0cea06e348b699a5d464c5dc87442
Ruby
mlongerich/url_shortener
/app/models/link.rb
UTF-8
1,087
3.046875
3
[]
no_license
# frozen_string_literal: true class Link < ApplicationRecord require 'uri' validates_presence_of :url, :short_url validates_uniqueness_of :url validates :short_url, uniqueness: { case_sensitive: false } validates :short_url, format: { with: /\w{6}/ } validates :short_url, length: { is: 6 } validate :v...
true
b73d1517dd290519a137801b26a989ca65c9b782
Ruby
oishi123/project
/app/models/student.rb
UTF-8
1,562
2.71875
3
[]
no_license
class Student < ApplicationRecord belongs_to :family has_many :registrations has_many :camps, through: :registrations validates :first_name , presence: true validates :last_name , presence: true validates :family_id , presence: true , numericality: { only_integer: true, greater_than: 0 } val...
true
12b7dcc60dce752bae2f1eb3c599cedc54331b8a
Ruby
samip-sharma/Mod1-project
/parsing_API/lyrics_API.rb
UTF-8
587
2.59375
3
[]
no_license
require "rest-client" require "pry" require "json" def lyricsAPI(artist, song) artist = artist.split(" ").join("_") song=song.split(" ").join("_") url = "https://private-anon-fa9f05909e-lyricsovh.apiary-proxy.com/v1/#{artist}/#{song}" lyrics_data = RestClient.get(url) hash = JSON.parse(lyrics_data.b...
true
672ce79dc02a690fe0f0dd42589d6ecb4099e158
Ruby
tristanharris/spikes
/typed_arrays/Arrays3.rb
UTF-8
2,605
3.265625
3
[]
no_license
class TypedArrayException < Exception end class Array def to_typed return if size == 0 type = self.first.class raise TypedArrayException.new('Cannot make typed array, cant do multi-dimension arrays') if type.kind_of? Array if self.any? { |obj| obj.class != type} raise TypedArrayException.new('Cannot...
true
0adaf12919c70fbeb71d55a012dc30412cab36be
Ruby
whtouche/wdi_2_ruby_sql_lab_hogwarts
/Ruby/houses.rb
UTF-8
171
2.625
3
[]
no_license
class Houses # attr def initialize(name:, animal:, points:) end end # Houses have a list of their students, and students hold a reference to the house they belong to
true
dfbb8994f0d812c4ee895345de2ae19a90e25f64
Ruby
codingcat1/to-do-ruby-again
/spec/toado_spec.rb
UTF-8
694
2.90625
3
[ "MIT" ]
permissive
require 'rspec' require 'task' require 'list' describe List do it "starts out with an empty list of tasks" do test_list = List.new "School stuff" test_list.tasks.should eq [] end it "can add tasks" do test_list = List.new "School stuff" test_task = Task.new "Learn Ruby", 1 test_list.add_task...
true
a5e3ee6e0fbba440140b0baaad95578835b33a5f
Ruby
SmartBear/gem-licenses
/lib/gem/licenses.rb
UTF-8
1,118
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "BSD-3-Clause" ]
permissive
module Gem def self.licenses licenses = {} config_path = File.expand_path('../../licenses/config.yml', __FILE__) config = YAML.safe_load(File.read(config_path)) Gem.loaded_specs.each_value do |spec| spec.licenses.map(&:downcase).each do |license| license_name = config[license] || license...
true
6db7d6ab90750a595d1e60de0a7f8e55f7999776
Ruby
wwslau/Manage_brown_field_VMS_B2M
/crxml.rb
UTF-8
2,269
2.8125
3
[]
no_license
require 'csv' def capture_managed_vm my_managed = 'csa_vm_details.txt' $managed_vm_array = Array.new # Load my_managed_vm into an array puts ("***********************") managed_vm = CSV.read(my_managed) managed_vm.shift managed_vm.shift managed_vm.each do |line| vm_name = line[0] vm_name = vm_nam...
true
7d18d4aa2f4cd1f807ceb512939bfe6622fa57f2
Ruby
Melodija/learn_to_program
/ch13-creating-new-classes/extend_built_in_classes.rb
UTF-8
485
3.96875
4
[]
no_license
class Integer def factorial if self <= 1 1 else self * (self-1).factorial end end def to_roman romans = { 1000 => "M", 500 => "D", 100 => "C", 50 => "L", 10 => "X", 5 => "V", 1 => "I", } numerals = [] num = sel...
true
0180945e42861b48c5bddf5ee00528afe66a9fbe
Ruby
kangdiyu/ics-bootcamp
/ch07/leapYearCounter.rb
UTF-8
325
3.671875
4
[]
no_license
puts 'Enter starting year: ' year_start = gets.chomp.to_i puts 'Enter ending year: ' year_end = gets.chomp.to_i puts 'Leap Year(s): ' year_test = year_start while year_test <= year_end if ( (year_test % 4 == 0) && (year_test % 100 != 0) ) || year_test % 400 == 0 puts year_test end year_test = year_test + 1...
true
dc91774da02ebe293daae66d5268c77d96d3695e
Ruby
HerrNeu/hw-sinatra-saas-hangperson
/lib/hangperson_game.rb
UTF-8
1,007
3.296875
3
[]
no_license
class HangpersonGame attr_accessor :word attr_accessor :wrong_guesses attr_accessor :guesses def initialize(word) @word = word @guesses = '' @wrong_guesses = '' end def guess(letter) raise ArgumentError unless letter =~ /^[a-z]$/i letter.downcase! if @word.include? letter r...
true
3b9d768f521673c685f8e2bddb13f103fd0d2e05
Ruby
samanthasanford/cartoon-collections-onl01-seng-ft-032320
/cartoon_collections.rb
UTF-8
624
3.34375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def roll_call_dwarves(dwarf_names)# code an argument here # Your code here dwarf_names.each_with_index{|dwarf, index| p "#{index+1}. #{dwarf}"} end def summon_captain_planet(planeteer_calls)# code an argument here # Your code here planeteer_calls.map{|string| string.capitalize + '!'} end def long_planeteer_ca...
true
25c5e0f65db9a01e346cfb0fe1b6b41bd4d97df0
Ruby
shibatasuguru0311/fleamarket_sample_79bb
/spec/models/item_spec.rb
UTF-8
2,924
2.71875
3
[]
no_license
require 'rails_helper' #空だと登録できないこと describe Item do it "is invalid without a name" do item = Item.new(name: nil) item.valid? expect(item.errors[:name]).to include("can't be blank") end it "is invalid without a price" do item = Item.new(price: nil) item.valid? expec...
true
192d705b771d661fc1f47aa6aad0b8f162bad3e2
Ruby
lightmotive/ls-book-ruby-intro
/loops_and_iterators/perform_again.rb
UTF-8
155
3.125
3
[]
no_license
# frozen_string_literal: true loop do puts 'Do you want to do that again?' answer = gets.chomp break unless %w[y yes].include?(answer.downcase) end
true
cf45a72f2f269ec053605c94f39d8ce9f51287aa
Ruby
piotrmurach/tty-runner
/lib/tty/runner/inflection.rb
UTF-8
349
2.59375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module TTY class Runner module Inflection # Convert snakecase string into camelcase # # @param [String] string # # @api public def camelcase(string) string.split("_").each(&:capitalize!).join end module_function :camelcase ...
true
28fd053f40bceac601a7a8160de43f4fd54edb45
Ruby
dieu-detruit/lecture-algorithm
/Week4/power.rb
UTF-8
355
3.203125
3
[]
no_license
# yは整数とし、0^0は未定義とする def power(x, y) begin raise RangeError if y.floor != y if y==0 then raise RangeError if x==0 return 1 elsif y>0 then prod = 1.0 y.times do prod *= x end return prod else prod = 1.0 (-y).times do prod /= x end end rescue RangeError => error p error ...
true
d50b94ee0c15d95881b6485819e3cdc3f845d877
Ruby
sophomorica/dpl_week1
/Homework/contact_list.rb
UTF-8
2,293
3.5625
4
[]
no_license
require "pry" @contacts = ["jack", "jill", "bob", "shirly", "fran"] def modify_contact puts "\n-------------------\nWhich Peep needs Changed?\n-------------------\n" @contacts.each_with_index do |f,i| puts "#{i +1 }) #{f}" end input = gets.strip.to_i puts "\n --------------------\n enter a new na...
true
f9a4b36c0cd69ce51b20cfacc31ecae3a62df6db
Ruby
krismacfarlane/godot
/w02/d06/instructor/enumerables.rb
UTF-8
360
2.96875
3
[]
no_license
require 'pry' arr = [ "patricio", "dflip" ] upcased_names = arr.map do |y| y.upcase end short_names = arr.select do |x| x.length < 6 end binding.pry class Celebrity < Human def initialize @solved = false end def setup solved end def take_out_trash super @tired = true ...
true
2c160e00267361f54327f25ebaeeab457ff826e1
Ruby
maoueh/buildozer
/lib/buildozer/cli/core/base.rb
UTF-8
3,398
3.03125
3
[ "MIT" ]
permissive
require 'optparse' require 'buildozer/helper/string' module Buildozer module Cli module Core class Base @@MAX_WIDTH = 70 def initialize(arguments = ARGV, options = {}) @arguments = arguments end ## # Specify the name of the command. Used as the default ...
true
74cf039a04a3beb44a293c871338be547a5f583f
Ruby
rcorre/dotfiles-old
/other/commit-msg
UTF-8
1,370
2.859375
3
[]
no_license
#!/usr/bin/ruby # This commit message hook will prefix commit messages with a tag indicating # their configuration area. # For example, commits that modify vim-related files will prefix the commit with # the tag [vim]. # This script will also reject a commit if changes are made to separate areas. # Use `git commit --...
true
2ef858cb10e6d6976abf545dc9fca70e354f10fd
Ruby
blolol/rpg
/app/models/battle.rb
UTF-8
1,600
2.75
3
[ "MIT" ]
permissive
class Battle include ActiveModel::Validations # Attributes attr_reader :challenger, :challenger_roll, :loser, :opponent, :opponent_roll, :pre_battle_challenger, :pre_battle_opponent, :winner # Delegates delegate :balance, :fairness, to: :fairness_calculator # Validations validates :challenger, acti...
true
e4f772478d22996380d37c16d98c965cdb5261cc
Ruby
chestercun/projeuler
/12.rb
UTF-8
385
3.5
4
[]
no_license
def divisors(n) ct = 2 mid = n/2 for i in 2..mid if n%i==0 ct+=1 end end return ct end triangle = {} triangle[:last] = 1 triangle[:num] = 1 desired = ARGV[0].to_i while (divisors(triangle[:num]) < desired) for i in 0..25 triangle[:last] += 1 trian...
true
7ecc6dff89aab3a0858df41ef1cb02930bd88fc1
Ruby
mecampbellsoup/codewars
/snail.rb
UTF-8
2,680
3.65625
4
[]
no_license
require 'pry' require 'minitest/autorun' class Element attr_reader :val attr_accessor :visited def initialize(val) @val = val @visited = false end end class Map attr_reader :data, :size, :result def initialize(array) @result = [] @size = array.size @data = [] array.each do |arr| ...
true
c6cb0242e536d361832bdee847ac23afdd11032d
Ruby
ALPHACamp/testing-demo-air-conditioner
/air_conditioner.rb
UTF-8
2,458
3.03125
3
[]
no_license
# 冷氣 class AirConditioner attr_accessor :ispower, :isopen, :timer def initialize @isopen = false @ispower = false @timer = 0 end def open! @isopen = true end # 出風口 def outlet_status if @isopen 'wind~~~' else 'nothing' end end # 檢查定時,改變冷氣狀態 def check_timer ...
true
9142f2e9ee9082dfb681d85d9e52c023047cc38e
Ruby
SwankForeigner5/331-Project-
/problem5.rb
UTF-8
1,016
4.03125
4
[]
no_license
# Statistics about a Matrix # require 'matrix' def matrix_stats(matrix) # Row and column sizes row_size = matrix.row_size.to_f col_size = matrix.column_size.to_f sum = 0.to_f print "Row Averages: " # Iterates over matrix rows 0.upto(row_size - 1) do |i| # Iterates over each element i...
true
f5fce0d9a4aecf449f3980e98de320ac91c2073b
Ruby
tyedye105/rfish
/lib/game.rb
UTF-8
517
3.390625
3
[]
no_license
class Game define_method(:initialize) do @deck = [] end define_method(:deck) do @deck end define_method(:create_deck) do ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks.each() do |rank| ...
true
e318027d3fd18df02be6dbcc806845a0c745da99
Ruby
jjdinho/fuel-economy-calculator
/app/controllers/cars_controller.rb
UTF-8
1,727
2.8125
3
[]
no_license
require 'pg' class CarsController < ApplicationController def year # Not necessary for single page app with full database... # cars = Car.select('year') # @years = cars.map do |car| # car.year # end # @years = @years.uniq.sort # render json: @years, callback: 'yearsQuery' end def...
true
344fd2921ecc5d58540b54e3dd11f813834e24a1
Ruby
bizchina/tocmd.gem
/lib/tocmd/markdown_render.rb
UTF-8
1,401
2.5625
3
[ "MIT" ]
permissive
require 'redcarpet' require 'pygments' require 'redcarpet' require 'rexml/document' module Redcarpet::Render class Custom < Base def header(title, level) @headers ||= [] title_elements = REXML::Document.new(title) flattened_title = title_elements.inject('') do |flattened, element| fla...
true
7f11dd652a5040ce9ff0aebfe49c37bf1973f676
Ruby
irmscher7353/yoyaku2011
/app/models/cart.rb
UTF-8
462
3.3125
3
[ "MIT" ]
permissive
# vim:ts=2:sw=2 class Cart attr_reader :name, :phone, :address, :items def initialize @name = "" @phone = "" @address = "" @items = [] end def add_product(product, quantity) current_item = @items.find {|item| item.product == product} if current_item current_item.increment_quantity(qua...
true
64f6b0e9ccf7a8d815874f11a32b77b7d135bedf
Ruby
vjoel/easy-serve
/examples/remote-run-script.rb
UTF-8
433
2.84375
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
class RemoteRunScript attr_reader :conns, :host, :log, :args def initialize conns, host, log, *args @conns = conns @host = host @log = log @args = args end def run conn = conns[0] log.progname = "run remote on #{host} with args #{args}" log.info "trying to read from #{conn.insp...
true
5d4ce4c366e3d531c43cc60dd915e54f80df5bc2
Ruby
SukritiSingal/login-count
/test/models/users_test.rb
UTF-8
4,249
2.859375
3
[]
no_license
require 'test_helper' class UsersTest < ActiveSupport::TestCase $SUCCESS = 1 $ERR_BAD_CREDENTIALS = -1 $ERR_USER_EXISTS = -2 $ERR_BAD_USERNAME = -3 $ERR_BAD_PASSWORD = -4 test "1 Sign up blank username" do code = User.add(username:"", password:"") assert (code[0] == $ERR_BAD_USERNAME), "Expected sign up...
true
55ffd2706b04d538380d76217d5da6fb870be203
Ruby
developwithpassion/fakes
/lib/fakes/class_swaps.rb
UTF-8
602
3.140625
3
[ "MIT" ]
permissive
require 'singleton' module Fakes class ClassSwaps include Singleton attr_reader :swaps def initialize @swaps = {} end def add_fake_for(klass, the_fake) symbol = klass.name.to_sym ensure_swap_does_not_already_exist_for(symbol) swap = ClassSwap.new(klass, the_fake) @...
true
bd4c196f7205bec11eb6ede07615826aa6000189
Ruby
rhday/deli-counter-onl01-seng-pt-030220
/deli_counter.rb
UTF-8
1,369
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def line(customers) if customers.length >= 1 new_array = [] index = 1 customers.each do |name| new_array << "#{index}. #{name}" index += 1 end puts "The line is currently: #{new_array.join(" ")}" else puts "The line is currently empty." end end def tak...
true
858643d29a9b117983e060a22e6b6d69ec99e63e
Ruby
Ermelo1983/pizzeria
/storage.rb
UTF-8
497
2.953125
3
[]
no_license
require './ingredient' class Storage def initialize @items = [ ingredient.new(ingredient::TOMATO, 8), ingredient.new(ingredient::DOUGH, 2), ingredient.new(ingredient::TOMATO, 8), ingredient.new(ingredient::TOMATO, 8) ] end def fetch(ingredients) ingredients.each do |ingredient...
true