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
196b3cb1736148bbb2e585a36b86368c0b70e3d3
Ruby
urbantumbleweed/urbantumbleweed
/w01/d03/Paul_Lee/Classwork/morning_exercise_d03_part2.rb
UTF-8
338
3.6875
4
[]
no_license
#division puts "Enter a base number" base_num = gets.chomp.to_i puts "Enter a divisor" divisor = gets.chomp.to_i times_loop = 0 times_divided = 0 ans = 0 while times_loop < divisor base_num -= divisor times_divided += 1 ans = times_divided times_loop += 1 end remainder = base_num puts ans puts "Remainder...
true
6cc57146062bcb8376768a754481930c37a974c2
Ruby
iankronquist/puppet-test-files
/lib/lookup_simple.rb
UTF-8
9,739
3.140625
3
[]
no_license
# Looks up data defined using Data Binding, and Data Providers using different strategies. The lookup searches in # Data Bindings first (if configured; typically Hiera), then in the environments data provider (if any), and last in # the module's data provider (if any) of the module the call to lookup originates from. T...
true
32bf68057817f256f18717d1d1236b4570105026
Ruby
PankeshGupta/Ruby-Games-Scripts
/games/anagram/two_word_anagram.rb
UTF-8
416
4.1875
4
[]
no_license
puts "What is your three letter word?" word = gets.chomp.downcase def reverse_letters(word) # word_array = word.split(//) # place the characters of the word into an array output_array = word_array.permutation.map{ |i| i.join } # joins the characters in the array of two permutations(for two letters words i.e "...
true
ef9b8b8a3404ba0232b72bf3aebf44514b63db81
Ruby
XanderRiga/statify
/app/workers/track_hear.rb
UTF-8
1,844
2.609375
3
[]
no_license
require 'hears/track_hear' require 'users/helpers/retrieve_spotify_user' class TrackHear include Sidekiq::Worker sidekiq_options retry: false def perform(user_id) last_listened_track = Users::Helpers::RetrieveSpotifyUser.new.call(user_id: user_id)&. recently_played(limit: 1)&.first return if no...
true
05296d23c4c55bb51ceb3ee3b5891f1ae70d6e72
Ruby
kevinmtrowbridge/data-vis-example
/app/models/dataset.rb
UTF-8
1,894
2.515625
3
[]
no_license
# == Schema Information # # Table name: datasets # # id :integer not null, primary key # name :string # data_source_id :integer # hdfs_data_source_id :integer # created_at :datetime not null # updated_at :datetime not null # class Da...
true
61de48a81af8c83c8cec5045d2f17959a67a4696
Ruby
jaswanthJeenu/Ruby-to-MIPS-Compiler
/project/test/binsearch.rb
UTF-8
488
3.8125
4
[]
no_license
a = [] b = 1 left = 0 right = 9 for i in 0..9 do a[i] = i + b b = b + i end for i in 0..9 do puts a[i] puts " " end puts "Enter a number to search : " number = gets def binSearch(number) flag = 1 while ((left <= right) && flag ==1) do mid = (left + right)/2 if (a[mid]==number) flag = 0 elsif (a[mid] ...
true
064f757f4a5e8cc4ad625882efaa75e66553bf99
Ruby
tcrane20/AdvanceWarsEngine
/Advance Wars Edit/Scripts/[200]Seaport.rb
UTF-8
1,031
2.859375
3
[]
no_license
class Seaport < Property def initialize(x, y, army = 0) super(x, y, army) @name = 'seaport' @id = TILE_SEAPORT @ai_value = 500 end def move_cost_chart(move_type) return case move_type when MOVE_FOOT then return [1] when MOVE_MECH then return [1] when MOVE_TIRE ...
true
51cd05c58fae72f5c6a7a18d9cc2b46b158ad287
Ruby
cin9247/MealMonster
/app/models/invoice.rb
UTF-8
443
2.953125
3
[]
no_license
require_relative "./money" class Invoice attr_accessor :month, :line_items, :customer def initialize(attributes={}) attributes.each do |key, value| send "#{key}=", value end end def total_price line_items.reduce(Money.new) do |sum, li| sum + li.price end end def total_count ...
true
ad90dee8c21d8d0a7c034118df609a037968b9b8
Ruby
raz5101/test-first-ruby
/myRuby.rb
UTF-8
188
3.375
3
[]
no_license
class Zombie attr_accessor :name, :brains, :hungry def initialize @name = "Ash" @brains = 0 @hungry = false isHungry = @hungry end def hungry? return isHungry end end
true
4afdccc08259bc60b006d5cca4c1072068c7e232
Ruby
nealsutaria/html
/Array.rb
UTF-8
1,524
3.859375
4
[]
no_license
# numbers = [4,8,15,16,23,42] # toys = ["Teddy bear", "Super Soaker", "Board game"] # things = [4, true, "Hello", 10.99] # registrations = [true, true, false, true, false] # # # students = [["Boris", 25, true], # ["Sally", 23, true], # ["Ingrid", 31, false]] # names = %w[Jack Jill John James ...
true
dedd80ca3d4bd07057c60cf95b26c39fd717c50b
Ruby
hirotoyoshidome/sample-ruby
/main/other/sample.rb
UTF-8
4,808
3.90625
4
[]
no_license
#! ruby -Ks # encoding: UTF-8 print ("Hello") #\r\nがつかない print "World" #実行するときはalt + rで実行できるよ #ちなみにencodingの設定は必須 puts("Hello") #\r\nがつく puts "World" =begin 実行時ドキュメント この部分は実行時に無視される 何行書いても大丈夫 =end print ("あいうえお"); print ("あいうえお".class()) #型を出力する(String) print (11); print (11.class) #Integer ()は省力できる String.n...
true
e0b3d197fee163e535d14ac139050988701f73b5
Ruby
edezekiel/alphabetize-in-esperanto-atlanta-web-career-102918
/lib/alphabetize.rb
UTF-8
283
3.171875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" def alphabetize(arr) esperanto = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz".split(//) arr.sort_by do |phrase| phrase.split("").map do |character| esperanto.index(character) end end end #use a method already built into every array, .index, on esperanto
true
32b0165353614b9b7ff741015b2d16f3d08d0cb0
Ruby
m-marquez-medina21/ciclosymetodos
/suma_pares.rb
UTF-8
94
3.015625
3
[]
no_license
i = 1 suma = 0 n = ARGV[0].to_i while i <= n suma += i*2 i += 1 end puts suma
true
51c0ee6d0398c4d651d2b9cf99d6d96bd963a484
Ruby
smcabrera/dot_example
/lib/dot_example/dot_env.rb
UTF-8
790
2.984375
3
[ "MIT" ]
permissive
class DotEnv def initialize(filename = nil) @filename = filename || ".env" create_file_if_does_not_exist end attr_reader :filename def key_lines keys.map { |key| key + "=" }.join("\n") end def lint! unless line.match(/^[^=\s]*=[^=\s]*$/) # TODO: Don't know if this is the best erro...
true
481a1bc520940550d4fc71e1bec141db6b79c4f6
Ruby
BlakeStrickland/weather_report
/sun_rise_set.rb
UTF-8
817
3.375
3
[]
no_license
require 'json' require 'httparty' class SunRiseSet def initialize(zip_code) @zip_code = zip_code @response = get_response end def sun_rise @response["sun_phase"]["sunrise"]["hour"] +":" + @response["sun_phase"]["sunrise"]["minute"]+ " a.m." end def sun_set @response["sun_phase"]["sunset"]["...
true
f5c4d7aea41c3aea0726f403b8d597aafaf4830f
Ruby
marleyhill/chitter-challenge
/lib/peeps.rb
UTF-8
803
3.09375
3
[]
no_license
require 'pg' require_relative 'database_connection' class Peeps attr_reader :id, :message, :time, :date, :user_id def initialize(id:, message:, time: '', date: '', user_id:) @id = id @message = message @time = time @date = date @user_id = user_id end def self.all result = DatabaseConn...
true
474ca3bafe3fed6d8c7bd36d3a1af639201f51fc
Ruby
Krolmir/ruby-exercises
/ruby_basics/loops/empty_array.rb
UTF-8
232
3.15625
3
[]
no_license
names = ['Sally', 'Joe', 'Lisa', 'Henry'] while names.length != 0 p names.delete_at(0) end p names names = ['Sally', 'Joe', 'Lisa', 'Henry'] loop do p names.delete_at(0) if names.length == 0 break end end p names
true
d565a853c3d57b76f10ad65828cc4fddb6d9ca54
Ruby
jcurhan/task_lister
/app/models/list.rb
UTF-8
869
2.90625
3
[]
no_license
# == Schema Information # # Table name: lists # # id :integer not null, primary key # title :string # created_at :datetime not null # updated_at :datetime not null # class List < ActiveRecord::Base belongs_to :board has_many :tasks validates :title, presence: true def...
true
45e5e89471693c75e5564acf7f644b1a3e98f1fe
Ruby
dkubb/memoizable
/lib/memoizable/memory.rb
UTF-8
2,703
3.515625
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# encoding: utf-8 module Memoizable # Storage for memoized methods class Memory # Initialize the memory storage for memoized methods # # @param [Hash] memory # # @return [undefined] # # @api private def initialize(memory) @memory = memory @monitor = Monitor.new ...
true
a6082b36aded9cadb3187d32716c0cd1d7c3240e
Ruby
araneo/rocket
/rocket-server/lib/rocket/server/channel.rb
UTF-8
551
2.578125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Rocket module Server class Channel < EM::Channel # Get specfied channel for given app or create it if doesn't exist. # # Channel["my-app" => "testing-channel"] # => #<Rocket::Channel> # Channel["my-another-app" => "next-one"] # def self.[](id) app, name ...
true
31330bfa5b3b9aaba2cb129472e603ed50cb4e0e
Ruby
davidPerezRamirez/aydoo2017ruby
/factores-primos-4/model/validador.rb
UTF-8
245
2.984375
3
[]
no_license
require 'sinatra/base' def halt_400_Bad_Request(message) halt 400, "400 Bad Request: #{message}" end def validarNumeroEntero(numero) if !(/\D/ !~ numero) halt_400_Bad_Request("El valor ingresado no es un numero entero positivo") end end
true
3164912bdf23d17d2d9b45924fe5d4b2347c759d
Ruby
PierrickI3/inin-dialer
/lib/puppet/parser/functions/latest_version.rb
UTF-8
484
2.703125
3
[ "Apache-2.0" ]
permissive
# # Gets the latest version of a file # # Usage: latest_version(dir, pattern) # # params: # # - dir: path to files # - pattern: file matching pattern # #require 'fileutils' module Puppet::Parser::Functions newfunction(:latest_version, :type => :rvalue) do |args| directory = args[0] pattern = args[1] debug...
true
2f2b9c3138894502e37444db423fa5cd76cf347d
Ruby
balalnaeem/launch-school-101-lessons
/exercises/easy_6/3.rb
UTF-8
1,351
4.5
4
[]
no_license
=begin Write a method that calculates and returns the index of the first Fibonacci number that has the number of digits specified as an argument. (The first Fibonacci number has index 1.) In: an integer Out: an integer Rule: first fibbonacci number has index of 1. Not 0. (so basically I will use the length of the ar...
true
e8bf73940aefbd7d3ac8391caa77bf7f28a84669
Ruby
zoebisch/ruby-music-library-cli-v-000
/lib/artist.rb
UTF-8
385
2.828125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist extend Concerns::ClassMethods extend Concerns::Findable extend Concerns::Searchable include Concerns::InstanceMethods attr_accessor :name, :songs def self.all @@all end def add_song(song) self.songs.include?(song) || @songs << song song.artist || song.artist = self end de...
true
8e289ef65e622b2a043b3e786a4bb0d4c53425e1
Ruby
MihaiLiviuCojocar/Boris-Bikes_2
/lib/bike_container.rb
UTF-8
390
3.171875
3
[]
no_license
module BikeContainer DEFAULT_CAPACITY = 10 def bikes @bikes end def capacity @capacity end def dock bike raise 'Sorry! No slots available' if full? bikes << bike end def release bike bikes.delete bike end def full? bikes.count == @capacity end def broken_bikes bikes.select { |bike| bike...
true
f98358f0b1ac5f9ad35f75bbb022a24fbcdf1f54
Ruby
dpsk/euler_solutions
/52.rb
UTF-8
228
3.171875
3
[]
no_license
10.upto(1_000_000_000) do |num| same_digits = true (2..6).each do |multiple| same_digits = false unless num.to_s.split("").sort == (num*multiple).to_s.split("").sort end if same_digits puts num; break; end end
true
efd88abc7ad79b21553c50485e562a8503b2ce40
Ruby
chrismlee26/makeschool
/labs/rails-top-tracks-api/vendor/bundle/ruby/2.5.0/gems/msgpack-1.2.4/doclib/msgpack/core_ext.rb
UTF-8
1,677
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
class NilClass # # Same as MessagePack.to_msgpack(self[, packer]). # # @return [String] serialized data # def to_msgpack(packer=nil) end end class TrueClass # # Same as MessagePack.to_msgpack(self[, packer]). # # @return [String] serialized data # def to_msgpack(packer=nil) ...
true
eb6ddf9b35118dbc4706f7f4197eaa5fbb5956af
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/trinary/8138fbeeaeee432797ef101eadaae8c7.rb
UTF-8
373
3.453125
3
[]
no_license
class Trinary def initialize(trinary) @trinary = trinary end def to_decimal total = 0 return total unless valid? @trinary.split(//).reverse.each_with_index do |multiplier, power| total += (3 ** power) * multiplier.to_i end total end def valid? regex = /[^0123]/ retur...
true
c4f551c0b25ee4fe6afe46884675da9393bd2bc6
Ruby
paniwani/andrew_geodistance
/directions.rb
UTF-8
3,105
3.21875
3
[]
no_license
require 'httparty' require 'json' require 'pry' require 'csv' PI = 3.1415926535 RAD_PER_DEG = 0.017453293 Rkm = 6371 # radius in kilometers Rmeters = Rkm * 1000 # radius in meters # Geocoded location of Chokwe District Hospital DESTINATION_LAT = -24.529887 DESTINATION_LON = 32.996639 GOOGLE_DIRECT...
true
8dfea558c8c0da9c5691ff2fd5b58b9085a5a3cf
Ruby
nuajen/Actividad12
/Array/array1.rb
UTF-8
170
3.375
3
[]
no_license
arreglo = [1,2,3,9,1,4,5,2,3,6,6] puts arreglo.first puts arreglo.last puts "Indice : " + 0.to_s + ";Valor" + arreglo[0].to_s puts arreglo print arreglo.select(&:even?)
true
e26a22dbf37344ea8a759b0e42dd3e4df3674c2d
Ruby
KeiIchi-74/furima-31741
/db/seeds.rb
UTF-8
2,448
2.8125
3
[]
no_license
items = [] 10.times do |i| item = Item.create( name: "サンプル#{i + 1}", info: "サンプル#{i + 1}", category_id: 3, sales_status_id: 2, shipping_fee_id: 2, prefecture_id: 2, scheduled_delivery_id: 2, price: 450, user_id: 1 ) items << item item = Item.create( name: "サンプル#{i + ...
true
0a333b34de8ef935072c0482c336572ba1c1081e
Ruby
Adria1988/ProgrammingExercises
/Ruby/Enumerables&Ranges/ShortestWord.rb
UTF-8
665
3.6875
4
[]
no_license
def find_short(t) arr = t.split(" ") min = [] arr.each do |element| min << element.length end lowest = min.min return lowest end describe "Basic Tests" do it "Simple Cases" do Test.assert_equals(find_short("bitcoin take over the world maybe who knows perhaps"), 3) Test.assert_equals(find_sho...
true
4b3516e19654de73e946f9fbba3a929f18988dcf
Ruby
MatFrg/THP_S1-Exercice-en-ruby
/exo_19.rb
UTF-8
101
2.84375
3
[]
no_license
list = [] i = 0 50.times do list << "jean.dupont.#{i}@email.fr" if i%2==0 then puts list[i] end i += 1 end
true
994489bf977556453b2801cb6debc530dfe1279f
Ruby
bogardpd/portfolio
/app/modules/markdown_text.rb
UTF-8
712
2.578125
3
[ "MIT" ]
permissive
module MarkdownText WHITELISTS = { nil => { tags: %w(a em p span strong), attributes: %w(href target) }, computer_supplemental: { tags: %w(a span), attributes: %w(class href target) } } # Returns a Redcarpet Markdown object. def self.markdown renderer...
true
73b98cb1e0fe56d56f5b594ed2d523d5724bfde4
Ruby
nathanshort/adventofcode2020
/11/run.rb
UTF-8
1,456
3.21875
3
[]
no_license
#!/usr/bin/env ruby require_relative '../lib/common' EMPTY = 'L' OCCUPIED = '#' FLOOR = '.' original = Grid.new( :io => ARGF ) current = original.dup # part 1 loop do previous = current.dup previous.each do |point,value| current[point] = case value when EMPTY point.adjacent.all? {|a| ! previous.po...
true
2f95870679d644eb9a66e0c3f3a7b338de29be49
Ruby
KFad11/phrg-oo-cash-register-pca-000
/lib/cash_register.rb
UTF-8
812
3.4375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class CashRegister attr_accessor :discount, :total, :item, :last_transaction def initialize(discount = nil) @total = 0 @discount = discount @item = [] end def add_item(item, price, quantity = 1) self.total += price * quantity quantity.times do items << item end ...
true
06823de410b1e3c309c1a5cb8bd29f96ff384d70
Ruby
scit106/script-demo
/renamer.rb
UTF-8
1,536
3.625
4
[]
no_license
# Rename one File # File.rename("./renameThese/myfile_1.txt", "./renameThese/funfile_1.txt") # Let's Add Variables # pathToFiles = "./renameThese/" # fileToRename = "myfile_1.txt" # newFileName = "funfile_1.txt" # File.rename(pathToFiles + fileToRename, pathToFiles + newFileName) # Let's rename multiple files! # pat...
true
e2aec546d15c7eaec6c3a0b7e0f2cf43f5438af2
Ruby
enkessler/prime_generator_kata
/lib/prime_number_generator/generator.rb
UTF-8
1,357
3.671875
4
[]
no_license
# Ruby's built in Prime number library require 'prime' module PrimeNumberGenerator class Generator def generate_primes(start_number, end_number) validate_input(start_number) validate_input(end_number) start_number, end_number = [start_number, end_number].sort generate_prime_list(start...
true
e68c188221e029a835ce7b14b5307974be128707
Ruby
JonJarGaa/Ruby-Basics-Exercises
/04_user_input/04_user_input _BLANKS/08_dividing_numbers.rb
UTF-8
1,203
4.53125
5
[]
no_license
=begin Write a program that obtains two Integers from the user, then prints the results of dividing the first by the second. The second number must not be 0, and both numbers should be validated using this method: This method returns true if the input string can be converted to an Integer and back to a string wit...
true
fd7ffbad06f1b2b394297d2625d4093f8097687a
Ruby
autostructure/secure_sqlserver
/lib/facter/sqlserver_databases_trustworthy_property.rb
UTF-8
1,240
2.515625
3
[]
no_license
# sqlserver_databases_trustworthy_property.rb # # Determine if the trustworthy property is set on the database. # SQL Server provides the ability for high privileged accounts to impersonate users # in a database using the TRUSTWORTHY feature. This will allow members of the # fixed database role to impersonate any user ...
true
f19c214ce06f82bdaf99458ff107010a7a902cf6
Ruby
lroliphant/rps-challenge
/lib/player.rb
UTF-8
442
3.484375
3
[]
no_license
class Player attr_accessor :chosen attr_reader :selection def initialize @selection = ["rock", "paper", "scissors" ] @chosen = "" end def choose(choice) @chosen = "" case choice when "rock" self.chosen = "rock" when "paper" self.chosen = "paper" when "scissors" ...
true
5ddee789ba17ec8221b24101b238410e8799785d
Ruby
rennhak/EMailBrain
/lib/Brain.rb
UTF-8
6,751
3.046875
3
[]
no_license
#!/usr/bin/ruby #### # # E-Mail Brain # ============ # # The idea of EMailBrain is to be a substitute for display filters used by mutt. # Display filters are for instances programs like t-prot or mutt-display-filter [1]. # # [1] http://aperiodic.net/phil/configs/bin/mutt-display-filter # # # (c) 2010-2011, Bjoern Ren...
true
c034e6c2090eabd571f2311b17a30cf0ef48bc0d
Ruby
shanik1986/LS-Course120
/Lesson4/testing.rb
UTF-8
1,522
3.296875
3
[]
no_license
# module Moveable # attr_accessor :speed, :heading # attr_writer :fuel_capacity, :fuel_efficiency # # def range # @fuel_capacity * @fuel_efficiency # end # end # # class WheeledVehicle # include Moveable # # def initialize(tire_array, km_traveled_per_liter, liters_of_fuel_capacity) # @tires = tire_a...
true
b7e656e92f3398f4626e3f71db296a5e643e1feb
Ruby
S-YOU/compiler-talk
/lib/crystal/codegen.rb
UTF-8
5,319
2.53125
3
[]
no_license
require 'llvm/core' require 'llvm/execution_engine' require 'llvm/transforms/scalar' LLVM.init_x86 module Crystal class ASTNode def llvm_type type.llvm_type end end class Def < ASTNode def mangled_name self.class.mangled_name(owner, name, args.map(&:type)) end def self.mangled_...
true
a974a556bae7b4a59bd86dd66d7ebcec7a3bbe25
Ruby
meganfago/collections_practice-atlanta-web-career-012819
/collections_practice.rb
UTF-8
614
3.75
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def sort_array_asc(array) array.sort end def sort_array_desc(array) array.sort.reverse end def sort_array_char_count(array) array.sort_by {|x| x.length} end def swap_elements(array) array.insert(1, array.delete_at(2)) end def reverse_array(array) array.reverse end def kesha_maker(array) a...
true
d1603dda3aac59777ec1e8db4225232ac1e06005
Ruby
Tibaud/morpion
/ex/gametest.rb
UTF-8
530
3.34375
3
[]
no_license
require_relative "../lib/tic_tac_toe.rb" puts " :::::::::::::::::::: Salut les Morpions ::::::::::::::::::::" #sleep(1) puts " Nom du premier joueur:" nom_1 = gets joueur_1 = TicTacToe::Player.new({color: " ☺ ", name: nom_1.chomp}) #sleep(1) puts " Nom du second joueur:" nom_2 = gets joueur_2 = TicT...
true
8643627e104cbdc2ea6cf87b4cb6ec2c6f0cea4f
Ruby
JZaitz/HighLowRuby
/highlow.rb
UTF-8
181
3.734375
4
[]
no_license
#funtion to take string of numbers and return high and low a = "1 4 6 7 9 44" def highandlow(numbers) numbers.split.map(&:to_i).minmax.reverse.join(' ') end puts highandlow(a)
true
cd0db1aa48b47cf4383d63d84521a7fafb52fee4
Ruby
site-prism/site_prism
/lib/site_prism/page.rb
UTF-8
6,110
2.875
3
[ "BSD-3-Clause", "LicenseRef-scancode-free-unknown" ]
permissive
# frozen_string_literal: true module SitePrism # [SitePrism::Page] # # SitePrism Pages are the top level construct of the POM framework # # Instances of this class represent a full web page that can either be dynamically navigated to # through clicking buttons or filling in fields, or verbosely loaded by u...
true
b46a96a26b180ae3414420554cf2a6ff9cdbe0cb
Ruby
SSchwartz214/credit_check
/lib/credit_check.rb
UTF-8
1,665
3.921875
4
[]
no_license
require "pry" # class CreditCheck def validate_cc(card_number) cc_digits_reversed = process_string(card_number) cc_digits_doubled = double_every_other(cc_digits_reversed) cc_digits_subtracted_by_nine = subtract_nine(cc_digits_doubled) cc_digits_summed = total_sum(cc_digits_subtracted_by_nine) cc_...
true
2d1ab6b5ffb6c60d2ad528b7937ae46665b37bdb
Ruby
AnnahGerletti/hangman
/hangman/hangman_game.rb
UTF-8
881
3.34375
3
[]
no_license
# frozen_string_literal: true class Game attr_reader :saved_guess, :initial_lives, :secret def initialize(dict,initial_lives: 10) @saved_guess = [] @initial_lives = initial_lives @secret = dict.word end def set_secret(new_secret) # override the dictionary secret, with a set secret written in th...
true
85b15df294a5a385050b26942c1fc9be9afbbfae
Ruby
SyntheticAutomation/backend_prework
/day_1/ex4.rb
UTF-8
1,153
3.859375
4
[]
no_license
#created variable: cars cars = 100 #created variable: space_in_a_car space_in_a_car = 4.0 #created variable: drivers drivers = 30 #created variable: passengers passengers = 90 #created variable: cars_not_driven, with one variable minus the other cars_not_driven = cars - drivers #created variable: cars_driven, equal to ...
true
9a5ff2817cf87b5c4a10dfef87cd36eddf8b73e6
Ruby
bcandrea/sinatra-rpc
/spec/sinatra/rpc/handler/introspection_spec.rb
UTF-8
1,916
2.578125
3
[ "MIT" ]
permissive
require 'spec_helper' describe Sinatra::RPC::Handler::Introspection do before(:each) do index = { 'ns.myMethod' => { handler: nil, method: :my_method, help: "This is a test method.", signature: [['nil']] }, 'ns.greet' => { handler: nil, ...
true
e5e593aca7afe2dc75b8e9341da60184130e0e7e
Ruby
carlthuringer/Magic-Hat
/spec/models/task_spec.rb
UTF-8
2,354
2.59375
3
[]
no_license
require 'spec_helper' describe Task do before :each do @user = Factory :user @task = Factory(:task, :user => @user) end it "should create a new instance given valid attributes" do @task.save! end describe "validations" do it "should require a description" do @task.description = "" ...
true
abf6a1960de68c336ca9e7c27d8f0d8971cdd42b
Ruby
kamok/jr-rails-interview-questions
/misc_problems/Active Record exercises.rb
UTF-8
685
2.734375
3
[]
no_license
# 1. Query all users who made three post in three weeks user_ids_three_weeks = Post.all.where("created_at < ?", Time.now !!!!).map(&:user_id) 3_post_in_three_weeks = user_ids_three_weeks.select { |id| user_ids_three_weeks.count(id) >= 3 } Users.all.where(3_post_in_three_weeks).map(&:name) # 2. List of address of pe...
true
1d15073b0e1798db82815c4eead88b1e9c2cfeb2
Ruby
marcusjun/ttt-with-ai-project-cb-000
/lib/players/computer.rb
UTF-8
4,401
3.65625
4
[]
no_license
module Players class Computer < Player def move(board) #If both players are computers then #use the COMPUTER_MOVES in the Board class #that guarantee tied games if Player.both_computers? board.move_array.find{|x| board.valid_move?(x)} ###################################...
true
b1789c27ef99a3e5398dda4a0e9104e447b5c4f8
Ruby
ethunk/Launch-Academy
/sales_tracking/code.rb
UTF-8
899
3.828125
4
[]
no_license
# Your code, here. require 'pry' print "let's get some sales today!" total_sales = 0 input = "" while !(input == "n") do puts "how much was that sale" sale1 = gets.chomp puts "ok our first sale was $#{sale1}" puts "ok how about our second sale?" sale2 = gets.chomp puts "ok our second sale was $#{sale2}" p...
true
d5e2cc2deb6555e1720c245a6e68f13a17d77fcb
Ruby
coreyhaines/PairedWithUs
/db/seeds.rb
UTF-8
620
2.984375
3
[]
no_license
User.destroy_all p1 = User.create email: "coreyhaines@gmail.com", name: "Corey", password: "password" p2 = User.create email: "sarahg.gray@gmail.com", name: "Sarah", password: "password" PairingSession.destroy_all def new_session(from, duration, pair_1, pair_2, *notes) p = PairingSession.create pair_1: pair_1, pai...
true
fe84b1cae44dc22133cd1220ba3d68ab6c832fee
Ruby
pradeepkhot/Programs
/19:example2string.rb
UTF-8
233
3.984375
4
[]
no_license
#Program to print Hello anil if anil is entered else to print How r u ###################################################################### print "enter neme" s=gets.chomp if s=='anil' puts "Hello #{s}" else puts "How r u" end
true
b116e0b7a732ae47aaddea53d19655d34c9f0733
Ruby
hfwbakker/custom_enumerals
/my_each.rb
UTF-8
213
3.75
4
[]
no_license
module Enumerable def my_each return "No block given" unless block_given? for i in self yield i end end end # numbers = [1, 2, 3] # numbers.my_each {|i| puts i} # numbers.each {|i| puts i}
true
985ccfe59a29b53cdda18a4b3c6801f7c00e4bbc
Ruby
vidoseaver/black_thursday
/lib/item.rb
UTF-8
868
2.984375
3
[]
no_license
require "bigdecimal" require "time" require 'pry' class Item attr_reader :id, :name, :description, :unit_price, :created_at, :updated_at, :merchant_id, :parent def initialize(item_data, parent) @id ...
true
40bef52320a8dd4dae55b33e76a3399b24fe270f
Ruby
lucascaton/enumerate_it
/spec/support/test_classes.rb
UTF-8
1,557
3.21875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class TestEnumeration < EnumerateIt::Base associate_values( value_1: ['1', 'Hey, I am 1!'], value_2: ['2', 'Hey, I am 2!'], value_3: ['3', 'Hey, I am 3!'] ) end class TestEnumerationWithoutArray < EnumerateIt::Base associate_values value_one: '1', value_two: '2' end class TestEnumerationWithExtended...
true
427c2b0327712d01a7abe549283c81927eab90e9
Ruby
ualbertalib/NEOSDiscovery
/app/services/marc_module.rb
UTF-8
556
2.53125
3
[]
no_license
require "nokogiri" module MarcModule def nokogiri(document) Nokogiri::XML(document['marc_display']).remove_namespaces! end def marc_field(document, tag) document.xpath("//datafield[@tag='#{tag}']") end def get_marc_subfield(document, tag) document.xpath("subfield[@code='#{tag}']").text end ...
true
a3f8b12bf34a2419b7a43bb706478108af010268
Ruby
mandyreal/ttt-4-display-board-rb-ruby-intro-000
/lib/display_board.rb
UTF-8
264
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Define display_board that accepts a board and prints # out the current state. def display_board(i) puts " #{i[0]} | #{i[1]} | #{i[2]} " puts "-----------" puts " #{i[3]} | #{i[4]} | #{i[5]} " puts "-----------" puts " #{i[6]} | #{i[7]} | #{i[8]} " end
true
c9c4ceeaca1c11aa94ae1e94d0ea2324cad227d8
Ruby
andrewkirkwood/W05_Synth_Shop_Project
/models/product.rb
UTF-8
2,533
3.046875
3
[]
no_license
require_relative( '../db/sql_runner' ) class Product attr_reader( :id ) attr_accessor( :name, :description, :buy_cost, :sell_price, :stock_qty, :sales_qty, :manufacturer_id, :type) def initialize( options ) @id = options['id'].to_i if options['id'] @name = options['name'] @description = options['d...
true
da959d4d3db7c5db4d0a793b24919c5cae698863
Ruby
koenhandekyn/adventofcode
/2019/d12/nbody1.rb
UTF-8
2,808
3.578125
4
[]
no_license
require 'matrix' def assert_eq(v1, v2) raise "expected #{v1} == #{v2}" unless v1 == v2 end class Vector def x self[0] end def y self[1] end def z self[2] end end class Moon attr_accessor :pos attr_accessor :vel def initialize(pos, vel = Vector[0,0,0]) @pos = pos @vel = vel e...
true
83baf81b49f4f2abdc467cedaa6730495e215c98
Ruby
Kacppian/rumodoro
/bin/pm
UTF-8
1,645
2.53125
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' require 'commander/import' require_relative '../lib/pomodoro' require 'fileutils' require 'json' program :name, 'pm' program :version, '0.0.1' program :description, 'A cli-tool to manage your pomodoro cycles' $CONFIG = {} def init_config base_path = `echo $HOME` base_path....
true
ddf88a3c808ef827020218db8815a3b126c9cc75
Ruby
coDeguZo/ruby-oo-practice-has-many-through-template-dc-web-030920
/tools/console.rb
UTF-8
1,429
3
3
[]
no_license
require_relative '../config/environment.rb' def reload load 'config/environment.rb' end drake = Artist.new("Drake") kanye = Artist.new("Kanye") ciara = Artist.new("Ciara") beyonce = Artist.new("Beyonce") eminem = Artist.new("Eminem") john = Artist.new("John Legend") tim = Artist.new("Tim Mcgraw") rap = Genre.new(...
true
48b6bb0a2e19809ed636ef8d3ed6a7e12f5d18b9
Ruby
Croat79/trailofphish
/lib/email/attachment.rb
UTF-8
2,206
3.140625
3
[]
no_license
require 'digest/md5' require 'digest/sha1' require 'digest/sha2' # require 'ssdeep' require 'magic' module Email # # Represents an extracted attachment. # class Attachment attr_reader :path, :name # # Initializes the attachment. # # @param [String] path # The path to the attachment....
true
2b02a83af2ee45ee4bf4f7a4eef7fb042f1f6dbe
Ruby
mimirandi21/Full-Stack-Developer-Coding-Challenge-1
/randirocket/app/services/AlertsSerializer.rb
UTF-8
151
2.609375
3
[]
no_license
class AlertsSerializer def initialize(alert_obj) @alert = alert_obj end def to_serialized_json @alert.to_json end end
true
bc6021166788765a334375d47d609d0e93b09388
Ruby
aks/fresh_connection
/lib/fresh_connection/replica_connection_handler.rb
UTF-8
1,957
2.640625
3
[ "MIT" ]
permissive
require 'concurrent' module FreshConnection class ReplicaConnectionHandler cattr_accessor :replica_query_cache_sync def self.enable_query_cache_sync! @@replica_query_cache_sync = true end def self.disable_query_cache_sync! @@replica_query_cache_sync = false end def initialize...
true
67972bb5ce9bcae302d78116dfd57070cd8a1c2e
Ruby
oleksiizabara/algorithms-ruby-
/greedy_algorithms/minimum_number_of_coins.rb
UTF-8
814
4.03125
4
[]
no_license
class MinimunNumbersOfCoins def self.perform(amount, coins) new(amount, coins).call end def initialize(amount, coins) @amount = amount @coins = coins @result = {} end def call @coins.each do |coin| next if coin > @amount break if @amount.zero? while @amount - coin >= 0...
true
bc1e2c0524ecd773a43bf5f5cf135e18184ddf36
Ruby
igaiga/tmrk01
/missing_instance_variables_sample_rails_app/config/initializers/trace_instance_variables.rb
UTF-8
911
2.625
3
[]
no_license
def tracer(target_instance_variable_name) TracePoint.trace(:line) do |tp| # ソース取得 begin line = File.open(tp.path, "r"){|f| f.readlines[tp.lineno - 1] } rescue Errno::ENOENT => _e end next unless line # erb対応 if match_data = line.match(/\A\s*<%=*(.*)%>\s*\z/) line = match_data.c...
true
ff194eca69b6639dba14350f2c773025a19e1bd7
Ruby
xiaoxinfmc/classic-problem-solving
/two_sum.rb
UTF-8
461
3.59375
4
[]
no_license
# @param {Integer[]} nums # @param {Integer} target # @return {Integer[]} def two_sum(nums, target) existance_map = {}; pair_to_ret = [] nums.each_with_index{ |val, idx| existance_map[val] = idx } nums.each_with_index{ |val, idx| id_to_pair = existance_map[target - val] next if (id_to_pair.n...
true
ab25f0737e117fe749fe657936436203eaea8814
Ruby
Johary-GIT/Le_scrappeur_fou
/lib/crypto.rb
UTF-8
660
3.25
3
[]
no_license
require 'rubygems' require 'nokogiri' require 'open-uri' require 'pry' # 1) Isoler les éléments HTML # 2) En extraire le texte et mettre ça dans un hash, # 3) Réorganiser ce hash dans un array de plusieurs mini-hash comme demandé. def crypto page = Nokogiri::HTML(URI.open("https://coinmarketcap.com/all/views/all...
true
afcda816bfddb91b5dda112d0d0b88b4dd9a4131
Ruby
moneta-rb/moneta
/lib/moneta/optionmerger.rb
UTF-8
1,327
2.65625
3
[ "MIT" ]
permissive
module Moneta # @api private class OptionMerger < Wrapper METHODS = [:key?, :load, :store, :create, :delete, :increment, :clear].freeze attr_reader :default_options # @param [Moneta store] adapter underlying adapter # @param [Hash] options def initialize(adapter, options = {}) super(adap...
true
289131b4c239c6f0f8149bef690104d553585786
Ruby
ekemi/orm-update-lab-onl01-seng-pt-052620
/lib/student.rb
UTF-8
1,380
3.140625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative "../config/environment.rb" class Student # Remember, you can access your database connection anywhere in this class # with DB[:conn] attr_accessor :name, :grade attr_reader :id def initialize(id = nil,name, grade) @id = id @name = name @grade = grade end def self.create_ta...
true
9b9a2e447fe9dc9f53b8a7dc37a6c03ef96c1541
Ruby
Maheshkumar-novice/Recursion-Practice
/merge-sort/merge-sort-secondary-version.rb
UTF-8
1,434
3.640625
4
[]
no_license
#!/usr/bin/env ruby # frozen_string_literal: true # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def merge(left_half, right_half, array) left_index = 0 right_index = 0 array_index = 0 left_max_index = left_half.length - 1 right_max_index = right_half.length - 1 while left_index <= left_max_index...
true
188e8a40f1288e66a0f64ac9b9d5bf72501bc959
Ruby
thoran/zapata
/lib/zapata/printer.rb
UTF-8
2,452
2.890625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module Zapata class Printer class << self extend Memoist def print(raw, args: false) type = raw.type result = case type when :const, :send, :int, :const_send, :literal, :float raw.value when :str str(raw) when...
true
e5ae5855fecc7a8c8813f730ea01389f50b46494
Ruby
Scott-Turner-vs-The-Legacy/legacy_associations_and_validations
/tests.rb
UTF-8
7,373
2.734375
3
[]
no_license
# Basic test requires require 'minitest/autorun' require 'minitest/pride' require 'byebug' # Include both the migration and the app itself require './migration' require './application' # Overwrite the development database connection with a test connection. ActiveRecord::Base.establish_connection( adapter: 'sqlite3...
true
58631537ab46696489dbc2772efeceb94005eef8
Ruby
zinh/ml.rb
/linear_regression/sgd.rb
UTF-8
962
3.5625
4
[]
no_license
require 'pp' require 'pry' # stochastic gradient descent class SGD attr_reader :data_x, :data_y, :theta def initialize(file_data_x, file_data_y) @data_x = read_data_file(file_data_x) @data_x.map!{|x| x.unshift(0)} @data_y = read_data_file(file_data_y) @sample_size = data_x.size @learning_rate =...
true
43376abb64f5927ae7b86867e57a2b483d3ddda4
Ruby
AnastasiaSakhno/pub
/app/models/arrival.rb
UTF-8
809
2.609375
3
[]
no_license
class Arrival < ActiveRecord::Base belongs_to :product belongs_to :user, :foreign_key => :receiver_id before_create :init, :add_products attr_accessible :count, :incoming_price, :sale_price, :product_id, :receiver_id validates :product_id, :presence => true validates :receiver_id, :presence => true valid...
true
a0311079ba57e834769616845951310ad7bca62c
Ruby
arlingtonruby/codernight-03
/Franklin/vendor/bundle/gems/ruby-progressbar-1.5.1/lib/ruby-progressbar/time.rb
UTF-8
484
2.703125
3
[ "MIT", "Ruby" ]
permissive
class ProgressBar class Time def self.now(time = ::Time) @@time = time @@time.send unmocked_time_method end private def self.unmocked_time_method time_mocking_library_methods.find { |method| @@time.respond_to? method } end def self.time_mocking_library_methods [ ...
true
631db7d6abcf93e11fd2327bb180ccd0fee1ed9f
Ruby
Zeraaiur/rails-longest-word-game
/app/controllers/pages_controller.rb
UTF-8
1,169
3.078125
3
[]
no_license
require 'open-uri' require 'json' class PagesController < ApplicationController def game all_letters = ("A".."Z").to_a voyels = ["A", "E", "I", "O", "U"] @my_letters = [] @score = params["score"].to_i || 0 7.times do @my_letters.push all_letters.sample(1).join end 3.times do ...
true
489045aa90ff7636ee8ea4b5485a9b59c269854c
Ruby
pact-foundation/pact-support
/lib/pact/reification.rb
UTF-8
1,463
2.515625
3
[ "MIT" ]
permissive
require 'expgen' require 'pact/term' require 'pact/something_like' require 'pact/array_like' require 'pact/shared/request' require 'pact/consumer_contract/query_hash' require 'pact/consumer_contract/query_string' require 'pact/consumer_contract/string_with_matching_rules' module Pact module Reification include A...
true
898bd4b19862d22e2f6836c88d8b95eb8dbddd07
Ruby
LawrenceWhalen/flash_cards
/lib/card_generator.rb
UTF-8
603
3.09375
3
[]
no_license
require 'pry' require './lib/card' puts Dir.pwd class CardGenerator attr_reader :filename, :cards, :filename_relative def initialize(filename) @filename = filename @filename_relative = File.join(".","lib",@filename) @cards = [] end def create_cards File.foreach(...
true
0b5e13eb224b3f6ece7c89b35ee2114a1fa61b28
Ruby
anureetsra/ruby
/loveRubynote.rb
UTF-8
250
3.421875
3
[]
no_license
puts "I love you while you are good. Are you good? Please answer yes or no:" answer = gets.chomp.downcase while (answer.downcase == "yes") puts "I love you while you are good. Are you good? Please answer yes or no:" answer = gets.chomp.downcase end
true
e658903bb24247383611e47771c0b15ddf8f7916
Ruby
Arielle919/NSS-BackEnd
/2013-12-05-Cheers_1stRubyLab/cheers.rb
UTF-8
251
4.03125
4
[]
no_license
puts "Whats your name?" name = gets.upcase.chomp vowels = ['A','E','I','O','U'] name.each_char do |char| if vowels.include?(char) article = 'an' else article = 'a' end puts 'Give me ' + article +'...'+char end puts name + ' is Great!'
true
43d2c5047f28e5b9e0e7bd2b3e13c7262c77624f
Ruby
jmschoen1/SE381
/atm/features/step_definitions/steps.rb
UTF-8
1,502
2.765625
3
[]
no_license
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'nice_bank') module KnowsTheDomain def my_account @my_account ||= Account.new end def cash_slot @cash_slot ||= CashSlot.new end def teller @teller ||= Teller.new(cash_slot) end end World(KnowsTheDomain) Transform /^\d+$/ do |number| numbe...
true
46c1cd6d3926e2a4b842ac0e7a1c7b1389d2314c
Ruby
kenchan/competitive_programming
/atcoder/abc054/a.rb
UTF-8
168
3.25
3
[]
no_license
a, b = gets.split.map(&:to_i) case when a == b puts 'Draw' when a == 1 puts 'Alice' when b == 1 puts 'Bob' when a > b puts 'Alice' when a < b puts 'Bob' end
true
fb90212f5434bab8da829c8e241421a43597b508
Ruby
keegoo/opensaz
/lib/opensaz/http_miscel.rb
UTF-8
1,813
2.515625
3
[ "MIT" ]
permissive
require 'nokogiri' module Opensaz class HTTPMiscel def initialize(xml_str) @xml = Nokogiri::XML(xml_str) end def timers timers_hash = {} @xml.xpath("/Session/SessionTimers").each do |node| timers_hash = { client_connected: node.attribute("ClientConnected").text, ...
true
457d5d189d263f1f6bde27e301a329e7fc6b528a
Ruby
veetow/adventofcode
/2020/day-14/2.rb
UTF-8
907
2.9375
3
[]
no_license
mask = '0' * 36 memory = {} def apply_mask(mask, address) mask.split(//).each_with_index do |m, i| address[i] = m unless m == '0' end address end def apply_permutation(perms, indices, mask) values = [] perms.each do |perm| addr = mask.dup indices.each do |i| addr[i] = perm.pop.to_s ...
true
c02268a8f7058ab93c89ac4e302dd6820975bcbf
Ruby
gilmae/AoC2020
/day03.rb
UTF-8
526
3.4375
3
[]
no_license
require './helper.rb' include Helper data = get_data("day03.input").map{|l|l.chomp.split("")} def traverse_path(world, x_step, y_step) height = world.length x=0 y=0 trees = 0 while x < height trees +=1 if world[x][y] == "#" y = (y+y_step)%world[x].length x+=x_step end...
true
86c442bf13cf3d386f514ec5f21c6b13dc09785d
Ruby
Pragmaticpraxis37/black_thursday
/test/merchant_repository_test.rb
UTF-8
3,632
2.703125
3
[]
no_license
require './test/test_helper' class MerchantRepositoryTest < Minitest::Test def setup item_path = "./data/items.csv" merchant_path = "./data/merchants.csv" invoice_path = "./data/invoices.csv" invoice_item_path = "./data/invoice_items.csv" customer_path = "./data/custome...
true
d778bc8d5e705e498864286a6a35f6993bc9403e
Ruby
archit2693/CalculatorProject
/lib/calculator/command_runner.rb
UTF-8
1,122
3.234375
3
[]
no_license
require_relative "version" require_relative "calculator_utility" class CommandRunner def run_command(command_string, operand, calculator_utility) case command_string when "add" calculator_utility.add_input_number_to_fixed_number(operand) when "subtract" calculator_utility.subtract_input_numb...
true
8fa5488a1b2c22dda2a7b1f673d4fca2ace72004
Ruby
Eduardo-Castillo-Sfleet/rubyPractice
/user.rb
UTF-8
129
3.375
3
[]
no_license
module User def greeting(name) puts "hi #{name}" end def bye(name) puts "bye #{name}" end end
true
49e94ba297dda836c8453c240196c779da53dcea
Ruby
Frederic-Mousson/21_Exo_Ruby
/exo_03.rb
UTF-8
168
2.90625
3
[]
no_license
puts "Bonjour, monde !" #puts "Et avec une voix sexy, ça donne : Bonjour, monde !" # Avec le '#' la seconde ligne est passée en commentaires et ne s'éxecute donc pas
true
306699ee0d3832af981358ce85b064c63f63ce09
Ruby
abagnard/App-Academy-Work
/w2d1 : w2d2/chess/pieces/rook.rb
UTF-8
228
2.71875
3
[]
no_license
require_relative 'piece' class Rook < Piece def initialize(board,pos,color) super end def symbol :R end def to_s " ♜ ".colorize({color: @color}) end def move_dirs HORIZONTAL_MOVES end end
true
27b65cb38b1b9050409e3710a67828e92d45b810
Ruby
Takouri/Ruby_101
/lesson_4/solution.rb
UTF-8
1,845
4.59375
5
[]
no_license
def sum_even_number_row(row_number) # 1. Create an empty 'rows' array to contain all of the rows rows = [] start_integer = 2 # 2. Create a 'row' array and add it to the overall 'rows' array # 3. Repeat step 2 until all the necessary rows have been created # 1. All rows have been created when the length o...
true
d0f955ecf2e860dc1c5b4bdefab6765d4c2d1fa0
Ruby
kjing/github_cli
/spec/github_cli/util_spec.rb
UTF-8
1,298
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'spec_helper' describe GithubCLI::Util do describe '#flatten_has' do let(:hash) { { :a => { :b => { :c => 1 }}} } it 'preserves original hash' do hash = { :a => 1, :b => 2 } output = subject.flatten_hash hash output.should == hash end it "reduces multidimensional keys to o...
true
098c7d1770f275d92d5f2c0562179b033dfb1205
Ruby
rowen92/nosh-up
/app/models/order.rb
UTF-8
534
2.625
3
[]
no_license
class Order < ActiveRecord::Base belongs_to :user has_many :line_items enum status: [:"Новый", :"В обработке", :"Выполнен", :"Отменен"] validates :user, :status, presence: true self.per_page = 50 def add_line_items_from_cart(cart) cart.line_items.each do |item| item.cart_id = nil line_it...
true