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
7caa2cb2c0661fe56c94778c641a7714c17a1276
Ruby
abraxaslee/LeetCode
/796.rb
UTF-8
437
3.796875
4
[ "MIT" ]
permissive
# 796. Rotate String # 44 / 44 test cases passed. # Status: Accepted # Runtime: 32 ms # @param {String} a # @param {String} b # @return {Boolean} def rotate_string(a, b) return true if a == b return false unless a.length == b.length a.each_char.with_index do |c,i| if c == b[0] head = i ...
true
3d707e7a09127b322a56e049ab5e364a980e428d
Ruby
kenneth1870/design-patterns-in-ruby
/decorator.rb
UTF-8
478
3.609375
4
[]
no_license
# Attach additional responsibilities to an object dynamically. Decorators # provide a flexible alternative to subclassing for extending functionality class Burger def cost 50 end end class BurgerWithCheese < Burger def cost 60 end end class LargeBurger def initialize(burger) @burger = burger e...
true
3dc00c9618156cddace95b59841a3d99090c5e44
Ruby
RyanTech/theatre_search
/app/models/search.rb
UTF-8
676
2.546875
3
[]
no_license
# == Schema Information # # Table name: searches # # id :integer not null, primary key # city :string(255) # state :string(255) # created_at :datetime not null # updated_at :datetime not null # class Search < ActiveRecord::Base attr_accessible :city, :listings, :name,...
true
ece1dd321001c9bdb79a0458602a6f947bf74ec4
Ruby
trevorcompton/trevor-blog
/app/controllers/posts_controller.rb
UTF-8
2,070
2.796875
3
[]
no_license
class PostsController < ApplicationController # because of this inheritance, this ruby file knows to act like a controller def index # <- the index action: an action is simply a publicly-accessible ruby method defined in a controller class @posts = Post.all end def show # @post = Post.find(1) # par...
true
f14bc12b88bf43133c726ca834bf242fb6abb68b
Ruby
danjungo/danjungo
/hpricot/hp12/app/models/usr.rb
UTF-8
3,519
2.671875
3
[]
no_license
require 'digest/sha1' # this model expects a certain database layout and its based on the name/login pattern. class Usr < ActiveRecord::Base CHANGEABLE_FIELDS = ['first_name', 'last_name', 'email'] attr_accessor :password_needs_confirmation after_save '@password_needs_confirmation = false' after_validation :c...
true
08524e1acc141f1aaa598470322aba8f00bf712c
Ruby
goppa-io/Hanlon
/core/stack.rb
UTF-8
1,054
3.71875
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
# here, we define a Stack class that simply delegates the equivalent "push", "pop", # "to_s" and "clear" calls to the underlying Array object using the delegation # methods provided by Ruby through the Forwardable class. We could do the same # thing using an Array, but that wouldn't let us restrict the methods that # ...
true
85ee5ee60531b431809edf3b2146f5457cd8650e
Ruby
oknashar/Problem-Solving
/HackerRank/countingValleys.rb
UTF-8
642
3.578125
4
[]
no_license
#link: https://www.hackerrank.com/challenges/counting-valleys/problem #!/bin/ruby require 'json' require 'stringio' # Complete the countingValleys function below. def countingValleys(n, s) level = 0; valleys = 0; isDownSeaLevel = false for i in 0..n level += (s[i] == 'U' ? 1 : -1) isDownSeaLe...
true
04fdbe61f17f922c9845c6fb4a16bf3fe6d58aed
Ruby
sshehryar/gpa_calculator
/gpac.rb
UTF-8
936
3.328125
3
[]
no_license
def inp return gets.chomp end puts "This is a Douchebag GPA calculator" subjects = 0 total_crd = 0 gpa_score = 0 grades = {"A+" => 4, "A" =>3.7 , "A-" => 3.6,"B+" =>3.5 , "B" => 3 , "B-" => 2.9 , "C+" => 2.5 , "C" => 2, "D+" => 1.5 , "D" => 1, "F" => 0} while subjects == 0 print "Enter The numb...
true
a409d0f9cb96d41fe841fdbcf7aaf6ef223539b5
Ruby
mash27/stockowl
/app/services/get_current_daily_price_series_for_stock_service.rb
UTF-8
1,124
3.109375
3
[]
no_license
class GetCurrentDailyPriceSeriesForStockService require 'open-uri' require 'json' def initialize(company_ticker) @company_ticker = company_ticker p @company_ticker p 'company ticker' end def call # 1. Build the url url = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbo...
true
ef2568e4b0db885d9e24111e560f34d422075556
Ruby
sumajirou/ProjectEuler
/p086.rb
UTF-8
484
3.125
3
[]
no_license
count = 0 1.step do |z| zz = z*z 1.upto(z) do |y| 1.upto(y) do |x| # このようにuptoを重ねることで x<=y<=z が保証される route = zz + (x+y)**2 if Math.sqrt(route) % 1 == 0 p [route,x,y,z] count += 1 end if count >= 1_000_000 puts "count=#{count}, M=#{z}" ...
true
479c975f473ae059b0ddbc20b1385ee6eedcee18
Ruby
rpalo/ruby-cs-algorithms
/data-structures/linked_list.rb
UTF-8
2,972
3.546875
4
[ "MIT" ]
permissive
require 'minitest/autorun' require_relative 'node' # Error for when list is empty class EmptyListError < StandardError end class NoNodeError < StandardError end # Implementation of simple Singly Linked List class LinkedList attr_reader :head, :size def initialize @head = nil @size = 0 end def inse...
true
e7b08b76cbed6529b21b14787a8b9bf9cd7e9d60
Ruby
choria-io/mcorpc-ruby-support
/lib/mcollective/validator/typecheck_validator.rb
UTF-8
894
2.953125
3
[ "Apache-2.0" ]
permissive
module MCollective module Validator class TypecheckValidator def self.validate(validator, validation_type) raise ValidatorError, "value should be a #{validation_type}" unless check_type(validator, validation_type) end def self.check_type(validator, validation_type) case validati...
true
39774678c63c96e6a0ee705ad4ec3c31979ffbc3
Ruby
cryptobuks/kbsecret
/bin/kbsecret-rm
UTF-8
907
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # frozen_string_literal: true require "kbsecret" require "tty-prompt" $VERBOSE = nil # tty-prompt blasts us with irrelevant warnings on 2.4 opts = KBSecret::CLI.slop do |o| o.banner = <<~EOS Delete a record. Usage: kbsecret rm [--session <name>] [--interactive] <label> EOS o...
true
1b0873b61b15387939c6afeaf320c97cbe8999a8
Ruby
nmacatangay/lom-stat-calculator
/main.rb
UTF-8
1,214
3.09375
3
[]
no_license
load './classes/calculator.rb' load './classes/logger.rb' load './classes/logic.rb' load './classes/parser.rb' load './classes/setup.rb' load './data/config.rb' def main # Initialize the main hash setup = Setup.new main_hash = setup.main_hash # Get the current weapon value from setup cwv = setup.cwv # I...
true
61d5638e6e6b50b553062c1b4d77965b83584789
Ruby
Karolis-Sakavicius/Ringman
/lib/ringman/listings_manager.rb
UTF-8
793
2.8125
3
[]
no_license
require 'rubygems' require_relative 'ebay' class ListingsManager def initialize @listings = [] end def add_listing(url, notify_times, options) listing = { listing: Listing.new(url), notify_times: notify_times, options: options } @listings.push(listing) end def run @runner_thread = Thread.ne...
true
697a8381edbffcf44fbea210a6c357c02ad608c5
Ruby
JiriKrizek/MI-RUB-sem
/test/test.rb
UTF-8
6,232
2.578125
3
[]
no_license
require '../lib/parser.rb' require '../lib/html_tag.rb' require '../lib/tags.rb' require 'test/unit' class TestTokenizer < Test::Unit::TestCase def test_html_tag t = HTML::Tag.new("html", Hash.new) assert(!t.has_attr?) t = HTML::Tag.new("html", {"key"=>"value"}) assert(t.has_attr?) end def test_title_...
true
f754c53983b972e716a25eefbc9e3e3097923e31
Ruby
phagmann/round2b
/app/controllers/macheaders_controller.rb
UTF-8
1,492
2.53125
3
[]
no_license
class MacheadersController < ApplicationController require 'sqlite3' protect_from_forgery with: :null_session def index #!/usr/bin/ruby @db = SQLite3::Database.new 'db/data.db' # min [1498431718] # max [1498436287] mac = Mac.first ts1 = mac.start_time + ...
true
5a4c6d76845d5eba18fe486c5102a6574d55bc61
Ruby
lutelles07/old_projcts_api
/features/services/database_service.rb
UTF-8
910
2.59375
3
[]
no_license
require 'yaml' class DatabaseService attr_reader :conn, :ROW_LIMIT, :SKU_LIMIT def initialize db = $database @conn = OCI8.new(db['username'],db['password'],db['database']) @ROW_LIMIT = 50 @SKU_LIMIT = 5000 end def get_db_connection @conn end def exe...
true
d53099ce94f7e8ba7cc0b8fc6114531a0bcb4ded
Ruby
areinmeyer/learningruby
/gameboard.rb
UTF-8
1,245
3.640625
4
[]
no_license
class GameBoard attr_reader :no_of_hits, :no_of_turns, :help def initialize @help = <<END_HELP I have marked 3 of 7 blocks. Try to guess which ones in the least amount of time. GRADES: 3 Guesses = GENIUS 4 Guesses = SMART 5 Guesses = NOT BAD 6 Guesses = ME...
true
81fcf7f6d8dfa8b37b8398c57f6ecd90ca091045
Ruby
dommichalec/launch_school
/weekly_challenges/grade_school/grade_school.rb
UTF-8
511
3.46875
3
[]
no_license
# steps # 1.) understanding the problem < this is the hardest step class School def initialize @roster = {} end def to_h result = {} @roster.keys.sort.each do |key| result[key] = @roster[key].sort end result end def grade(number) raise InvalidNumber unless number.is_a?(Intege...
true
80e96c95dbe1febe020725bf64573ff946c2a7a1
Ruby
danielkol10/cookbook-sinatra
/app.rb
UTF-8
1,707
2.5625
3
[]
no_license
# frozen_string_literal: true require 'sinatra' require 'sinatra/reloader' if development? require 'pry-byebug' require 'better_errors' configure :development do use BetterErrors::Middleware BetterErrors.application_root = File.expand_path(__dir__) end require_relative 'cookbook' require_relative 'recipe' require_...
true
42c66916688137aec99563ea3bb212ed1c2946e6
Ruby
jguthrie100/chess
/lib/board.rb
UTF-8
1,231
3.390625
3
[]
no_license
# lib/board.rb require_relative 'helper' class Board include Helper attr_accessor :board, :removed_pieces def initialize @board = Array.new(8) { Array.new(8) } @removed_pieces = Array.new setup_board end def move(from, to) piece = get_piece(from) unless piece.nil? end end d...
true
78cdaa93447258446706f5d3faccf9da0ba3e399
Ruby
muziyoshiz/admiral_stats_parser
/spec/admiral_stats_parser/model/character_list_info_spec.rb
UTF-8
4,381
2.75
3
[ "MIT" ]
permissive
require 'spec_helper' describe CharacterListInfo do describe '#lv_to_exp' do it 'returns sum of experience points' do info = CharacterListInfo.new info.lv = 1 expect(info.lv_to_exp).to eq(0) info.lv = 2 expect(info.lv_to_exp).to eq(100) info.lv = 50 expect(info.lv_to_e...
true
290f4470e12d32cfa5f6c44f3d7aba9f9299b4b4
Ruby
kaiheiongaku/books_books_books
/lib/library.rb
UTF-8
947
3.265625
3
[]
no_license
require './lib/author' class Library attr_reader :name, :authors def initialize(name) @name = name @authors = [] end def add_author(author) @authors << author end def books if @authors != [] @authors.map do |author| author.books end.flatten else [] end ...
true
09d40a7a0211db62cbcd5c6372dd39831dd6bee3
Ruby
kasai441/ruby-practices
/07.bowling_object/lib/frame.rb
UTF-8
863
3.171875
3
[]
no_license
# frozen_string_literal: true require_relative 'roll' class Frame attr_accessor :rolls def initialize(index, max_frame) @max_frame = max_frame @index = index @rolls = [] end def roll(score, index) @rolls << Roll.new(score, index) end def score @rolls.map(&:score).sum end def sc...
true
01db0190efa3d77bf57b4f8f157d61d025c29f28
Ruby
beechnut/homegrown
/models/word.rb
UTF-8
275
2.953125
3
[]
no_license
# Word # Word PRIME DIRECTIVE: stores the generated word # written by Matt Cloyd # started September 15 2012, alpha finished # class Word attr_reader :word # initialize with an input string = word, then split into an array def initialize(word) @word = word end end
true
f2b87793ae60591812fcb25bd8623c103765e9a9
Ruby
iAmMatthew/task_list
/task_list.rb
UTF-8
356
3.4375
3
[]
no_license
task_list = Hash.new puts "What do you need to do today?" task = gets.chomp while task != "exit" if task_list.has_key?(task) puts "You haved added a task." else task_list[task] = 1 end puts "Would you like to do anything else? Type a task or exit." task = gets.chomp end task_list.each do |task, num...
true
61badad210550cdc7bace198f5bc6eae2c379976
Ruby
eunomie/ruby-elm
/spec/compiler_spec.rb
UTF-8
6,383
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'elm' describe Elm::Compiler do context '##with' do it 'should return a compiler with a defined runnable' do runnable = Elm::Runnable.new 'true' compiler = Elm::Compiler.with runnable expect(compiler.instance_variable_get(:@make)).to eq runnable end end context '#content' do ...
true
867f41ef9b20f7be1f594ac9e97301064c32bffd
Ruby
randallr18/World_Cup
/app/models/match.rb
UTF-8
2,810
2.765625
3
[ "MIT" ]
permissive
class Match < ActiveRecord::Base belongs_to :stadium belongs_to :team def self.create_array_from_API all_matches = RestClient.get("http://worldcup.sfg.io/matches") matches_array = JSON.parse(all_matches) end def self.add_hometeam_matches_from_API self.create_array_from_API.each do |match| ...
true
8905166b3491d33c2779c234bb493b9c56e924a6
Ruby
EmmyMorris/backend_mod_1_prework
/section1/lesson8.rb
UTF-8
431
3.390625
3
[]
no_license
greeting = "Hello Everyone!" greeting[0..4] greeting = "Hello Everyone" greeting.length sentence = "This is my sample sentence." sentence.split numbers = "one,two,three,four,five" numbers.split(",") greeting = "Hello Everyone!" greeting.gsub("Everyone!", "Friends!") name = "Emmy" puts "Good morning, "+ name +"!" p...
true
06c46f87be53b36f328903ec87c4a85e15beac16
Ruby
fulcom/rails-mister-cocktail
/db/seeds.rb
UTF-8
1,261
2.546875
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
1faa9e6bd5c132456ddcacebf4bbd2e5b72ec73e
Ruby
kanpou0108/launchschool
/The_General_Approach_for_Problem_Solving/02/q06.rb
UTF-8
1,145
4.125
4
[]
no_license
Launch School - an online school for developers easy8-4 https://launchschool.com/exercises/70718e76 All Substrings Write a method that returns a list of all substrings of a string. The returned list should be ordered by where in the string the substring begins. This means that all substrings that start at position ...
true
c1680f55fada4e01032f395f057c72761d7337aa
Ruby
ablakerose/collections_practice-online-web-pt-051319
/collections_practice.rb
UTF-8
853
3.6875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(numbers_array) numbers_array.sort end def sort_array_desc(numbers_array) numbers_array.sort.reverse # numbers_array.sort{|a, b| b <=> a} end def sort_array_char_count(numbers_array) #numbers_array.length.sort numbers_array.sort {|a, b| a.length <=> b.length} end def swap_elements(array) ...
true
c9b7d5aaeef48621f6f3853a4fcc8d279ff8b698
Ruby
ljnissen/rubycode
/006/file_09.rb
UTF-8
112
3.609375
4
[]
no_license
def factorial(n) total = 1 (1..n).each do |n| total *= n end total end puts factorial(gets.to_i)
true
9be09baff87e3525393f7876f58116054b49aeb5
Ruby
HM100/pokemon-essentials
/Data/Scripts/011_Battle/006_Other battle types/006_PokeBattle_BattleRecord.rb
UTF-8
8,119
2.546875
3
[]
no_license
#=============================================================================== # #=============================================================================== module PokeBattle_RecordedBattleModule attr_reader :randomnums attr_reader :rounds module Commands Fight = 0 Bag = 1 Pokemon = 2 ...
true
bde200d41182f0839dfa9ed6d7ef20b328170610
Ruby
OneAcreCafe/labor
/app/helpers/shifts_helper.rb
UTF-8
196
2.65625
3
[ "Apache-2.0" ]
permissive
module ShiftsHelper def days(start_date, end_date) days = [] (start_date.to_i .. end_date.to_i).step(24*60*60) do |timestamp| days << Time.at(timestamp) end days end end
true
ee29909506ae8a8773c61b3a9753f3a230d100af
Ruby
kamok/lil-programs
/change_counter.rb
UTF-8
2,290
4.0625
4
[]
no_license
#Todo, add pluralization and refactor the until loops into a dictionary of bills and values and one until method class CountChange attr_accessor :cost, :pay, :change def initialize(cost, pay) @cost = cost.to_f @pay = pay.to_f @change = (pay - cost).round(2) end def calc_change return "You don't have any ...
true
a58d07a2126cd517f985410b59385b1cabc21705
Ruby
garretwolf/backend_module_0_capstone
/day_1/exercises/ex6.rb
UTF-8
1,683
4.25
4
[]
no_license
# types_of_people variable set equal to 10 types_of_people = 10 # variable named x is assigned to a string where # types_of_people is embedded in that string x = "There are #{types_of_people} types of people." # variable named binary is set equal to string "binary" binary = "binary" # variable named do_not is set equal...
true
8404d2508161b09636a70c1f010a301ea991233f
Ruby
schrockwell/chisel
/lib/chisel/resource.rb
UTF-8
1,672
2.734375
3
[]
no_license
module Chisel class Resource @@cache = {} def id raise "You must implement #{self.class.name}.id" end def self.all raise "You must implement #{self.class.name}.all" end def resource_type self.class.name.underscore end def inspect File.join(*self.id) end def cache(*keys) ...
true
ae3cefc5a53ce9f48e18a3dc7df8efd18a21365f
Ruby
nicolasleger/anystyle
/lib/anystyle/feature/chars.rb
UTF-8
546
2.65625
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
module AnyStyle class Feature class Chars < Feature def observe(token, page:, **opts) chars = count(token, /\p{L}/) upper = count(token, /\p{Lu}/) white = count(token, /\s/) punct = count(token, /[\p{Pd}:.,&\(\)"'”„’‚´«「『‘“`»」』]/) width = display_width(token) ...
true
70700041df224973ae60e26a1fcc1c783d52fd36
Ruby
adsteel/C0elevation
/app/helpers/order_items_helper.rb
UTF-8
2,236
3.25
3
[]
no_license
module OrderItemsHelper require 'numbers_in_words' require 'numbers_in_words/duck_punch' class PriceLine def initialize(key, value) @first_key, @second_key = key, key @first_value, @second_value = value, value end # checkers def multiple_values? @first_value != @second_value en...
true
d91f31c6eb90854ab4d5b01a904cecbb034548f5
Ruby
DrCooksALot/programming-univbasics-4-square-array-nyc01-seng-ft-051120
/lib/square_array.rb
UTF-8
133
3.375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def square_array(array) new_array = [] array.length.times { | index | new_array.push( array[index]** 2 ) } new_array end
true
d685675a660cd77e216b81c121939a20a5feaf7e
Ruby
chandigarh47/WDi26-Homework
/Jose_Juan_Alcolea/week_04/day_02/MTA.rb
UTF-8
984
3.203125
3
[]
no_license
require 'pry' # # $lines = { # "N" = ["Times Square", "34th", "28thN", "23rd", "Union Square", "8thN"] # "L" = ["8th", "6th", "Union Square", "3rd", "1st"] # "6" = ["Grand Central", "33rd", "28th", "23rd", "Union Square", "Astor Place"] # } #$lines def single_trip ( line , star_station, finish_station ) lines = ...
true
72da1d413b8147ea010303f5684d1d046558bc74
Ruby
zoojar/bolt
/lib/bolt/module_installer/puppetfile.rb
UTF-8
4,175
2.546875
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true require_relative '../../bolt/error' require_relative 'puppetfile/forge_module' require_relative 'puppetfile/git_module' # This class manages the logical contents of a Puppetfile. It includes methods # for parsing and generating a Puppetfile. # module Bolt class ModuleInstaller clas...
true
94af5e8bc4d01420aec007f2bbbdbf94696865ec
Ruby
mmillman/w3d1
/array/spec/array_spec.rb
UTF-8
833
3.140625
3
[]
no_license
require 'rspec' require 'array' describe "Array" do describe "my_uniq" do subject { [1, 2, 1, 3, 3] } it "strips out repeated values" do subject.my_uniq.should == [1, 2, 3] end end describe "two_sum" do let(:no_two_sum) { [1, 2, 1, 3, 3] } let(:has_two_sum) { [1, 2, 1, 3, -3] } ...
true
dbd72b41d1c88c4b58d84c56badc6f592fb883d2
Ruby
enthal/ecdf_ruby_demo
/spec/card_pres_spec.rb
UTF-8
2,325
2.921875
3
[]
no_license
# Copyright © 2011 Timothy James; All rights reserved require 'card_pres' describe CardPres do describe '#initialize' do describe 'normally from strings' do let (:cp) {CardPres.new("user", "1", "1.3", "4")} it { cp.to_a.should == ["user",1,1.3,4] } it { cp.user_id.should == "user" } ...
true
04e7c6aada275693f351f0fb6c7d66f5c79b2c63
Ruby
blevy115/roll-of-the-die
/permutations.rb
UTF-8
278
2.921875
3
[]
no_license
permutation = [] combo =[] until permutation.length == 36 dice_1 = Random.rand(1..6) dice_2 = Random.rand(1..6) combo = [dice_1, dice_2] combo = combo.join(" ") unless permutation.include? combo permutation << combo end end print permutation.sort.join("\n") puts
true
54c0755b7aa61afd300f56a449216c3c82c4b226
Ruby
scalabl3/couchbasemodels.com
/app/models/document_store.rb
UTF-8
4,543
2.71875
3
[]
no_license
require 'couchbase' require 'map' module DocumentStore include Term::ANSIColor setting_hash = { :node_list => ENV['couchbase_servers'].split(","), :pool => "default", :bucket => 'default', :port => 8091 } # if (Yetting.couchbase_password && !Yetting.couchbase_password.empty?) # setting_hash[:...
true
626918df78bb14d8cc60489b8293c49796692779
Ruby
jajapop-m/algorithm
/1_06_A_CountingSort.rb
UTF-8
1,925
4.03125
4
[]
no_license
# 計数ソート(バケツソート、バケットソート) # 計数ソートは各要素が0以上k以下である要素数nの数列に対して、線形時間(O(n+k))で動く高速で安定なソーティングアルゴリズム # 数列Aを読み込み、計数ソートのアルゴリズムで昇順に並べ替え、出力するプログラム # 入力例 # 7 # 数列Aの長さを表す整数n 1 ≦ n ≦ 2_000_000 # 2 5 1 3 2 3 0 #各要素は0以上10_000以下 # 出力例 # 0 1 2 2 3 3 5 N = gets.to_i array = gets.split.map(&:to_i) module CountingSort refine Array ...
true
e122fefbc37ce3af96026f0997237109b5021977
Ruby
beauby/jsonapi-serializable
/lib/jsonapi/serializable/resource_dsl.rb
UTF-8
3,990
2.734375
3
[ "MIT" ]
permissive
module JSONAPI module Serializable module ResourceDSL def self.included(base) base.extend(ClassMethods) end module ClassMethods # @overload type(value) # Declare the JSON API type of this resource. # @param [String] value The value of the type. # ...
true
c97f0cfc545330da9e2c8567c6fb2d4e38c4483e
Ruby
morellon/spoj
/ruby/onp/main.rb
UTF-8
341
3.359375
3
[]
no_license
def to_rpn(expression) rpn = "" operators = [] expression.each_char do |char| if char == "(" # nope elsif char =~ /[*^+-\/]/ operators << char elsif char == ")" rpn << operators.pop else rpn << char end end rpn end tests = gets.chomp.to_i tests.times do puts t...
true
282bfb705daf1e01b7caf27a78665e9383f75b4e
Ruby
sharedworkforce/sharedworkforce-demo-rails
/app/tasks/tag_cat_task.rb
UTF-8
869
2.515625
3
[]
no_license
class TagCatTask include SharedWorkforce::Task REJECT = ["not a cat", "more than one cat", "photo did not load"] ACCEPT = ["fluffy", "soft", "cute", "rough", "scary", "evil"] title "Tag this cat" instruction "Tick all that apply" answer_options REJECT + ACCEPT answer_type :tags on_success :tag_cat ...
true
6099be8a3354eb8db877855447edd7ab08f666c5
Ruby
vprahaladhan/mightyape-deals
/lib/mighty_ape/cli.rb
UTF-8
3,087
3.140625
3
[ "MIT" ]
permissive
class MightyApe::CLI # @@BASE_URL = "https://www.mightyape.com.au" attr_accessor :offset, :page def initialize MightyApe::Scraper.get_all_promos @offset = 0 @page = 1 end def call welcome list_menu loop do input = gets.strip (input == 'q' || input == 'Q') && break ...
true
4b685148700c4d9df4bb0567b2150b9d18bfb6da
Ruby
Numie/RubyStructures
/lib/data_structures/heap.rb
UTF-8
3,260
3.171875
3
[ "MIT" ]
permissive
class Heap def self.from_array(array) heap = self.new heap.instance_variable_set(:@store, array) heap.send(:store).length.downto(0).each do |idx| children_indices = heap.send(:children_indices, idx) heap.send(:heapify_down, idx, children_indices) unless children_indices.empty? end he...
true
acde5aad121d884471eeb20e3990cbb803a89f84
Ruby
anginblu/ttt-with-ai-project-v-000
/lib/players/computer.rb
UTF-8
311
3.390625
3
[]
no_license
class Players class Computer < Player def move(board) possible_moves = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] possible_moves.delete_if {|number| !board.valid_move?(number)} if board.valid_move?("5") "5" else possible_moves[0] end end end end
true
65287721b92d4bd7a3fb0ddfdcaadf40c9cb4719
Ruby
jessegan/jamlist
/app/models/playlist.rb
UTF-8
2,745
2.765625
3
[ "MIT" ]
permissive
class Playlist < ApplicationRecord ### ASSOCIATIONS belongs_to :group has_many :playlist_tracks, dependent: :destroy has_many :tracks, through: :playlist_tracks ### VALIDATIONS validates :name, {presence: true, uniqueness: {scope: :group, message: "should be unique per group"}} validates...
true
8cac350e18b4641c35d180c1c3dbf6b326edda2e
Ruby
scaleapi/scaleapi-ruby
/spec/lib/api/task_list_spec.rb
UTF-8
1,334
2.59375
3
[ "MIT" ]
permissive
RSpec.describe Scale::Api::TaskList do let(:scale) { Scale.new(api_key: SCALE_TEST_API_KEY) } # the cassette assumes there are totally 3 tasks # page 1 retrieves 2 tasks let(:page_1) { VCR.use_cassette('task_list_1') { scale.tasks.list(limit: 2) } } # page 2 retrieves the remaining 1 task. let(:page_2) { V...
true
db2b94378d985db20755b449716a703dec2f93a6
Ruby
ipetrovski3/tools
/lib/tools/time.rb
UTF-8
893
3.375
3
[]
no_license
module Tools class TimeAdjust LIMITHOURS = 24 LIMITMINSEC = 60 def initialize(time, hrs, min, sec) @time = time.split(/:/) @hrs = hrs @min = min @sec = sec end def adjust_clock hours minutes seconds "#{hours}:#{minutes}:#{seconds}" end priv...
true
75035d207f99e766f4937d41a1047fa9b3f0e4e6
Ruby
osak/Contest
/Euler/61.rb
UTF-8
622
3.140625
3
[]
no_license
#!/usr/bin/ruby #Check polygonal number that written as ax^2+bx def polygonal_checker(a,b,num) if b*b+4*a*num < 0 then false else n = (-b+Math.sqrt(b*b+4*a*num)) / (a*2); n.to_i.to_f == n; end end checker = [ [1.0/2, 1.0/2], [1,0], [3.0/2, -1.0/2], [2,-1], [5.0/2, -3.0/2], [3, -2], ]; status = Array.n...
true
8f6693f55a82c3d72245a5904d43e14f5acd127e
Ruby
michaeloboyle/sprig
/lib/sprig/seed/attribute.rb
UTF-8
1,816
2.84375
3
[ "MIT" ]
permissive
module Sprig module Seed class Attribute attr_reader :name, :raw_value, :value def initialize(name, raw_value) @name = name.to_s @raw_value = raw_value end def dependencies @dependencies ||= find_dependencies_within(raw_value).uniq end def value ...
true
35551a57edbbda97df976ba5fe4189ecdef425d1
Ruby
nicolasdao/fileman
/lib/fileman/delete.rb
UTF-8
393
2.609375
3
[ "MIT" ]
permissive
require 'fileutils' require 'fileman/rename' module Fileman module_function def remove(folder_path) new_path = Fileman.rename(folder_path, 'a', {:include_files => true, :ignore_ext => true, :recursive => true}) FileUtils.rm_rf new_path # based on different environment, you may need to remove the folder a seco...
true
1c30bef1c671ced46bd3898ac462ee66292a6f5b
Ruby
benjaminws/working_man
/bin/working_man
UTF-8
1,755
2.65625
3
[ "MIT", "Beerware" ]
permissive
#!/usr/bin/env ruby require 'optparse' require 'methadone' require 'working_man' include Methadone::Main include Methadone::CLILogging main do |run_type| config_path = File.expand_path("#{options[:file]}") check_config(config_path) case run_type when "start" WorkingMan.start_work when "stop" ...
true
423e8d0726f2cb3836496a099092bd159c481ba5
Ruby
MatteoPierro/adventofcode-2020
/test/binary_boarding_test.rb
UTF-8
569
2.78125
3
[]
no_license
# frozen_string_literal: true require 'minitest/autorun' require_relative '../lib/binary_boarding' class BinaryBoardingTest < Minitest::Test def test_calculate_seat_id ticket = 'BFFFBBFRRR' assert_equal(567, BinaryBoarding.seat_id(ticket)) end def test_max_seat_id tickets = %w[BFFFBBFRRR FFFBBBFRRR...
true
c931cd2c6831e80f4e92115fb1fd1601dd656504
Ruby
CleanSolLLC/ruby-objects-has-many-through-lab
/lib/song.rb
UTF-8
422
3.484375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_accessor :artist, :genre attr_reader :name @@all = [] def initialize(name, artist, genre) @name = name @artist = artist @genre = genre @@all << self end def self.all @@all end def songs Song.all.select {|song| song.title == self} end def new_song(name, genre) ...
true
39f88c6b3478ac67676caf2bd6af6e934fec9b2b
Ruby
railsagainstignorance/hex-regex
/genex.rb
UTF-8
25,351
3.296875
3
[]
no_license
# genex # a home-grown stab at the Perl Regex-Genex library which generates all strings which match the specified regex. # see the GENEX.md for more info # where a 'fragment' can be # - a single char, ['A'], # - a list of chars, ['A','B','C'], # - a single/list of word fragments, ['AA','BB','CC'], # always pas...
true
a204f7643cc04530c33fc5622247f7ba2e14c7db
Ruby
Creodahn/finance-app-api
/test/models/profile_test.rb
UTF-8
2,488
2.78125
3
[]
no_license
require 'test_helper' class ProfileTest < ActiveSupport::TestCase def setup @user = User.new(password: "testTEST") @user.save @profile = Profile.new( name: "Justin Drew", email: "justin@justindrew.net", user_id: @user.reload.id ) end ...
true
f221f52e1aa838cef63e7d2336decabde46367a6
Ruby
ylarom/cachetier
/spec/lib/cachetier_spec.rb
UTF-8
3,216
3.15625
3
[ "MIT" ]
permissive
require 'spec_helper' require 'cachetier' class DummyTier < Cachetier::Tier def set(key, value, ttl) end def reset(key) end end class AlwaysExpiredDummyTier < DummyTier register_tier_class :always_expired, AlwaysExpiredDummyTier def get_val_and_expiration_time(key) return :dummy_cached_value_that_sho...
true
e9d6e20e48bcaeae827358bf3def658504421fe3
Ruby
damianpllatek/booking-app
/app/models/room.rb
UTF-8
835
2.515625
3
[]
no_license
class Room < ApplicationRecord has_many :bookings mount_uploader :photo, PhotoUploader validates :name, presence: true, length: { minimum: 3, maximum: 250 } validates :description, presence: true, length: { minimum: 10, maximum: 5000 } validates :size, presence: true validates :base_price, presence: true ...
true
67135a73c833350ee4ba76ddf6eba5afb51323ff
Ruby
chooyan-eng/mygame
/src/save_manager.rb
UTF-8
413
2.703125
3
[]
no_license
require 'pathname' module MyGame # module for managing game data module SaveManager DATA_DIR = 'data'.freeze # save last played time def self.save_last_play_time save 'last_play_time.txt', Time.new.strftime('%Y%m%d%H%M%S') end # save given data into given file at data/ def self.save...
true
eac636f31410c69cf840ec75b92e21be0cccd0dc
Ruby
anjalisebastian/kwk-l1-hash-iteration-mini-lab-kwk-students-l1-dfw-070918
/iteration.rb
UTF-8
292
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Challenge 1 cart_item_prices= [12.43, 19.99, 3.49, 75.00] count=1 cart_item_prices.each do |price| puts "Item #{count}: #{price}" count += 1 end # Challenge 2 tax_included = [] cart_item_prices.each do |price| x = (price * 1.17) tax_included.push (x) end puts tax_included
true
bed7db9ad0cab3e88831caa8362ca6d5e09b39c4
Ruby
andy98725/Rails_Sample_App
/app/models/user.rb
UTF-8
1,390
2.59375
3
[ "MIT", "Beerware", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Basic regex for email format VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+[a-z]+\z/i class User < ApplicationRecord attr_accessor :remember_token before_save { self.email.downcase! } validates :name, presence: true, length: {maximum: 50} validates :uName, presence: true, uniqueness: {case_sensitive: fal...
true
a545120ca208fbc2a330ba867077c61088471ef5
Ruby
czytom/nask_epp
/lib/nask_epp/contact_credentials.rb
UTF-8
1,766
2.65625
3
[ "MIT" ]
permissive
class NaskEpp::ContactCredentials class Error < StandardError end POSTAL_ATTRIBUTES = [ :name, :street, :city, :province, :zip_code, :country ] ATTRIBUTES = [ :contact_id, :phone, :fax, :email, :person, :publish ] + POSTAL_ATTRIBUTES ATTRIBUTES.each do |...
true
c838c8a96ec40f02077a9e89975bedac92ba8cec
Ruby
ChampagneOtousan/panaderia-amistosa
/class.rb
UTF-8
521
2.515625
3
[]
no_license
class Cake attr_accessor :title, :price, :image def initialize(title, price, image) @title = title @price = price @image = image end end class Cookie attr_accessor :title, :price, :image def initialize(title, price, image) @title = title @price = price @ima...
true
163e93a92cff158b0a6fb9b37376bb5bfeb25301
Ruby
yxp010/school-domain-houston-web-career-040119
/lib/school.rb
UTF-8
600
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code here! class School attr_accessor :roster attr_reader :name def initialize(name) @name = name @roster = {} end def add_student(name, grade) if @roster[grade] == nil @roster[grade] = [] @roster[grade] << name else @roster[grade] << name end @roster[grade].sort...
true
01922b2da1736727477c2f75adda49b6684b18a5
Ruby
Xeitor/unit-testing-isw
/spec/carrito_spec.rb
UTF-8
1,882
3.015625
3
[]
no_license
# rubocop:disable require 'carrito' require 'article' describe "Carrito" do let(:carrito) { Carrito.new } let(:article_with_stock) { Article.new(stock: 1000, product_name: "Macbook Pro 16gb", description: "Descripcion", price: 100) } let(:article_without_stock) { Article.new(stock: 0, product_name: "Macbook Pro ...
true
1a777215075a01e33b257d84b37ca4dfcec210c3
Ruby
mmacedo/euler
/ruby/001.rb
UTF-8
212
3.5625
4
[]
no_license
#!/usr/bin/env ruby # http://projecteuler.net/problem=1 def sum_multiples_of_3_and_5_below(limit) (1...limit).select { |n| n % 3 == 0 or n % 5 == 0 }.inject(:+) end puts sum_multiples_of_3_and_5_below(1000)
true
bf358b7f58f8833b351cf3ce1ae4de1ead4895bf
Ruby
caius/brightbox-cli
/lib/brightbox-cli/commands/images-register.rb
UTF-8
1,684
2.59375
3
[ "MIT" ]
permissive
module Brightbox desc 'Register an image' command [:register] do |c| c.desc "Name to give the image" c.flag [:n, "name"] c.desc "Image Username" c.flag [:u, "username"] c.desc "Archtecture of the image (i686 or x86_64)" c.flag [:a, "arch"] c.desc "Source filename of the image you upl...
true
80af472738e038d58458c752e8d737b4818a7a54
Ruby
kavindabest/mars_rover
/lib/mars_rover/plateau.rb
UTF-8
396
3.359375
3
[]
no_license
module MarsRover class Plateau attr_reader :lower_left, :upper_right def initialize(lower_left, upper_right) @lower_left = Position.new(lower_left[0], lower_left[1]) @upper_right = Position.new(upper_right[0], upper_right[1]) end def in_the_area?(new_value, eje) new_value.between?(l...
true
334f9fb453cb4196368b9245aa99ccacace6f9e6
Ruby
rodrigoruas/food-delivery-01-with-base-repo
/router.rb
UTF-8
1,011
3.390625
3
[]
no_license
class Router def initialize(meals_controller, customers_controller) @meals_controller = meals_controller @customers_controller = customers_controller @running = true end def run while @running print_menu choice = gets.chomp.to_i print `clear` route_action(choice) end ...
true
fa99eb0ed8f4ebb4da3c158e180cbeb39c87536f
Ruby
wschenk/willschenk.com
/content/howto/2020/checking_rss_health/load_feed.rb
UTF-8
799
2.671875
3
[]
no_license
require 'feedjira' require 'httparty' def load_feed feed_url resp = HTTParty.get feed_url if resp.code == 200 Feedjira::Feed.add_common_feed_element("generator") feed = Feedjira.parse(resp.body) info = { title: feed.title, feed: feed_url, link: feed.url, description: feed.des...
true
015ff1023127357443bab1b5d44d4f41117b5670
Ruby
mwolf-net/number-obfuscator
/lib/number_obfuscator/summation.rb
UTF-8
390
3.015625
3
[]
no_license
require_relative 'binary_expression' module Obfuscator class Summation < BinaryExpression addType(Summation) def to_s "#{left.to_s}+#{right.to_s}" end def to_tex "#{left.to_tex}+#{right.to_tex}" end def Summation.canDo(n) n > 2 end def Summation.makePair(n) ...
true
11d8a1c37feaf6e28bb8767341bde4ac0ed6c7a8
Ruby
antw/kin
/lib/kin/form_builder.rb
UTF-8
6,994
2.90625
3
[ "MIT" ]
permissive
module Kin ## # Adds some extra form helpers to the merb-helper defaults. # # Includes: # * date_field for entering a date. # * time_field for entering a time. # * datetime_field for entering a date and time. # * label_field - tweaks the default to create note blocks and asterisks. # module ...
true
b1d9052717db07d9ed2bbaa2c96abad8753515fa
Ruby
EricEntropy/SnkrReleases2021
/lib/UpcomingSnkrReleases/CLI.rb
UTF-8
1,530
3.15625
3
[ "MIT" ]
permissive
class CLI def self.begin system "clear" welcomeMSG self.brands_menu self.snkrs_menu end def self.welcomeMSG puts "\nWelcome to UpcomingSnkrReleases for 2021!" puts "Here is a list of the available brands:" puts "" end def self.brands_menu ...
true
c001c718f967695e9bf6cb63ab0577f876ef1c96
Ruby
mariomanzoni/Enterprise-Recipes-with-Ruby-and-Rails
/code/testing/rspec/rspecmocks/vendor/plugins/rspec/lib/spec/matchers/has.rb
UTF-8
1,109
2.796875
3
[ "MIT" ]
permissive
#--- # Excerpted from "Enterprise Recipes for Ruby and Rails", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose...
true
123671fda83684eeabeee899fced331c40e99876
Ruby
jinnic/ruby-enumerables-hash-practice-emoticon-translator-lab-nyc04-seng-ft-041920
/lib/translator.rb
UTF-8
1,543
3.796875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# require modules here require "yaml" #require "pry" #emoticons = YAML.load_file('emoticons.yml') # method that loads the emoticons.yml file # return a hash where each key is the name of an emoticons # Each emoticon name should point to a nested hash # containing two keys, :english and :japanese # { # 'angel' =...
true
bba082179de87c19e1647ef0334e4dbadc217197
Ruby
github/bert
/lib/bert/decoder.rb
UTF-8
205
2.6875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module BERT class Decoder # Decode a BERT into a Ruby object. # +bert+ is the BERT String # # Returns a Ruby object def self.decode(bert) Decode.decode(bert) end end end
true
71f161dbae643e30bb21804d405e4a58b65bdfc5
Ruby
Ekelly140/ruby-collaborating-objects-lab-v-000
/lib/artist.rb
UTF-8
535
3.40625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Artist attr_accessor :name, :songs @@all = [] def initialize(name) @name = name @songs = [] end def add_song(song) @songs << song end def save @@all.each do |a| return false if a.name == self.name end @@all << self end def self.all @@...
true
40710a5bc875b03eff4d433472ad3d7df96b7624
Ruby
MaleehaBhuiyan/square_array-ruby-apply-000
/square_array.rb
UTF-8
136
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
numbers = [1,2,3] def square_array(numbers) new_array = [] numbers.each{|number| new_array.push(number**2)} return new_array end
true
a9e31cce3178dacef17d5d9aa0e745ae360b6301
Ruby
flannerychristopher/petercooper_beginningruby
/ch02/pets.rb
UTF-8
965
4.15625
4
[]
no_license
class Cat   attr_accessor :name, :age, :gender, :color end class Dog   attr_accessor :name, :age, :gender, :color end class Snake   attr_accessor :name, :age, :gender, :color end #refactor class Pet    attr_accessor :name, :age, :gender, :color end class Cat < Pet end class Dog   def bark(i)     i.times do       pu...
true
662755c93d1e5bdf5acf696965d9e081df2d7726
Ruby
raphaelctrindade/bolao2014
/app/models/question_scorer.rb
UTF-8
397
2.625
3
[ "MIT" ]
permissive
class QuestionScorer # include Scorer # TODO? attr_reader :question def initialize(question) @question = question end # Score all existing question_bets for this question (calculates the points and saves on the question_bets). # Can be run any number of times. def score_all! question.question_b...
true
a135597e15e06c89a0d0a5115c4084222b2bf3b6
Ruby
Reinagal/BUDDYNGO
/app/models/guest.rb
UTF-8
1,299
2.59375
3
[]
no_license
class Guest < ApplicationRecord belongs_to :event has_many :answers validates :name, presence: true validate :mail_or_phone_number validate :valid_french_phone_number after_create :format_phone_number def mail_or_phone_number if phone_number == "" && email == "" errors.add("You have to add an e...
true
ca87f0cc1896d69fae3a2e921b3f7f6cf3768d0c
Ruby
IsaacZhi/saashw
/hw1/hw1p1.rb
UTF-8
1,104
3.796875
4
[]
no_license
def palindrome?(string) if ( string == nil ) return true end replaceString = string.gsub(/\W/, '') downcaseString = replaceString.downcase return downcaseString == downcaseString.reverse end #p true == palindrome?("A man, a plan, a canal -- Panama") #p true == palindrome?("Madam, I'm Adam!") #p false =...
true
10fa01a7175e4357cee8987a3f5e205f0360b1fe
Ruby
jkubacki/friends-api
/app/services/time_ranges/long_enough.rb
UTF-8
426
2.59375
3
[]
no_license
# frozen_string_literal: true module TimeRanges class LongEnough < ApplicationService def initialize(group:, time_range:) @group = group @time_range = time_range end def call time_range_in_minutes >= group.meeting_length_in_minutes end private attr_reader :group, :time_ra...
true
ee3c6c8fac8cc49a0c528ea78198a27f1d941ea1
Ruby
febuiles/rubyconfar
/defer.rb
UTF-8
194
2.75
3
[]
no_license
module Graham def receive_data(number) calculate = proc { graham(number) } report = proc { |result| send_data(result) } EM.defer(calculate, report) end end
true
fda713848bd52024b4cfdb9d82baa15f286982ee
Ruby
cep104/sweater_weather
/bin/sw
UTF-8
741
2.53125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require "bundler/setup" #require "movies" require 'rest-client' require 'json' require 'pry' require 'require_all' require_all 'lib' # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. # (If you us...
true
c225aeabb86e0649dfb2eb7a02e2648400f60f0f
Ruby
pnewsam/phase-0-tracks
/ruby/secret_agents.rb
UTF-8
1,938
4.6875
5
[]
no_license
# Encrypt method: # - For each character in the string # - If it's a letter, advance letter by one # - Else if it's a space, ignore it # - Return the encrypted string # Decrypt method: # - Define a variable that contains the entire alphabet # - For each character in the string # - Check its index within alp...
true
91bfd1632566939b5a89368898bbc84d9327c39e
Ruby
ptantiku/My-Code
/ruby/test_sendkey/test_sendkey.rb
UTF-8
635
2.90625
3
[]
no_license
#!/usr/bin/env ruby # includes Xdo package require 'xdo/keyboard' require 'xdo/mouse' require 'xdo/xwindow' # search for window id using title name win_id = XDo::XWindow.search("Slalom Canoe 2012").last # Uncomment to bring the window up (I don't need to bring it up) # window = XDo::XWindow.new(win_id) # create win...
true
75addc27298afcb9a7adcc858f57f3db9e7efbe5
Ruby
FelipeGuz/ruby_kommit_fgs
/unit13/merge_method.rb
UTF-8
747
4.0625
4
[]
no_license
## combine hashes market = { garlic: '3 cloves', tomatoes: '5 batches', milk: '10 gallons' } kitchen = { bread: '2 loaves', yogurt: '20 cans', milk: '100 gallons' } ## merge(hash): #=> the hash is going to be combined with the argument hash #=> if bouth has similar keys, ruby keeps only the o...
true
3326eab31c97af94792190d786607dafbab600e7
Ruby
David-Roark/code_practice
/exercism/custom-set/custom_set.rb
UTF-8
678
3.546875
4
[]
no_license
class CustomSet attr_reader :values def initialize(values) @values = values.uniq.sort end def empty? @values.size == 0 end def member?(e) @values.include?(e) end def subset?(oth) @values == (@values & oth.values) end def disjoint?(oth) (@values & oth.values).empty? end ...
true
6ceb7aba01a1df4be22fd58099debebb2ed357e3
Ruby
allison-johnson/rack-responses-lab-online-web-ft-120919
/app/application.rb
UTF-8
253
3.046875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Application def call(env) resp = Rack::Response.new h = Time.now.hour.to_i if h < 12 resp.write("Good Morning!") else resp.write("Good Afternoon!") end #if resp.finish end #call end #class
true