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
6914dff57c2af85b8a86eaa35ff26239ed0cf699
Ruby
sbfaulkner/exercism
/ruby/sum-of-multiples/sum_of_multiples.rb
UTF-8
213
2.78125
3
[]
no_license
class SumOfMultiples def initialize(*factors) @factors = factors end def to(limit) (1...limit).select { |i| @factors.any? { |f| (i % f).zero? } }.sum end end module BookKeeping VERSION = 2 end
true
263a3a5e2c0597fe52b6fe8c973740ba0670797c
Ruby
IMRAN104/thinknetica-rails
/app/models/car/first_class_car.rb
UTF-8
315
2.71875
3
[]
no_license
class FirstClassCar < PassengerCar validates :lower_seats, numericality: { greater_than: 0 } validates_each :upper_seats, :upper_lateral_seats, :lower_lateral_seats, :sitting_seats do |record, attr, value| record.errors.add(attr, 'must be equal zero for this type of car!') if value.to_i > 0 end end
true
12de298a6cf90a03cef852decfc335877c2c9531
Ruby
lmjcbs/top-companies-CLI
/lib/top_companies_CLI/location.rb
UTF-8
348
3.015625
3
[ "MIT" ]
permissive
class Location extend Findable attr_accessor :companies attr_reader :name @@all = Array.new def initialize(location) @name = location @companies = Array.new @@all << self end def companies @companies end def self.names self.all.map { |location| location.name } end def s...
true
e2efc4ef0787a0c22d0b988cea0a9d52d72d7c61
Ruby
kukushkin/kplay
/lib/kplay/system.rb
UTF-8
2,160
2.640625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'open3' module Kplay # # Common system extensions # module System def self.included(base) base.send :extend, ClassMethods end # Class level methods module ClassMethods DEFAULT_SH_OPTS = { echo: true, output: true, tty: ...
true
d82b92564c9b9882e4489e7864949c3d376575a8
Ruby
jpr5/fu
/common/ruby/utils/hash.rb
UTF-8
12,176
2.84375
3
[]
no_license
require 'active_support' require 'active_support/core_ext/class/attribute_accessors' require 'active_support/core_ext/hash' module FU module Utils module Hash extend self def included(klass) klass.class_eval do include InstanceMethods ...
true
bb0b20ccaf3fbe88944aff0dec9d70d5b009fdc8
Ruby
jajapop-m/algorithm
/1_09_B_MaximumHeap.rb
UTF-8
2,110
3.9375
4
[]
no_license
# 最大・最小ヒープ # 与えられた配列からmax-ヒープを構築するプログラム(max-ヒープ条件:節点のキーがその親のキー以下である) # 入力例 # 10 # 配列のサイズH # 4 1 3 2 16 9 10 14 8 7 # 出力例 # max-ヒープの節点の値を節点の番号が1からHに向かって順番に一行で表示(各値の直前に一つの空白文字) # 16 14 10 8 7 9 3 2 4 1 class HeapData attr_accessor :value def initialize(value) @value = value end end class Heap < Array ...
true
449ee3ad268e2f16e793a313735b81532e4aedc6
Ruby
muffin-men/Ruby_Book
/chapter_4/range.rb
UTF-8
2,092
4
4
[]
no_license
# 範囲オブジェクト # include?メソッド # 引数の値に含まれているか判定できるメソッド # ..は5が範囲に含まれる(1以上5以下) range = 1..5 p range.include?(4.9) p range.include?(5) p range.include?(6) # ...は5が範囲に含まれない(1以上5未満) range = 1...5 p range.include?(4.9) p range.include?(5) p range.include?(6) # 範囲オブジェクトを変数に入れず直接呼び出す場合は()で囲む p (1..5).include?(5) # 配列に対して範囲オブジェク...
true
3753471fad2bb84a25cae0546f8c3fcf11775ae7
Ruby
jeffnv/AA_prep
/coding_challenge_2/practice-problems/lib/09_scientific_notation.rb
UTF-8
376
3
3
[]
no_license
def get_rounded_num_as_s(num) result = '' return end def sci_not(num) result = "" mag = num.to_s.length if(mag < 3) result = num.to_s (3 - mag).times do result += "0" end else temp = num.to_f (mag - 3).times do temp /= 10 end result = temp.round.to_s end ...
true
168459af1b2d6fc7fe75268586e63eafd1db6b02
Ruby
Nick-Son/Binder
/house.rb
UTF-8
3,036
3.6875
4
[]
no_license
# Required gems require 'pry' require 'terminal-table' class House attr_accessor :contact_name, :email, :password, :phone, :house_number, :street, :bins, :total_bin_space def initialize(house = {}) @contact_name = house[:contact_name] @house_number = house[:house_number] @street = house[:street] @...
true
c4cbb4264e67a80ce728eafc9bd99381bc36c2d5
Ruby
dsander/huginn
/app/models/agents/twitter_search_agent.rb
UTF-8
3,346
2.671875
3
[ "MIT" ]
permissive
module Agents class TwitterSearchAgent < Agent include TwitterConcern can_dry_run! cannot_receive_events! description <<-MD The Twitter Search Agent performs and emits the results of a specified Twitter search. #{twitter_dependencies_missing if dependencies_missing?} If you want ...
true
0802136e15456a5bd7d022d75e4df3b3ee35a627
Ruby
julemagne/coursyl-improvements
/db/seeds.rb
UTF-8
12,977
2.640625
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 rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
39cdd77a35b991573c3a9f93c94dbea220fdc5a3
Ruby
jenmerritt/wk02-d1-bus_stop_lab
/specs/bus_stop_spec.rb
UTF-8
622
2.703125
3
[]
no_license
require('minitest/autorun') require('minitest/reporters') Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new require_relative('../person') require_relative('../bus_stop') class BusStopTest < Minitest::Test def setup @person = Person.new("Julia", 47) @bus_stop = BusStop.new("Castle Terrace") e...
true
7b270b42d25083547dbd25a84194ff6cfad2a235
Ruby
tarrinros/market
/lib/product_collection.rb
UTF-8
882
3.171875
3
[]
no_license
class ProductCollection def self.from_dir(current_path) files_list = Dir.glob("#{current_path}/data/*/*.txt") self.new(files_list) end def initialize(files_list) @collection = [] files_list.each do |path| if path.include?("books") @collection << Book.from_file(path) elsif p...
true
ffe6d48f3c96480335879e01d49f9c5e412d27a9
Ruby
TomWerner/hw2fall15
/lib/part2.rb
UTF-8
1,164
3.265625
3
[]
no_license
class WrongNumberOfPlayersError < StandardError ; end class NoSuchStrategyError < StandardError ; end class PlayerFormatError < StandardError ; end class MisformattedTournamentError < StandardError ; end def rps_game_winner(game) raise WrongNumberOfPlayersError unless game.length == 2 raise PlayerFormatError unles...
true
4b2adcb8732e0c7b13754008374deef331dcd24b
Ruby
cielavenir/codeiq_solutions
/thisweek_masuipeo2/tyama_codeiq2417.rb
UTF-8
310
2.875
3
[]
no_license
#!/usr/bin/env ruby $memo={} def dfs(n) n<0 ? 0 : n==0 ? 1 : $memo[n]||=(2..5).reduce(0){|s,e|s+dfs(n-e)} end def solve(n) n<=1 ? 0 : (n%2..2).reduce(0){|s,e|s+dfs(n/2-e)} end if __FILE__==$0 N=gets.to_i i=2 r=0 while i*i<=N if N%i==0 r+=solve(i) r+=solve(N/i) if i*i!=N end i+=1 end p r end
true
a10101b2d12e4236b34f548b94270269c97e644b
Ruby
gabytzubaws/ruby_exercises
/bubble_sort.rb
UTF-8
617
3.796875
4
[]
no_license
def bubble_sort array for i in 0..array.length-1 for j in i..array.length-1 if(array[i] > array[j]) temp = array[i] array[i] = array[j] array[j] = temp end end end array end #print bubble_sort [4,3,78,2,0,2] def bubble_sort_by array for i in 0..array.length-1 fo...
true
6d6d50eca717fc97c474050e46056c3a5ee64040
Ruby
AnnaVinnik/Diploma
/PatersonWorms.rb
UTF-8
6,788
2.9375
3
[]
no_license
require 'ruby2d' set width: 850 set height: 700 set background: '#dbd7d2' class Worms def init #Спрашивать у пользователя @start_point = [0, 0] puts "Введите правила" enter = gets.chomp @rule = enter.chars.map {|c| c.to_i } p @rule @count_rule = @rule.size @rule_status = Array.new(...
true
eae3a182f3ccc1a3b1632b833b029669bc0805b7
Ruby
mixelpixel/stackoverflow
/ruby/csv.rb
UTF-8
1,731
3.921875
4
[]
no_license
# http://stackoverflow.com/questions/39785203/ruby-if-boolean-true-return-first-name-from-same-row-csv/39786166#39786166 # require 'csv' # def customer_check(user_pin) # x = false # puts x # CSV.read('customers.csv', headers: true).any? do |row| # x = true if row['customerNo'] == user_pin and row[...
true
5351e901192f6440a7dfd626260d0a99746cfb7b
Ruby
megumiyamauchi/bewd_homework
/99bottle.rb
UTF-8
758
3.953125
4
[]
no_license
puts "99 bottles of beer" num_bottles = 99 while(num_bottles > 1) do puts "#{num_bottles} bottles of beer on the wall, #{num_bottles} bottles of beer." num_bottles = num_bottles -1 puts "Take one down and pass it around, #{num_bottles} bottles of beer on the wall" if num_bottles == 1 puts "Take one down and pass ...
true
094493ae25e3551a5ebec7b4fb6321cb617665f2
Ruby
ranjith0044/task2
/var4.rb
UTF-8
206
3
3
[]
no_license
a=(1..50).to_a.each do |element| if(element%2).zero? if(element%3).zero? print "element #{element} is: hush hush \n" else print "element #{element} is: huff huff \n" end end end hi this is text file
true
f0896520c4eeb1594a99ffaf0f5149cddd92ddf3
Ruby
RobertoBarros/batch_513_cookbook_day_one
/lib/scrape.rb
UTF-8
730
3.15625
3
[]
no_license
require 'nokogiri' require 'open-uri' puts "Enter ingredient:" ingredient = gets.chomp url = "https://www.allrecipes.com/search/results/?wt=#{ingredient}" doc = Nokogiri::HTML(open(url), nil, 'utf-8') results = [] doc.search('.fixed-recipe-card').first(5).each do |card| name = card.search('h3').text.strip url ...
true
4713f7cf5ef9f91caa93546df050b5b11f7f28bc
Ruby
tamu222i/ruby01
/tech-book/3/3-59.rb
UTF-8
82
2.578125
3
[]
no_license
# 破壊的メソッドの例 v1 = "foo1" v2 = v1 p v1.chop p v2 p v1.chop! p v2
true
f89b56f5402839bc854084a62203296782d12097
Ruby
anclist/classroom-seat-reinforcement
/exercise.rb
UTF-8
549
3.484375
3
[]
no_license
classroom_seats = [ [nil, "Pumpkin", nil, nil], ["Socks", nil, "Mimi", nil], ["Gismo", "Shadow", nil, nil], ["Smokey","Toast","Pacha","Mau"] ] classroom_seats.each_with_index do |row, index| row.each_with_index do |name, seat| if name == nil p "Row #{index + 1} seat #{seat + 1} is free." p "D...
true
16f4cedc1819d3d6f1ab23098f72bc75bfbc69e6
Ruby
homeshift/OpenlyLocal
/test/unit/name_parser_test.rb
UTF-8
7,190
2.640625
3
[]
no_license
require File.expand_path('../../test_helper', __FILE__) class NameParserTest < ActiveSupport::TestCase OriginalNameAndParsedName = { "Fred Flintstone" => {:first_name => "Fred", :last_name => "Flintstone"}, "Fred Bob Flintstone" => {:first_name => "Fred Bob", :last_name => "Flintstone"}, "Fred-Bob Flints...
true
4b31d9224db59a52ad8fcec784d6bc6b1364ac90
Ruby
ardusthebobcat/Contact
/lib/mail.rb
UTF-8
383
2.84375
3
[]
no_license
class Mail @@addresses = [] #initialize define_method(:initialize) do |street,city,state, zip, type| @street = street #street @city = city #city @state = state #state @zip = zip #zip @type = type#type (home, work, other) end define_method(:save) do @@addresses.push(self) end defi...
true
0989359033782636c300abf92b01cab425036903
Ruby
heatherjc07/seven_languages_in_seven_days
/Ruby/Day3/acts_as_csv_module_modified.rb
UTF-8
1,188
3.265625
3
[]
no_license
module ActsAsCsv def self.included(base) base.extend ClassMethods end module ClassMethods def acts_as_csv include InstanceMethods end end module InstanceMethods def read @csv_contents = [] filename = self.class.to_s.downcase + '.txt' file = File.new(filename) @h...
true
149487a3ff6d89eb85ae7578aa33baa922895a1f
Ruby
MajesticForReal/THP
/day_13/lib/dark_trader.rb
UTF-8
968
3.21875
3
[]
no_license
require 'nokogiri' require 'open-uri' def get_name url = "https://coinmarketcap.com/all/views/all/" page = Nokogiri::HTML(URI.open(url)) name = page.xpath('//*[@class="cmc-table-row"]//td[3]/div').map{|element| element.text} return name end #Recuperation des noms de devise. def get_value url = "https://coinmark...
true
70f87a18af6321e66e2bb375ffba7d7f2376708a
Ruby
Maheshkumar-novice/Custom-Enumerables
/tests/all-vs-my_all.rb
UTF-8
1,297
3.515625
4
[]
no_license
#!/usr/bin/env ruby # frozen_string_literal: true require_relative '../custom-enumerables' puts '=====================' puts 'all? vs my_all?' puts '=====================' numbers = [1, 2, 3, 4, 5] puts 'all?' p(numbers.all? { |_item| true }) p(numbers.all? { |_item| false }) p(numbers.all? { |_item| nil }) p(numbers...
true
e9178c1834a239daabe2e242a9e5726c935ce659
Ruby
stjordanis/ruby-sslyze
/lib/sslyze/xml/certinfo/certificate_validation/path_validation.rb
UTF-8
1,946
2.546875
3
[ "MIT" ]
permissive
require 'sslyze/xml/plugin' require 'sslyze/xml/types' require 'sslyze/xml/attributes/error' module SSLyze class XML class Certinfo < Plugin class CertificateValidation # # Represents the `<pathValidation>` XML element. # # @since 1.0.0 # class PathValidation...
true
b93d0621fc307379265cdfbd24af790761323a98
Ruby
nelsonjchen/cloudfiles_streamer
/lib/cloudfiles_streamer/segmented_stream.rb
UTF-8
907
3.171875
3
[ "MIT" ]
permissive
module CloudFilesStreamer class SegmentedStream attr_reader :file, :segment_size, :bytes_read, :total_bytes_read def initialize(data, segment_size) @file = data @segment_size = segment_size @bytes_read = 0 @total_bytes_read = 0 end def read(length) reset_bytes_read! and...
true
87d362bf5aab2fcfcadf3678b9b6c421ae3f6bad
Ruby
h4hany/leetcode
/solutions/146_lru_cache.rb
UTF-8
750
3.625
4
[]
no_license
class LRUCache # :type capacity: Integer def initialize(capacity) @capacity = capacity @cache = {} end # :type key: Integer # :rtype: Integer def get(key) return -1 unless @cache.key?(key) val = @cache[key] @cache.delete(key) @cache[key] = val val end # :typ...
true
297eac597c05640ebeade08aaa63d235b8d4c812
Ruby
meisyal/sastrawi-ruby
/lib/sastrawi/stemmer/context/context.rb
UTF-8
5,139
2.90625
3
[ "MIT", "CC-BY-NC-SA-3.0" ]
permissive
require 'sastrawi/stemmer/confix_stripping/precedence_adjustment_specification' ## # Stemming context using Nazief and Adriani, Confix Stripping (CS), # Enhanced Confix Stripping (ECS), and Improved (ECS) module Sastrawi module Stemmer module Context class Context attr_reader :original_word, :dict...
true
6145d34706c1280335613a4bea3ec5cfcaeb4ab3
Ruby
tooky/otb-academy-oct-2015
/the-language/lib/trainer.rb
UTF-8
485
3.125
3
[]
no_license
module Trainer class FillMeIn def initialize(caller_line) if (match = caller_line.match(/^(?<file>.+?):(?<line>\d+)/)) @file = match["file"] @line = match["line"] else raise ArgumentError, "#{caller_line} does not match caller spec" end end def location [@f...
true
6addb501047affe2059b122c59fa3d61ce35ae09
Ruby
thomasjnoe/re-former
/test/models/user_test.rb
UTF-8
740
2.515625
3
[]
no_license
require 'test_helper' class UserTest < ActiveSupport::TestCase def setup @user = User.new(username: "Test User", email: "test@test.biz", password: "test123", password_confirmation: "test123") end test "should be valid" do assert @user.valid? end test "username should be present" do @user.username...
true
5264c53f23de217bc0aa050f0356d05ab673c3ff
Ruby
benrodenhaeuser/repetitions
/109_prep/small_problems/0603.rb
UTF-8
1,312
5.28125
5
[]
no_license
# Write a method that calculates and returns the index of the first Fibonacci number that has the number of digits specified as an argument. =begin examples (see tests below): - the index of the first fibo number that has two digits is 7 (i.e., the 7th fibo number). - the index of the first fibo number that has 10 d...
true
97ebdeeab9847a3fc58bbc3d7c1b3f8f76b9cb47
Ruby
angelinasongco/learn-co-sandbox
/loop_example.rb
UTF-8
366
3.109375
3
[]
no_license
# loop do # puts "nyan" # break # end #counter + 1 #while counter < 11 # puts counter #counter = counter + 1 #end #def hungry_sb # kitkat = 0 #while < 30 #puts "Give me another kitkat!" #kitkat += def hungry_person mango= 0 until mango == 10 puts "Give me my mango! i only want #{mango}"...
true
d5f99acc821997a82f2b4f00fa4f6f428fe61fc2
Ruby
drogus/ifirma-api
/lib/ifirma/auth_middleware.rb
UTF-8
1,008
2.53125
3
[]
no_license
class Ifirma class AuthMiddleware < Faraday::Response::Middleware attr_reader :username, :invoices_key def initialize(app = nil, options = {}) super(app) @options = options @username = @options.delete(:username) @invoices_key = decode_key(@options.delete(:invoices_key)) end ...
true
12e4a5b92f164ce2b58a62c0190ce88064a1f5e7
Ruby
flori/more_math
/lib/more_math/cantor_pairing_function.rb
UTF-8
1,052
3.234375
3
[ "ICU", "MIT" ]
permissive
module MoreMath module CantorPairingFunction module_function def cantor_pairing(*xs) if xs.size == 1 and xs.first.respond_to?(:to_ary) xs = xs.first.to_ary end case xs.size when 0, 1 raise ArgumentError, "at least two arguments are required" when 2 x, y,...
true
3b9736281348e459371039e0cf8354c8efc41256
Ruby
NevadaCode/scratchpad
/irc_server.rb
UTF-8
2,333
3.21875
3
[]
no_license
require 'socket' server = 'moon.freenode.net' port = 6667 socket = TCPSocket.open(server, port) nickname = 'TheHappyBot' channel = '#NevadaCode123' socket.puts "NICK #{nickname}" socket.puts "USER #{nickname} 0 * #{nickname}" socket.puts "JOIN #{channel}" socket.puts "PRIVMSG #{channel} :Hi, how are you today?" mes...
true
1dde308a24fcf7d5cba35507a062c0e92313e01f
Ruby
Skech7/saltedge_courses_2019
/teliucov/lesson9/json.rb
UTF-8
668
3.125
3
[]
no_license
require 'json' @first_names = [] @last_names = [] File.open('imputs.txt').each do |line| full_name = line.split @first_names << full_name[0] @last_names << full_name[1] end @combined = {} def name_randomizer @first_names.each_with_index do |f_name, f_index| @last_names.each_with_index do |l_name, l_index| ...
true
a64d61065e4f657e03ac48a0b98ff38912eb95c0
Ruby
staugaard/rupi
/lib/rupi/pin.rb
UTF-8
2,465
3.21875
3
[ "MIT" ]
permissive
require 'wiringpi' module Rupi class Pin class GPIO < WiringPi::GPIO def pullUpDnControl(pin, pud) Wiringpi.pullUpDnControl(pin, pud) end end attr_reader :number, :up_handlers, :down_handlers def initialize(number) @number = number @up_handlers = [] @down_h...
true
da45af46ed0f138311e13c1290b706553b36f665
Ruby
LucianoCordeiro/VegPlacesCuritiba
/app/helpers/places_helper.rb
UTF-8
245
2.578125
3
[]
no_license
module PlacesHelper def places_count Place.count end def search_count if @places.count > 0 "Sua busca gerou " + pluralize(@places.count, "resultado") else "Nenhum estabelecimento foi encontrado" end end end
true
e7dcefdc56ef03b5b25486e3016b5e9da76d0fa4
Ruby
ndalcin/flatiron-store-project-v-000
/app/models/cart.rb
UTF-8
518
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Cart < ActiveRecord::Base has_many :line_items has_many :items, through: :line_items belongs_to :user def total sum = 0 self.line_items.each do |line_item| price = line_item.item.price quantity = line_item.quantity sum += (price*quantity) end sum end def add_item(i...
true
dd2231b96cf59ea2c86c9ffe66f680a041c906f9
Ruby
talentnest/schema-dot-org
/lib/schema_dot_org/postal_address.rb
UTF-8
939
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'schema_dot_org' module SchemaDotOrg # Model the Schema.org `Thing > Intangible > StructuredValue > ContactPoint > PostalAddress`. # See http://schema.org/PostalAddress class PostalAddress < SchemaType attr_accessor :street_address, :address_locality, :address_region, :...
true
5de5759788130877367a8fff8e05e3a0d6486cf2
Ruby
Kangb0tmang/wdi_project_2_food_tracker_app
/main.rb
UTF-8
5,606
2.671875
3
[]
no_license
require 'sinatra' require 'sinatra/reloader' require 'pg' require 'pry' require_relative 'db_config' require_relative 'models/food_item' require_relative 'models/guide' require_relative 'models/storage_type' require_relative 'models/user' # Sessions to remember current_user enable :sessions #========================...
true
d7db99d87cde69418555804efc9b432e9d85d763
Ruby
jhsu802701/generic_app_old
/bin/generic_app
UTF-8
1,030
2.546875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'generic_app' def get_input(default_value) value_input = gets.chomp if value_input == '' default_value else value_input end end puts '***********************' puts 'Welcome to Generic App!' puts default_subdir = 'tmp9' puts puts "DEFAULT VALUE: #{default_subdir}" puts 'En...
true
500e845f8a6379d741d538271a0e7a4f103dd97e
Ruby
dkubb/axiom-optimizer
/lib/axiom/optimizer/function/binary.rb
UTF-8
2,785
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# encoding: utf-8 module Axiom class Optimizer module Function # Mixin for optimizations to Binary functions module Binary # The optimized left operand # # @return [Object] # # @api private attr_reader :left # The optimized right operand ...
true
f244f79de30ec0c046a5da92c54c3e9683106aea
Ruby
erplsf/wallbase_scraper
/application.rb
UTF-8
2,579
2.765625
3
[ "MIT" ]
permissive
require 'rubygems' require 'bundler/setup' require 'mechanize' require 'parallel' require 'ruby-progressbar' # require 'thread' class ImageScraper def initialize(hash = {}) @agent = Mechanize.new @logged_in = false @image_count = Hash.new(0) @links = Hash.new @progress = Hash.new @options = ...
true
ba416886d99a4b7370850c0aec2d752b21277f57
Ruby
nyluhem/nyalls_hemingway_pda
/pda_practice/hashes.rb
UTF-8
640
2.96875
3
[]
no_license
@pet_shop = { pets: [ { name: "Arthur", pet_type: :dog, breed: "Husky", price: 900, }, { name: "Tristan", pet_type: :dog, breed: "Basset Hound", price: 800, }, { name: "Merlin", pet_type: :cat, breed: "Egyptian Mau", price: 15...
true
21a7ded8fc945441c325415a5512fae124297e6e
Ruby
natwebb/ruby-cheers
/test/test_cheers_integration.rb
UTF-8
1,995
2.78125
3
[]
no_license
require_relative 'helper' class TestCheersIntegration < MiniTest::Unit::TestCase def test_a_regular_name actual_output = '' IO.popen('ruby cheers.rb', 'r+') do |pipe| pipe.puts 'Nat' pipe.close_write actual_output = pipe.read end expected_output = <<EOS What's your name? Give me a...
true
dc4be02efdf849d35b740f46d6afc96e544a30cc
Ruby
no-glue/greedy_ra_alogorithm
/lib/greedy_ra_algorithm.rb
UTF-8
2,543
3.265625
3
[ "MIT" ]
permissive
require "greedy_ra_algorithm/version" module GreedyRaAlgorithm class GreedyRaAlgorithm # gets distance between cities def euc_2d(c1, c2) Math.sqrt((c2[0] - c1[0]) ** 2.0 + (c2[1] - c1[1]) ** 2.0).round end # gets distance between two cities def cost(shake, cities) distance = 0 ...
true
f868f56cdc88e46c898e757338ff7265ab6b4106
Ruby
euxn23/bookmeter_scraper
/lib/bookmeter_scraper.rb
UTF-8
1,317
2.53125
3
[ "MIT" ]
permissive
require 'bookmeter_scraper/bookmeter' require 'bookmeter_scraper/configuration' require 'bookmeter_scraper/version' module BookmeterScraper ROOT_URI = 'http://bookmeter.com'.freeze LOGIN_URI = "#{ROOT_URI}/login".freeze USER_ID_REGEX = /^\d+$/ class << self def mypage_uri(user_id) raise ArgumentEr...
true
41e3243943005b0c8defbdbecf6dba13fe00d106
Ruby
darthmanwe/serif
/spec/lib/placeholder_spec.rb
UTF-8
1,160
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
RSpec.describe Serif::Placeholder do describe ".substitute" do specify { expect(Serif::Placeholder.substitute("foo", {})).to eq("foo") } specify { expect(Serif::Placeholder.substitute(nil, {})).to eq(nil) } it "makes substitutions using placeholders given by colons" do expect(Serif::Placeholder.sub...
true
f45f6bc87aed177c407d40c2889df37dd10dbab6
Ruby
cristinhpipok/ejercicios-ruby
/solutions/bmi.rb
UTF-8
234
3.546875
4
[]
no_license
print "Ingresa tu peso: " weight = gets.chomp.to_i print "Ingresa tu altura: " height = gets.chomp.to_f bmi = weight / height**2 puts puts "Tu BMI es #{bmi}" # para redondear a un único decimal # puts "Tu BMI es #{bmi.round(1)}"
true
d4842d6aaa4be933f94b0ae4b590a755847dfd02
Ruby
sodas43/Udemy
/DataAlgo_forPy/Mock_Challenges/search_engine/question1.rb
UTF-8
406
3.890625
4
[]
no_license
# Question # Given a dice which rolls 1 to 7 (with uniform probability), simulate a 5 sided dice. Preferably, write your solution as a function. # Requirements # You MUST do this on pen and paper or on a whiteboard. No actual coding is allowed until you've solved it on pen and paper! def simulate_roll(min = 1, max = ...
true
a6320c8c4469295a5fb6da1c98bcbd3aa5af64ec
Ruby
nmacawile/ruby_basics
/learn_to_program_ruby/chapter4a.rb
UTF-8
195
3.5625
4
[]
no_license
puts "What's your first name?" fname = gets.chomp puts "What's your middle name?" mname = gets.chomp puts "What's your last name?" lname = gets.chomp puts "Hello, #{fname+' '+mname+' '+lname}!"
true
29262cd4fdfaf13022251d1adf94e89050f3cef7
Ruby
rsnorman/avengersassemble
/lib/services/character_migration/character_csv_exporter.rb
UTF-8
559
2.90625
3
[]
no_license
require 'csv' class CharacterCSVExporter def initialize(filepath) @filepath = filepath end def export(characters) attrs_names = ModelAttributes.new(Character).attribute_names CSV.open(@filepath, 'wb') do |row| characters.each do |character| row << attrs_names.collect do |a| ...
true
00a428a6f1ff955bae1a3113d4ce5b1c99e5c81d
Ruby
chn-challenger/learn_to_program
/ch14-blocks-and-procs/better_program_logger.rb
UTF-8
931
3.359375
3
[]
no_license
def log desc, &block $indent ||= 0 #set to 0 unless already defined puts ' '*$indent+"Beginning #{desc.inspect}..." $indent += 1 result = block.call $indent -= 1 puts ' '*$indent+"...#{desc.inspect} finished, returning: #{result}" end def test log 'outer-block' do log 'inner-block1' do n = 100; n end...
true
872c3589a53e8eb2fcaa3bc834ca3d41c4f0b017
Ruby
coryb2424/code_snippets
/slot_machine/spec/slot_machine_spec.rb
UTF-8
2,476
2.953125
3
[]
no_license
require_relative '../lib/slot_machine' def test_scenario_reels(reels, expected_score) it "returns #{expected_score} for #{reels[0]}/#{reels[1]}/#{reels[2]}" do expect(slot_machine.send(:calculate_score, reels)).to eq expected_score end end describe SlotMachine do let(:slot_machine) { SlotMachine.new(100) } ...
true
e96be27e94b1277b791f4c36170bdfb47106848b
Ruby
tonywok/realms
/lib/realms/zones/explorers.rb
UTF-8
550
2.515625
3
[ "MIT" ]
permissive
module Realms module Zones class Explorers < Zone attr_reader :explorers def initialize(*args) super @explorers = (0..Float::INFINITY).lazy.map do |i| Cards::Explorer.new(owner, index: i) end end def cards [explorers.peek] end def re...
true
221b26db7c96b704af44928d01c247f88780b981
Ruby
inkydragon/gc
/ruby/coderwar/Moves in squared strings (I).rb
UTF-8
254
3.03125
3
[]
no_license
def oper(fct, s) fct.call(s) end def vert_mirror(s) s.split("\n").map(&:reverse).join("\n") end def hor_mirror(s) s.split("\n").reverse.join("\n") end s = "abcd\nefgh\nijkl\nmnop" p oper(method(:vert_mirror), s) p oper(method(:vert_mirror), s)
true
b7e9cfc1c16c3b3f6346d79537b4187118215bf6
Ruby
acrogenesis-lab/tdd101
/calculator_kata/spec/string_calculator_spec.rb
UTF-8
899
3.203125
3
[]
no_license
require 'spec_helper' require 'string_calculator' describe StringCalculator do describe '.add' do it 'will return 0 for an empty string' do expect(StringCalculator.add('')).to eq(0) end it 'will return 1 for "1"' do expect(StringCalculator.add('1')).to eq(1) end it 'will return 3 fo...
true
b9eee407b43a79265a7050e2c90ad3831d31b3a1
Ruby
famished-tiger/cukedep
/lib/cukedep/feature-model.rb
UTF-8
8,701
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# File: feature-model.rb require 'tsort' require 'csv' require 'erb' require 'pathname' module Cukedep # This module is used as a namespace # The internal representation of a set of feature files. # Dependencies: use topological sort # TSort module http://ruby-doc.org/stdlib-2.6/libdoc/tsort/rdoc/index.html # See als...
true
b3ffff98034ffc59710efe3856610551380de901
Ruby
zoso10/terrible
/config.ru
UTF-8
1,745
2.640625
3
[]
no_license
# frozen_string_literal: true require "pry-byebug" require "puma" require "rack" require "json" class Application USERS_PATH = "/users" def self.call(env) new(env).call end def initialize(env) @env = env end def call if env[Rack::REQUEST_METHOD] == Rack::POST && env[Rack::PATH_INFO] == USER...
true
7f806e4bfb709726e76b3e688c92aae94083c8e9
Ruby
AndresCMontejo/Curso_de_Ruby
/splat.rb
UTF-8
1,118
4.15625
4
[]
no_license
#OPERARDOR SPLAT def saludos_a_todos(extra,*saludar) #definimos nuestro metodo.., podemos marcar con un "*" el metodo #que queremos iterar, del lado izquiero colocamos otro metodo extra para agregar una palabra saludar.each {|saludo| puts "Que onda #{extra} #{saludo}"} #iteramos nuestro metodo, y "extra" p...
true
ce9e9d92c5fb5a3d810ee539fc03e0441a249b6e
Ruby
jorge8989/ruby-sdk
/lib/constantcontact/components/event_spot/event_address.rb
UTF-8
806
2.609375
3
[ "LicenseRef-scancode-dco-1.1", "MIT" ]
permissive
# # event_address.rb # ConstantContact # # Copyright (c) 2013 Constant Contact. All rights reserved. module ConstantContact module Components module EventSpot class EventAddress < Component attr_accessor :city, :country, :country_code, :latitude, :line1, :line2, :line3, :longitude, :postal_code, ...
true
a6740733a51033603ccd23a37681381402b2469e
Ruby
krayinc/mtp2
/lib/string/extender/html.rb
UTF-8
980
2.640625
3
[]
no_license
require 'cgi' require 'string/extender/common' class Regexp module Pattern module HTML BR = /<br(?:\s*\/)?>/i end end end class String module Extender module HTML def escape_html(*tags) if tags.empty? CGI.escapeHTML self else CGI.escapeElement self, ta...
true
96f68226ed453f51317b31579b346ee042e1e538
Ruby
agiegerich/hw2fall16
/spec/part5_spec.rb
UTF-8
526
3.390625
3
[]
no_license
require 'part5.rb' describe "CartesianProduct" do it "should exist" do # lambda { CartesianProduct.new(1..2,3..4) }.should_not raise_error expect(lambda { CartesianProduct.new(1..2,3..4) }).not_to raise_error end it 'should make the cartesian product' do cp = CartesianProduct.new(1..2, 3..4) arr ...
true
398e8b4b0804a404646a52659bb954c036c76614
Ruby
UgoMare/oop-06
/rooms_repository.rb
UTF-8
257
2.75
3
[]
no_license
class RoomsRepository def initialize @rooms = [] @next_id = 1 end def create_room(room) @rooms << room room.id = @next_id @next_id += 1 end def find(id) #CODE THE WAY TO FIND THE ROOM INSTANCE WITH THE ID `ID` end end
true
14bedf7b2fc725719390c28ad8968775453d80fa
Ruby
Blaise-Shyaka/Tic-tac-toe
/lib/player.rb
UTF-8
477
3.1875
3
[ "MIT" ]
permissive
# rubocop:disable Lint/Void # Description/Explanation of the Player class class Player attr_accessor :player_sign, :name, :warning def initialize @name @player_sign @warning end def valid_player_name(name) if name.length.zero? self.warning = 'Name cannot be empty' return false e...
true
c0025a2452b27263d0591ae5bf676a8dc03208eb
Ruby
unicornrainbow/backup-tools
/update_snapshot
UTF-8
939
2.59375
3
[ "MIT" ]
permissive
#! /usr/bin/env ruby # # Updates a backup snapshot. Based on http://www.mikerubel.org/computers/rsync_snapshots/ require 'logger' require 'fileutils' class MultiIO def initialize(*targets) @targets = targets end def write(*args) @targets.each {|t| t.write(*args)} end def close @targets.each(&...
true
500710e1a102a05c0f4ca6a7406bcc72b159f16c
Ruby
adamsanderson/qwandry
/lib/qwandry/repository.rb
UTF-8
1,477
3.03125
3
[]
no_license
module Qwandry # A Repository's primary responsibility is to return a set of Packages that # match the search criteria used in Repository#scan. # # Subclasses are expected class Repository attr_reader :name attr_reader :path attr_reader :options # Creates a Repository with a give name, ...
true
ac2c3a351bd1bf7d6ec2ba368b6fb218bc01d019
Ruby
michelleamazinglin/aA-classworks
/W2D2/pair/startup_project/lib/startup.rb
UTF-8
1,631
3.828125
4
[]
no_license
require "employee" class Startup attr_reader :name, :funding, :salaries, :employees def initialize(name, funding, salaries) @name = name @funding = funding @salaries = salaries @employees = [] end def valid_title?(title) @salaries.has_key?(title) end de...
true
f9fb528f52e37ce90d62a65021e894de448cf851
Ruby
thoughtbot/dddd
/features/step_definitions/talk_steps.rb
UTF-8
1,576
2.578125
3
[]
no_license
Then /^I should see the following talks:$/ do |table| table.hashes.each do |talk_hash| talk = Talk.find_by_name(talk_hash['name']) page.should have_css("a[name='#{talk.slug}']") page.should have_css("h2", :text => "#{talk.name} - #{talk.speaker_name}") page.should have_css(".abstract p", :te...
true
0569cc18a00b2e4abf238aa6f59c6fc1c053488b
Ruby
ninefold/fog
/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb
UTF-8
898
2.53125
3
[ "MIT" ]
permissive
module Fog module Compute class Brightbox class Real # Remove a number of servers from a server group # # >> Compute[:brightbox].remove_servers_server_group "grp-12345", :servers => [{:server => "srv-abcde"}] # # == Parameters: # * identifier (String) - The ...
true
02f00c0460ea08826a44a84c48d9c9f4c732ce25
Ruby
discotroll65/blue_hat_red_hat
/clown.rb
UTF-8
786
3.59375
4
[]
no_license
require_relative ('clown_list.rb') class Clown attr_reader :pos, :color, :correct def initialize(line) @clowns_line = line end def say_answer answer = figure_what_answer_to_say end private def figure_what_answer_to_say #This is where you put your algorithm!! #Make an algorithm that wi...
true
b86b87595bef81be04b0c27cb53d2b898abc88c8
Ruby
algolia/jekyll-algolia
/lib/jekyll/algolia/hooks.rb
UTF-8
2,837
2.734375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Jekyll module Algolia # Applying user-defined hooks on the processing pipeline module Hooks # Public: Apply the before_indexing_each hook to the record. # This method is a simple wrapper around methods that can be overwritten # by users. Using a wrapper ...
true
120b4025eda42d7a1c5536f26af691e066319d2a
Ruby
emilMircea/cashier-function
/spec/item_spec.rb
UTF-8
392
2.59375
3
[]
no_license
require 'item' describe Item do context 'initialize' do let(:green_tea) { Item.new('Green tea', 3.11, 'GR1') } it 'should have a name' do expect(green_tea.name).to eq('Green tea') end it 'should have a price' do expect(green_tea.price).to eq(3.11) end it 'should have product code'...
true
7fe056b1b0f4dd0f7267c2ad675a755b76ee7e37
Ruby
olessiap/learningruby
/Weekly-Projects/week-1/binary_search.rb
UTF-8
680
3.359375
3
[]
no_license
def bsearch(arr, target, store = []) arr.sort! arr = arr.dup #copy of arr if arr.length == 1 && target != arr.first return nil end #find middle point of current sub_arr midpoint = arr.length/2 midpoint_v = arr[midpoint] if target == midpoint_v store << arr # store.flatten!.sort! # ...
true
a11cd8f6c111e41aaf5b4e2104bae5da135ac7cd
Ruby
JupiterLikeThePlanet/goby
/lib/Item/shovel.rb
UTF-8
231
2.859375
3
[ "MIT" ]
permissive
require_relative 'item.rb' class Shovel < Item def initialize(params = { name: "Shovel", consumable: false }) super(params) end def use(entity) type("\"Type 'dig' to use me when the time arises...\"\n\n") end end
true
f3797d66a6cffc54f83cdb9bbbf40ba522140947
Ruby
srirammca53/update_status
/rubystuff/25-05-2011 (2)/duck.rb
UTF-8
143
2.984375
3
[]
no_license
class Dog def talk @sum =duck.23 + duck.34 puts @sum end end class Duck def talk puts "Quack" end end [Dog.new, Duck.new].each { |a| a.talk }
true
cff2abd22ce4007cadf270c4f56514f46a5cfa08
Ruby
aranzagp/emergency-transfer-summary
/app/pdfs/summary_pdf.rb
UTF-8
1,699
2.5625
3
[]
no_license
# frozen_string_literal: true class SummaryPdf < Prawn::Document include PatientSummariesHelper def initialize(patient) super() @patient = patient header_rows_section facility_name_section patient_informaion_section summary_section end def header_rows_section table header_rows do ...
true
1b5ad9e7bccd3303714870e796b6e6a28dfea386
Ruby
tsuji-t/my-storage
/spec/models/user_spec.rb
UTF-8
2,504
2.53125
3
[]
no_license
require 'rails_helper' # 実行コマンド # bundle exec rspec spec/models/user_spec.rb RSpec.describe User, type: :model do before do @user = FactoryBot.build(:user) end describe '新規登録' do it '全て存在すれば正常に登録できる' do expect(@user).to be_valid end it "ニックネームが空だと登録できない" do @user.nickname = "" ...
true
a45997272908c6b6b9db909a97dc2029a8e10ac0
Ruby
reach075710/study_Ruby
/AtCoder/ABC/ABC_181/C.rb
UTF-8
1,191
2.859375
3
[]
no_license
n = gets.chomp.to_i tmp_equation = 0 slope = 0 intercept = 0 answer = "No" a_arr = [] b_arr = [] 0.upto(n - 1) do |i| a_arr[i],b_arr[i] = gets.chomp.split(" ").map(&:to_f) end 0.upto(n - 3) do |i| (i + 1).upto(n - 2) do |j| if a_arr[i] == a_arr[j] then chk_prm = 1 elsif b_arr[i] == b_arr[j] then ...
true
ac966006bb4821664fe08fc245c50baf935e0b3d
Ruby
karinfdez/ironhack_bootcamp
/week_1/user_password.rb
UTF-8
1,249
3.9375
4
[]
no_license
require "highline/import" #Prompt user and get his/hers input class Correct_input attr_accessor :system_password, :system_username, :user_input def initialize(system_username,system_password) @system_password=system_password @system_username=system_username @user_input="" end def prompt(user_decision) ...
true
245466d12778ea0fdedddd6556323cfc90d0890d
Ruby
sisk/healer
/app/helpers/patients_helper.rb
UTF-8
1,309
2.75
3
[]
no_license
module PatientsHelper def patient_image(patient, size = :thumb) image_tag(patient.displayed_photo(size), :alt => "Photo of #{patient.to_s}", :class => "patient_image") end def patient_gender(patient) case patient.try(:male) when true then "Male" when false then "Female" else "Unknown" en...
true
3d6684aec8f4cfaf9ba16aba5779a219d098ec8a
Ruby
eonum/swiss-hospital-statistics
/app/helpers/search_helper.rb
UTF-8
1,702
2.609375
3
[ "MIT" ]
permissive
module SearchHelper # JSON API for search # parameters: # term: search term # limit: maximum number of items # locale: language for search term and results # as_hash: if set deliver codes in a hash including the id, the localized text and the code def search_and_render model res = [] query = param...
true
3b6798bf84ac6bd9c1da92739167771ac13866c1
Ruby
TechProject/rampupruby1
/bottles.rb
UTF-8
209
3.296875
3
[]
no_license
number = 99 while number >= 1 puts """#{number} bottles of beer on the wall.\ #{number} bottles of beer. You take one down,\ pass it around, #{number} bottles of beer on the wall.""" number -= 1 end
true
791b3296d2d3b7ddc1d379068491df0c215fce63
Ruby
mtchavez/al_papi
/lib/al_papi/keyword.rb
UTF-8
1,930
2.671875
3
[ "MIT" ]
permissive
module AlPapi class Keyword ## # # POST a keyword/engine/locale combination to get SERP for. # # @param keyword [String] *Required* - The keyword you are ready to get results for. # @param engine [String] _Optional_ - Defaults to google # @param locale [String] _Optional_ - Defa...
true
851c0056013de9a9c9d4c437b1b62e78cb6d987d
Ruby
ludocracy/Duxml
/lib/duxml/meta/grammar/rule/children_rule.rb
UTF-8
5,577
2.578125
3
[ "MIT" ]
permissive
# Copyright (c) 2016 Freescale Semiconductor Inc. require File.expand_path(File.dirname(__FILE__) + '/../rule') require File.expand_path(File.dirname(__FILE__) + '/../../../doc/element') module Duxml # methods to apply rule on what children an Element may have module ChildrenRule; end # do not subclass! rule t...
true
0ab46e12b1bb8e88b85f97222615d18f4082cd59
Ruby
csquared/loopr
/listener/run.rb
UTF-8
1,270
3.15625
3
[]
no_license
require 'rubygems' require 'serialport' class Button def initilize @on = false end def toggle! @on = !@on end def on?; @on; end def off?; !@on; end end class Pedal def initialize @record_button = Button.new @loop_button = Button.new end def run!(tty = nil) unless tty ...
true
953fa21c05475ed45b1802eaf9ab72c4f0ffc78f
Ruby
t3hk0d3/rencoder
/lib/rencoder/decoder.rb
UTF-8
2,837
2.875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Rencoder # Rencode format decoder module module Decoder INTEGER_DECODING_MAP = { CHR_INT1 => [1, 'c'], CHR_INT2 => [2, 's>'], CHR_INT4 => [4, 'l>'], CHR_INT8 => [8, 'q>'] }.freeze def decode(buffer) buffer = StringIO.new(buffer) unless...
true
b4865fe34ca201ccd16d11441ef2b7385125560f
Ruby
GMAP/DSPBench
/dspbench-threads/src/main/resources/frauddetection/util.rb
UTF-8
3,151
3.25
3
[ "MIT" ]
permissive
class IdGenerator def initialize @id_char = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', 'P','Q','R','S','T','U','V','W','X','Y','Z', '0', '1', '2', '3', '4'] @length = @id_char.length @id_char_num = ['0','1','2','3','4','5','6','7','8','9'] end ...
true
d1a94b44f5620a0d0ca13e2591399b485eccdbb1
Ruby
agardiner/arg-parser
/lib/arg-parser/argument.rb
UTF-8
21,715
2.9375
3
[ "BSD-2-Clause" ]
permissive
# Namespace for classes defined by ArgParser, the command-line argument parser. module ArgParser # Hash containing registered handlers for :on_parse options OnParseHandlers = { :split_to_array => lambda{ |val, arg, hsh| val.split(',') } } # Hash containing globally registered predefined argumen...
true
f96d4abcbd1f057b02e6f7b9cd77d58ee7c38f74
Ruby
daxwann/App_Academy
/intro_programming/last_index.rb
UTF-8
414
4.46875
4
[]
no_license
# Write a method last_index that takes in a string and a character. # The method should return the last index where the character can be # found in the string. def last_index(str, char) return (str.length - 1) - str.reverse.index(char) end puts last_index("abca", "a") #=> 3 puts last_index("mississipi", ...
true
fe4d9e266aff9dae2e5884bc2a356c0de938dd10
Ruby
annaroyer/black_thursday
/test/invoice_repository_test.rb
UTF-8
3,671
2.75
3
[]
no_license
require_relative 'test_helper' require_relative '../lib/invoice_repository' require_relative '../lib/invoice_item_repository' require_relative '../lib/transaction_repository' require_relative '../lib/customer_repository' class InvoiceRepositoryTest < Minitest::Test def setup @data = { items: './test/fi...
true
23fe2fbc9dc518dfc5135e97b0ad332569e110dd
Ruby
jitendrarathor/test2
/app/helpers/statuses_helper.rb
UTF-8
384
2.53125
3
[]
no_license
module StatusesHelper def get_intime(intime) return intime.in_time.strftime("%r") end def get_outtime(outtime) return outtime.out_time.strftime("%r") end def get_tworkhour(tworkhour) return Time.at(tworkhour.work_hour).gmtime.strftime('%R:%S') end def get_breaktime(brktime) return Ti...
true
1096c04d40ceb593cb15ff46a90789819b9beeac
Ruby
bharatagarwal/launch-school
/101_programming_foundations/3_practice_problems/02 Easy 2/06.rb
UTF-8
189
3.0625
3
[]
no_license
flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) # p flintstones << 'Dino' # p flintstones.concat(['Dino']) # note it has to be [Dino], and not just 'Dino' p flintstones.push("Dino")
true
08afee628cd97b7fb0079c60aeb6511a32f125dd
Ruby
DylanAttal/Algorithm-Practice
/Codewars/Ruby/8kyu_SumOfPositive.rb
UTF-8
246
3.921875
4
[]
no_license
# You get an array of numbers, return the sum of all of the positives ones. # Example [1,-4,7,12] => 1 + 7 + 12 = 20 # Note: if there is nothing to sum, the sum is default to 0. def positive_sum(arr) arr.select{ |num| num.positive?}.sum end
true
1a08d7a3aa45e9ac9eea34f05085e645506a8768
Ruby
elitmus/ariadne
/test/test_ariadne.rb
UTF-8
2,468
2.515625
3
[ "MIT" ]
permissive
require_relative 'test_helper' class AriadneTest < MiniTest::Test def test_insert_data app_name = 'test' data = { 'id' => 123, 'state' => 'active' } out = Ariadne.insert_data(options: data, app_name: app_name) assert_equal Redis::Future, out.class end def test_get_data app...
true