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
ff120aac51dbb58dbb54eed3b48ded4399a4f3c1
Ruby
AndreLaranjeira/RottenPotatoes
/app/models/movie.rb
UTF-8
373
2.515625
3
[]
no_license
require 'active_record' class Movie < ActiveRecord::Base #self.abstract_class = true #attr_accessible :title, :rating, :description, :release_date @@all_ratings = ["G", "PG", "PG-13", "NC-17", "R"] def self.all_ratings @@all_ratings end def self.find_by_director(m) return (m.director.blank? ? []...
true
9791bba902a070230e98583ecf0722c0568990e1
Ruby
hollyglot/code-exercises
/ruby-exercises/test_email.rb
UTF-8
355
2.734375
3
[]
no_license
require 'test/unit' class User attr_accessor :email def initialize(email) @email = email end end # Test if user's email is unique when a User record is created class TestUserEmailUniqueness < Test::Unit::TestCase def test_email_uniqueness user = User.new('boo@bar.com') assert(true, User.where(:...
true
fd587c6190271ee377253e14520459fbbf6797e2
Ruby
pooza/ginseng-core
/test/standard_error_test.rb
UTF-8
443
2.5625
3
[ "MIT" ]
permissive
module Ginseng class StandardErrorTest < TestCase def setup @standard_error = StandardError.new('test') raise 'test2' rescue => e @runtime_error = e end def test_status assert_equal(500, @standard_error.status) assert_equal(500, @runtime_error.status) end def te...
true
69596c28879a1da643b6fd116e5b75b44261f444
Ruby
LipsiaGROUP/stecms-appointment-plugin
/app/models/stecms_appointment/customer.rb
UTF-8
625
2.515625
3
[ "MIT" ]
permissive
module StecmsAppointment class Customer < ActiveRecord::Base has_many :bookings, class_name: 'StecmsAppointment::Booking', foreign_key: 'stecms_appointment_customer_id' def self.search_customers(term) salon_customers = select('id, name, cell') .where("name LIKE :term OR cell LIKE :term", ...
true
080cbb178060ddbd5a5c7f3b53d8d9b817c9ed34
Ruby
cofiem/clearly-query
/lib/clearly/query/helper.rb
UTF-8
2,577
2.8125
3
[ "MIT" ]
permissive
module Clearly module Query # Utility methods for working with Arel. class Helper class << self # Concatenate one or more strings # @param [Array<String>] args strings to concatenate # @return [Arel::Nodes::Node] def string_concat(*args) adapter = ActiveRecord...
true
1219782468263c1e0bedc401074cc282844d68a2
Ruby
rpalo/advent-of-code-2017
/challenges/day21.rb
UTF-8
310
2.921875
3
[]
no_license
# frozen_string_literal: true require_relative '../lib/fractal' start = <<~HEREDOC .#. ..# ### HEREDOC rules = ARGF.read.chomp frac = Fractal.new(start, rules) frac.iterate(5) puts "# of cells on after 5 iterations: #{frac.on}" frac.iterate(13) puts "# of cells on after 18 iterations: #{frac.on}" #Y
true
e486c929bfece3dc18307c59ca83e8a106af8469
Ruby
davebirinyi/aarsiat_app
/test/models/guest_test.rb
UTF-8
1,774
2.78125
3
[]
no_license
require 'test_helper' class GuestTest < ActiveSupport::TestCase def setup @guest = Guest.new( name: "Example Guest", email: "guest@thewedding.com", song_artist: "", song_title: "") end test "should be valid" do assert @guest.valid? end test "name should be present" do ...
true
f8cc954f0f4073479af470d215ad24b96bf4846e
Ruby
rlafranchi/myflix
/spec/models/video_spec.rb
UTF-8
1,899
2.53125
3
[]
no_license
require 'spec_helper' describe Video do it "should save" do v = Video.create(name: 'name', description: 'description' ) expect(Video.first).to eq(v) end it {should belong_to(:category)} it {should validate_presence_of(:name)} it {should validate_presence_of(:description)} it {should have_many(:revi...
true
5517ca5047fcacb64a18d74dc65c7b1b4d621dfd
Ruby
vioif/inheritance_part1
/student.rb
UTF-8
164
3.203125
3
[]
no_license
require_relative 'people' class Student < People def initialize(name) @name = name end def name @name end def learn "I got it!" end end
true
bb69e144fa138d7c1144b341a182279188197d93
Ruby
asmuth/clip-examples
/misc/letters-cyrillic/generate.rb
UTF-8
619
2.609375
3
[]
no_license
#!/usr/bin/env ruby letters = [ ["Аа", "A"], ["Бб", "Be"], ["Вв", "V"], ["Гг", "G"], ["Дд", "D"], ["Ее", "Eh"], ["Ж", "Zh"], ["Зз", "Z"], ["Ии", "I"], ["Пп", "P"], ] letters.each_with_index do |(letter, desc)| spec = <<-EOF (layer/resize A6) (draw/text text "#{letter}" p...
true
49ac9f811e232fb3159d9ec4ad5978c0cbc9fed8
Ruby
derekorgan/ruby
/Terrain/twodarray.rb
UTF-8
2,070
4.125
4
[]
no_license
# A TwoDArray is a Two-Dimensional Array of a consistent width class TwoDArray attr_reader :w, :h include Enumerable include Comparable def initialize (w=0, h=0) if w > 0 and h > 0 @data = Array.new(w){ Array.new(h) } else @data = Array.new{ Array.new } end @w = w @h = h end # getter def [...
true
cafe0ed27db513b68d54a187539d5a7eb4682c8d
Ruby
dunn/homebrew-cmds
/cmd/brew-url.rb
UTF-8
745
2.671875
3
[]
no_license
# brew url <formula> # # List the associated URLs for the given formulae: main download link, # head, devel, bottle for the current OS. require "formula" def print_urls(f) puts "#{Tty.underline}#{f.name}.rb#{Tty.reset}" %w[stable bottle devel head].each do |source| next unless f.send(source) url = "#{Tty....
true
0e730be0353ba2e1ec38b0d8364675370a67918e
Ruby
aysikh/ruby-oo-object-relationships-has-many-lab
/lib/artist.rb
UTF-8
352
3.078125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Artist attr_reader :name @@all = [] def initialize(name) @name = name @@all << self #we want the instances of the songs...not just the name end def self.all @@all end def songs end def add_song(song) end def add_song_by_name end ...
true
60807731a0cf0bb55d862bebb6a912ccaa7e4669
Ruby
vsparrow/ruby-object-initialize-lab-cb-000
/lib/dog.rb
UTF-8
463
3.984375
4
[]
no_license
# Define a Dog class in lib/dog.rb that provides an #initialize method that accepts an argument for the dog's name. # That argument should be stored within a @name instance variable. # # Additionally, Dog#initialize should accept a second optional argument for the dog's breed stored in an instance variable @breed. # ...
true
7eed722faadb4bece92e8c6a173fd43307149ee3
Ruby
davidblackwelder/test
/while.rb
UTF-8
325
4.0625
4
[]
no_license
# num = 1 # while num < 10 # puts num # num += 1 # end # puts "Please enter your name: " # name[] = gets.chomp.downcase.capitalize # while name[] != "Pam" # puts "Please enter your name: " # name = gets.chomp.downcase.capitalize # end num = rand(1..10) while num != 7 puts num num = rand(1..10) end puts "Luc...
true
50df0ae4ae7d4de680ae488b4c259ce888052896
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/binary/fa54f2d009a84323889c705e1d27bcd0.rb
UTF-8
332
3.328125
3
[]
no_license
class Binary ASCII_ZERO = '0'.ord attr_accessor :binary def initialize binary self.binary = binary end def to_decimal binary.bytes.reverse_each.with_index.reduce(0) do |base10,(byte,i)| digit = byte - ASCII_ZERO return 0 unless digit.between? 0,1 base10 + ( digit * 2**i ) en...
true
35e75c411dcca83dc14c8403df2085c7bd8ad4f2
Ruby
gilibethvega/desafio_cuentas_barajas_2
/cuentas_bancarias.rb
UTF-8
979
3.703125
4
[]
no_license
class Usuario attr_accessor :cuenta_bancaria, :nombre def initialize(nombre, cuenta_bancaria) raise ArgumentError, "Se necesita al menos una cuenta" if cuenta_bancaria.size < 1 @nombre = nombre @cuenta_bancaria = cuenta_bancaria end def saldo_total @cuenta_bancaria.map { |x| x.saldo}.sum end ...
true
9835a43b1c0f103837fbbc9a553fe1aca1846c22
Ruby
nysdin/AtCoder
/ABC/157/a.rb
UTF-8
31
2.75
3
[]
no_license
n = gets.to_i puts (n-1)/2 + 1
true
2a707f1c89c8c70431520df00d463f0bac795218
Ruby
Vjp888/backend_prework
/day_4/ex19.rb
UTF-8
1,176
4.53125
5
[]
no_license
#This is creating a parameter and setting an order for the needed information. def cheese_and_chrackers(cheese_count, boxes_of_crackers) puts "You have #{cheese_count} cheeses!" puts "You have #{boxes_of_crackers} boxes of crackers!" puts "Man that's enough for a party!" puts "Get a blanket.\n" end #This is g...
true
eb7f5b410dff740643d279a084b2f10e368dff1c
Ruby
basicxman/rgb-tetris
/docs/planning/draw_blocks.rb
UTF-8
3,135
3.078125
3
[]
no_license
#!/usr/bin/env ruby # Andrew Horsman # Tetris Planning # Draw BlockPrototype require 'gosu' require 'set' require File.expand_path(File.dirname(__FILE__) + '/block_prototype') require File.expand_path(File.dirname(__FILE__) + '/game_config') require File.expand_path(File.dirname(__FILE__) + '/state_machine') class ...
true
d60c82f8b31bc329fb1c395170f33453e15f5e15
Ruby
jeff235255/test_driven_development_minitest
/money.rb
UTF-8
315
3.484375
3
[]
no_license
class Money attr_reader :amount, :currency def initialize(amount, currency) @amount = amount @currency = currency end def self.dollar(amount) Money.new(amount, :USD) end def self.franc(amount) Money.new(amount, :CHF) end def self.vnd(amount) Money.new(amount, :VND) end end
true
4bff25535dd01a593345fcd5f57882a47b8b93ca
Ruby
hirayama/ruby
/awsSdkContainer/test/testmail.rb
UTF-8
1,738
2.75
3
[]
no_license
require 'aws-sdk' # Replace sender@example.com with your "From" address. # This address must be verified with Amazon SES. sender = "no-reply@hoge.jp" # Replace recipient@example.com with a "To" address. If your account # is still in the sandbox, this address must be verified. recipient = "hirayama.tomohiro@hoge.jp" ...
true
f8b0b8222af32e102a8fb49a43aad1544e3301e6
Ruby
srebalaji/100DaysOfAlgorithm
/day98/abstract_factory_design_pattern.rb
UTF-8
625
3.4375
3
[]
no_license
# Abstract Factory Design Pattern. class Computer def initialize(specs) @specs = specs end def build puts "#{self.name} is created with #{self.specs}" end end class Pc < Computer attr_accessor :specs, :name def initialize(specs) @name = "Pc" @specs = specs end end class Server < Computer attr_access...
true
424cefff18b03eeaff60bc81d8e5982b1ab6b5bc
Ruby
efatsi/rails-heroicon
/lib/rails_heroicon/helper.rb
UTF-8
1,834
2.75
3
[ "MIT" ]
permissive
require "action_view" module RailsHeroicon module Helper # To add a heroicon, call <tt><%= heroicon "icon_name" %></tt> on your erb template. # Head over to https://heroicons.com to view all the icons. # # == Options # The helper method accepts mutiple arguments such as: # # === Variant ...
true
397d43b780cf7edf25d635e2b7c85408a12f92b1
Ruby
Watson-Derek/RB120
/Exercises/oo_basics_classes_objects_2/public_secret.rb
UTF-8
172
3.296875
3
[]
no_license
class Person def secret=(s) @secret = s end def secret @secret end end person1 = Person.new person1.secret = 'Shh.. this is a secret!' puts person1.secret
true
4493bac8e6ba71f5c9f70a4fd8dbcd6f1ffbc10b
Ruby
pvselvan/iXperience
/exercises/d3/reverse.rb
UTF-8
187
3.65625
4
[]
no_license
array = ["apples", "bananas", "carrots", 4] # to print in reverse, just use the .reverse method index = array.length - 1 while (index >= 0) puts array[index] index = index - 1 end
true
029f738e25084147a830c83b2980b8d6667e265f
Ruby
castwide/backport
/lib/backport/client.rb
UTF-8
3,048
3.0625
3
[ "MIT" ]
permissive
require 'observer' module Backport # A client connected to a connectable Backport server. # class Client include Observable # @return [Adapter] attr_reader :adapter # @param input [IO] # @param output [IO] # @param adapter [Class, Module] # @param remote [Hash] def initialize in...
true
449373ea1c2f64d8dc47f4734a80a0bf46e2e146
Ruby
matthu24/app_academy_projects
/W2D3/poker/spec/player_spec.rb
UTF-8
1,161
3.1875
3
[]
no_license
require 'player' require 'deck' require 'rspec' require 'byebug' RSpec.describe Player do # before(:each) do # deck = Deck.new # deck.shuffle! # end subject(:player) do deck = Deck.new deck.shuffle! x = Player.new(deck) end describe "#initalize" do it "initializes with empty hand" d...
true
964bc0510d1fb5948c67fb4a56a4ea55211384bc
Ruby
sidharthanc/bridgemart
/spec/models/credit_purchase_spec.rb
UTF-8
1,982
2.515625
3
[]
no_license
describe CreditPurchase, type: :model do it { is_expected.to belong_to(:organization) } it { is_expected.to belong_to(:payment_method) } it { is_expected.to have_many(:credits) } it { is_expected.to allow_value(1.to_money).for(:amount) } it { is_expected.not_to allow_value(0.to_money).for(:amount) } it { ...
true
b813a8e4d811cef03fa9916eb8db9bfa09a4dc9e
Ruby
inesgs12/ruby-objects-has-many-lab-london-web-career-042219
/lib/author.rb
UTF-8
979
3.703125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "pry" class Author @@posts = [] attr_accessor :name, :post def initialize(name) @name = name @posts = [] #has many posts - this is all that means end # def posts #we want to go over all the posts and see the ones that belong to this instance author # Posts.all.select {|posts| post.user ...
true
923b7eed6b7a8bc650402b58766d7441be59ad1b
Ruby
tkbeili/ruby-example
/ruby/hash_from_array.rb
UTF-8
216
3.375
3
[]
no_license
greetings = ["Hello", "Hi", "Hola", "Hey", "Yo"] results = {} greetings.each do |word| results[word.to_sym] = word.length end # another way results = Hash[greetings.map {|x| [x.to_sym, x.length] }] puts results
true
3b579c595c838a779bcebb73fcce93e1df4b8213
Ruby
elbohairy/project_oop
/mastermind.rb
UTF-8
3,300
4.15625
4
[]
no_license
# Things I could still do: # => error handling--there's very little of it # => improve AI: the Odin people seem to think the MasterMind rules involve # telling you if a specific color is in the correct order or not. That is wrong. # Hence writing the AI to know whether, based on the codemaker's response, a given...
true
fb21b242afde4d25ce3f180834568a5096224d0e
Ruby
NicciSheets/tdd_methods
/string_tdd_methods.rb
UTF-8
404
3.5
4
[]
no_license
def concat_method(first_string, second_string) first_string.concat(second_string) #this is essentially just appending the second_string into the first_string, when calling upon this method end def concat_without_method(first_string, second_string) first_string << second_string #by appending the second_string into ...
true
ddf4ee11dae80a93b179ea69621529f19406d7b2
Ruby
mendokusai/lotus01
/vendor/ruby/2.1.0/gems/lotus-helpers-0.2.0/lib/lotus/helpers/html_helper/empty_html_node.rb
UTF-8
1,371
2.734375
3
[ "MIT" ]
permissive
module Lotus module Helpers module HtmlHelper # Empty HTML node # # @since 0.1.0 # @api private class EmptyHtmlNode # Attributes separator # # @since 0.1.0 # @api private ATTRIBUTES_SEPARATOR = ' '.freeze # Initialize a new empty HTML ...
true
b6e3db76fec18d6a0034436d2be4d82e57cae972
Ruby
resant18/cohort-resources
/foundations_remote/hacker_rank_quizzes/hacker_quiz_1/coding1.rb
UTF-8
417
4.1875
4
[]
no_license
# a prime number is a numebr that is only divisibly by 1 and itself. the smallest prime number is 2. Write a method prime? # that accepts a numebr as an argument and returns a boolean indication whether or not the given number is a prime # Examples p prime?(2) # => true p prime?(3) # => true p prime?(7) # => tru...
true
ee1f4f34ae4f2a8c4899f3cd0db2c5f5251af37d
Ruby
railslauncher/clamd
/lib/clamd/configuration.rb
UTF-8
545
2.515625
3
[ "MIT" ]
permissive
module Clamd class Configuration attr_accessor :host, :port, :open_timeout, :read_timeout, :chunk_size ## # Default configuration for Clamd DEFAULTS = { host: 'localhost', port: 9321, open_timeout: 5, read_timeout: 30, chunk_size: 10240 } def initialize s...
true
ed4ccfa0eacf005b32f921ba318059ac3c9c89fe
Ruby
pheen/lemur_board
/app/services/websocket_minion.rb
UTF-8
1,378
2.71875
3
[]
no_license
require 'json' class WebSocketMinion class MinionError < StandardError; end def self.setup(open_sockets, ws, current_user) minion = WebSocketMinion.new(open_sockets, ws, current_user) minion.add_to_open_sockets minion.listen_to_socket minion.write_initial_data end def initialize(open_sockets,...
true
987eb6a68b3e54a41a0d723d01eb49c4ba1a5e8a
Ruby
tessneau/OO-Animal-Zoo-dumbo-web-051319
/lib/Animal.rb
UTF-8
625
3.390625
3
[]
no_license
class Animal attr_reader :species, :nickname attr_accessor :weight, :location @@all = [] #<--LOOK HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! def initialize(species, weight, nickname) @species = species @weight = weight @nickname = nickname @location= location @@all << self en...
true
fd640259cd36f044f48cbea18c5d85ec1fc6cf24
Ruby
nhorton04/W3D2
/skeleton/aa-questions/question_like.rb
UTF-8
3,122
2.59375
3
[]
no_license
require_relative 'links' class QuestionLike def self.find(id) question_like_data = QuestionsDatabase.instance.execute.get_first_row(<<-SQL, id: id) SELECT * FROM question_likes WHERE question_likes.id = :id SQL QuestionLike.new(question_likes_data) end def self.likers...
true
b11cb0d59c7a6e3de6a68ce8cecc0694d796f780
Ruby
logicalproof/Isolation
/Items/Resources/Radioactive.rb
UTF-8
530
2.59375
3
[]
no_license
class Radioactive include Item include Resource attr_accessor :volatility, :decay, :energy def initialize(material_name, player) @name = material_name @overall_quality = get_attribute @volatility = get_attribute @decay = get_attribute @energy = get_attribute @property_list = {:overall_...
true
310aea4f3b8c4a07b8d9fc8b1f5bface2b43cfba
Ruby
runningonfumes/playground
/app/domain/account.rb
UTF-8
2,012
2.546875
3
[]
no_license
class Account include Entity def initialize @balance = Balance.new end def self.create(attributes) account = self.new account.apply_event :account_created, attributes.merge(:uid => new_uid) account end def deposite(amount) self.should_exist new_balance = @balance.deposi...
true
47cf70d4283929a51b3c56156d6d545458fe4903
Ruby
cadebward/dynamic_form_test
/app/fields/integer_field.rb
UTF-8
462
2.828125
3
[]
no_license
class IntegerField < FormField def add_validation_errors(value) unless value.blank? || value.match(/\A[+-]?\d+\Z/) form_value.errors.add :value, 'must be an integer' end int_value = value.to_i if max.present? && int_value > max.to_i form_value.errors.add :value, "can't be greater than #{m...
true
a04c3c7ce4794b5655da97097704d71da93a853c
Ruby
t-akazawa/ruby-book
/lib/deep_freeze.rb
UTF-8
112
2.65625
3
[]
no_license
module Kernel def deep_freeze(obj) obj = obj.map(&:freeze) if obj.class == Array obj.freeze end end
true
3f2d352aee85039a06fc08785772044431a0da7b
Ruby
lindsaymkelly/codewars
/comp_same.rb
UTF-8
2,457
4.4375
4
[]
no_license
# Given two arrays a and b write a function comp(a, b) (compSame(a, b) in Clojure) that checks whether the two arrays have the "same" elements, with the same multiplicities. "Same" means, here, that the elements in b are the elements in a squared, regardless of the order. # Examples # Valid arrays # a = [121, 144, 1...
true
51d0f8f423e9d4c11d9d2e8d90ea63f5e4fa45b8
Ruby
Telixia/leetcode-3
/Medium/0916-Word Subsets/Solution.rb
UTF-8
454
3.453125
3
[]
no_license
# @param {String[]} a # @param {String[]} b # @return {String[]} def word_subsets(a, b) count = [0] * 26 b.each do |sub| count_ = count_chars(sub) (0...26).each do |i| count[i] = [count[i], count_[i]].max end end a.filter { |word| count_chars(word).zip(count).all? { |c| c[0] >= c[1] } } end ...
true
0b88a88d3723226bb69e34b0c7fc74fa6f2aaa8d
Ruby
GrahamBruce84/classes_homework
/sports_team.rb
UTF-8
679
3.59375
4
[]
no_license
class SportsTeam def initialize(team_name, players, coach) @team_name = team_name @players = players @coach = coach @points = 0 end def get_team_name() @team_name end def get_player_names() @players end def get_coach_name() @coach end def get_points() @points en...
true
55ecb0406616fb8c9f2c957e83b90bc048731bc2
Ruby
the-wendell/insurance_calc
/run.rb
UTF-8
1,327
2.609375
3
[]
no_license
# frozen_string_literal: true ENV['CALC_ENV'] = 'production' require 'optparse' require 'rubygems' require 'bundler/setup' require 'require_all' require_all 'lib' PERSONAL_LIABILITY = 'personal_liability' DENTAL = 'dental' VALID_INSURANCE_TYPES = [DENTAL, PERSONAL_LIABILITY].freeze def personal_liability opts = C...
true
77ba61a3dd2b6c778b845c48648515e9e70eef2f
Ruby
mchll05/cc_w2d3_lab
/pub.rb
UTF-8
480
3.265625
3
[]
no_license
class Pub attr_reader :name, :till @@LEGAL_AGE = 18 def initialize(pub_name, till_total) @name = pub_name @till = till_total end def add_to_till drink_price = 5 @till += drink_price end def legal_drink_age?(customer) # legal_drink_age = 18 # @a_customer >= legal_drink_age customer.age >= @@LEGA...
true
9dc6c55375b19d6a31d3b897ec33389fdc86b3af
Ruby
Giagnus64/cli-applications-guessing-game-dumbo-web-071519
/guessing_game_cli.rb
UTF-8
433
4.03125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Code your solution here! def run_guessing_game comp_number = generate_random_number user_number = capture_user_input if (comp_number == user_number.to_i) puts "You guessed the correct number!" elsif user_number == "exit" puts "Goodbye!" else puts "Sorry! The computer guessed #{comp_number}." e...
true
e02652d773a5d7c15ab05533f5878d4294cf2dd0
Ruby
O-I/marvel
/lib/marvel/error.rb
UTF-8
325
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Marvel module Response class Error < StandardError attr_reader :code, :status def initialize(response_hash) @code = response_hash['code'] @status = response_hash['status'] || response_hash['message'] end def to_s "#{@code} #{@status}" end end en...
true
062aa2721d8d531237a3b5e035d6a2dd30e3843d
Ruby
leebardon/ruby-enumerables-reverse-each-word-lab-london-web-012720
/reverse_each_word.rb
UTF-8
113
3.359375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(sentence) array = sentence.split(' ') array.collect {|memo| memo.reverse}.join(' ') end
true
62fdc63b793caa2c4e3bba31d27ac32d18d94e0f
Ruby
HPInc/printos-box-api-samples
/ruby/box_api.rb
UTF-8
7,656
2.65625
3
[ "MIT" ]
permissive
# © Copyright 2016 HP Development Company, L.P. # SPDX-License-Identifier: MIT require 'json' require 'net/http' require 'openssl' require 'time' #access credentials $baseUrl = "https://printos.api.hp.com/box" #use for production account #$baseUrl = "https://stage.printos.api.hp.com/box" #use for staging account $ke...
true
4ca0e91aea3cf1600f388d85834e8848c5174aa3
Ruby
tamycova/30DaysHR
/RUBY/Day29/Solution1.rb
UTF-8
513
3.703125
4
[]
no_license
class TestReader def initialize inp @inp = inp end def each n_tests = @inp.readline.to_i while n_tests > 0 do n_tests -= 1 yield @inp.readline.strip end end end class FunnyTester def self.funny1? s, i (s[i].ord - s[i-1].ord).abs != (s[s.length-i].ord - s[s.length-i-1].ord)....
true
b68181e7b59e78ff0931b90a5ef1a0ee3e925074
Ruby
DanMcDonald91/Code-Clan-Work
/week_2/day_1/specs/bank_accounts_spec.rb
UTF-8
767
2.953125
3
[]
no_license
# Bank Accounts Spec require ('minitest/autorun') require('minitest/rg') require_relative('../BankAccount.rb') class TestBankAccount < MiniTest::Test def test_account_name account = BankAccount.new('Dan' , 500, 'business') account_two =BankAccount.new('Andy' , 600, 'travel') account.account_name = ('Da...
true
c19ec5dfd30f7c623013542d55a08017a864e465
Ruby
osamunmun/AOJ
/vol100/sort3num.rb~
UTF-8
71
2.578125
3
[]
no_license
#!/bin/ruby arr = gets arr.split.map(&:to_i) puts arr.sort.join(" ")
true
9df79a4ac59a9f4d6e6365817def18dec1ff864f
Ruby
cghiban/broccoli
/answer
UTF-8
1,532
2.828125
3
[]
no_license
#!/usr/bin/env ruby -w =begin rdoc Question answering script. Authors: Zach Paine (znp) Mattt Thompson (mattt) Owen Yamauchi (ody) Emilie McConville (emcconvi) =end # So we don't need a long nasty line on every require $: << File.join(File.dirname(__FILE__), '/lib') $:.concat(Dir.glob(File.join...
true
b45723cc0faa4951ac670735b858a66ee53dfd8c
Ruby
CoherentLogic/ehmp20
/chef-repo/project_cookbooks/vista/providers/fileman.rb
UTF-8
8,082
2.6875
3
[ "Apache-2.0" ]
permissive
# # Cookbook Name:: vista # Resource:: fileman # # This provider uses greenletters and PTY to automate install prompts. This can cause odd character output to :log. # # .01 must be a field in field_values # If /.*:\/\// is encountered during input, it is assumed correct # action :create do chef_gem "greenletters" ...
true
d94dc4b66c5dcd1b14349b5edda10c7b15aaf66e
Ruby
johnscancella/scribeAPI
/lib/ocr_alto.rb
UTF-8
1,726
3.109375
3
[ "MIT" ]
permissive
require 'nokogiri' module OcrAlto MARGIN = 50 # box1 overlaps box2 def self.overlap(box1, box2) ! (box1[:hpos] + box1[:width] < box2[:hpos] || box1[:hpos] > box2[:hpos] + box2[:width] || box1[:vpos] + box1[:height] < box2[:vpos] || box1[:vpos] > box2[:vpos] + box2[:height]) end # box1 en...
true
19779899c12d9d8469045609b73ccb91802d7223
Ruby
EmilienMottet/exercism-sol
/ruby/matrix/matrix.rb
UTF-8
370
3.28125
3
[]
no_license
# frozen_string_literal: true # Matrix class Matrix def initialize(args) lines = args.each_line n = lines.count @matrix = Array.new(n) { Array.new(n) } lines.each_with_index do |line, i| line.split.each_with_index { |cell, j| @matrix[i][j] = cell.to_i } end end def rows @matrix e...
true
6f2dd9620ccee82aa9bf218caa71e70a517cca51
Ruby
janetmndz/immersive-module-one-mini-mock-challenge-dumbo-web-071519
/console.rb
UTF-8
638
2.90625
3
[]
no_license
require 'pry' require_relative './book' require_relative './author' jane = Author.new("Jane Austen") emily = Author.new("Emily Brontë") georgette = Author.new("Georgette Heyer") sense_and_sensibility = Book.new("Sense & Sensibility", jane, 119000) emma = Book.new("Emma", jane, 155000) pride_and_prejudice = Book.new("...
true
277c8b98f84f627d9e4263549742ccf1b49679a3
Ruby
tormaroe/fortholito
/fortholito/lexer.rb
UTF-8
1,567
3.03125
3
[]
no_license
module Fortholito TYPE_STRING = :string TYPE_FLOAT = :float TYPE_INT = :int TYPE_WORD = :word Token = Struct.new(:text, :type) do def is_word? word self.type == TYPE_WORD and self.text.chomp.strip == word end end class Lexer attr_reader :tokens def initialize source...
true
d75e1d5a4ea17e0ac8c29ce042e29ac337af9e67
Ruby
BrycenGit/rock_paper_scissors
/spec/rock_paper_spec.rb
UTF-8
694
2.8125
3
[ "MIT" ]
permissive
require('rspec') require('rock_paper') describe("RPS#rock_paper") do it("returns 'win' if rock is the object and scissors is the argument") do game = RPS.new() expect(game.win("rock", "scissors")).to(eq('win')) end it("returns 'win' if paper is the object and rock is the argument") do game = RPS.new...
true
0e45582d0363c33867e7d72a2728c6e9424e0be5
Ruby
InsanityRadio/libatem
/examples/vision_mixer.rb
UTF-8
1,841
2.671875
3
[]
no_license
#!/bin/env ruby $AUDIO_THRESHOLD = 858803 $IP = "10.32.0.119" require_relative '../lib/atem' class VisionMixer attr_accessor :close, :wide def initialize ip, close, wide, slate @ip = ip @close = close @wide = wide @current_camera = wide[0] connect! @close.map! { | w | @atem.inputs[w] } @wide.ma...
true
dd368198d39861e8598e721a3564cc83cb43c871
Ruby
uesteibar/Ironhack-week-2
/1-monday/3-online-calculator/lib/storage/memory_handler.rb
UTF-8
211
3.0625
3
[]
no_license
class MemoryHandler def initialize(storage_provider) @storage_provider = storage_provider end def get @storage_provider.get end def put(number) @storage_provider.put(number) end end
true
6cfc8a066089fdcce25232299a2bacfc644555aa
Ruby
mnhollandplum/black_thursday
/lib/invoice.rb
UTF-8
608
2.8125
3
[]
no_license
class Invoice attr_reader :id, :customer_id, :merchant_id, :created_at attr_accessor :status, :updated_at def initialize(data) @id = data[:id].to_i @customer_id = data[:customer_id].to_i @merchant_id = data[:merchant_id].to_i @status = d...
true
79c6f9587d98673c7ebbfef8e2b64fa869078d34
Ruby
devarora567/basic_ruby_exercise
/reverse_sentence_words/bin/main.rb
UTF-8
93
2.765625
3
[]
no_license
require_relative '../lib/string' puts "Enter the sentence" puts gets.chomp.reverse_sentence
true
a5bcf1a6bedfc954d649a9009e98fc212fd0bc0c
Ruby
tygerbytes/runby-pace
/lib/runby_pace/run_types/tempo_run.rb
UTF-8
1,922
2.953125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Runby module RunTypes # Combines the fast and slow tempo runs into one convenient range of paces class TempoRun < RunType attr_reader :slow_pace_calculator, :fast_pace_calculator def description 'Tempo Run' end def explanation 'Ra...
true
3f3ea9fdb49dcff816e823354a5dc18bc73d3640
Ruby
concow/my-collect-online-web-sp-000
/lib/my_collect.rb
UTF-8
549
3.859375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_collect(collection) i = 0 #initialize counter new_collection = [] #declare new array for later while i < collection.length #condition: while there is a filled array (technically our iterator) new_collection << yield(collection[i]) #[] method to grab each successive i...
true
7834d05e4a03539ed1da1e4f71aa93894bebb177
Ruby
mcruger/HW2office_directory
/edit_list.rb
UTF-8
3,925
3.53125
4
[]
no_license
#1. The program takes one parameter: the bucket name for the office directory #2. It displays the cities as a numbered list and accepts appropriate numbers as input #3. It displays the employees in the selected city in a numbered list and accepts appropriate numbers as input. #4. It requests the name, office location...
true
d2d6e6709405278dc744f6ae236dbe0d0e1db602
Ruby
thekindofme/price_grabber
/parsers/memory_lk_parser.rb
UTF-8
1,593
2.734375
3
[ "MIT" ]
permissive
require 'rubygems' require 'mechanize' module LPriceGrabber class MemoryLK < Parser def categories categories = [] WWW::Mechanize.new.get('http://shop.memory.lk').search("/html/body/div/table/tr[2]/td/table/tr[2]/td[2]/table//a").each do |link| if link['href'].include? 'category-list-' #ther...
true
af699ea72dcfa657834cc0c2a07e8e239be49d9f
Ruby
kenta-s/code-snippets
/ruby/post_json_to_external_url.rb
UTF-8
376
2.796875
3
[]
no_license
require 'net/https' # example: # post_json_to_external_url("http://example.com", {text: "hello"}.to_json) def post_json_to_external_url(url, payload) uri = URI.parse(url) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = Net::HTTP::Post.new(uri.request_uri) req["Content-Type"] = "applicat...
true
23666789dc5e8adcc1cd5cd0848589f53d1b67d8
Ruby
ceh522/static_and_dynamic_testing_pda
/Static_and_Dynamic/spec/test.rb
UTF-8
861
2.84375
3
[]
no_license
require('minitest/autorun') require('minitest/reporters') Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new require_relative('../card.rb') require_relative('../card_game.rb') class CardGameTest < Minitest::Test def setup @card1 = Card.new("clubs", 4) @card2 = Card.new("spades", 1) @cards = [@card1, @car...
true
a31d2802cfb20f3c8edce394847313df0113dbd5
Ruby
alexiscarlier/pdf-generator
/run.rb
UTF-8
488
2.703125
3
[]
no_license
require "prawn" require "./lib/pdf_renderer.rb" require "./lib/text_arranger" text = '.large .bold My First Document .italic .normal .paragraph This is my .large very first .regular .large .paragraph By Alexis Carlier :)' text_arranger = TextArranger.new(text) text_arranger.separate text_arranger.get_string_indexes a...
true
0fb76b4af76b4c318ec291fe0c886555ce4325a6
Ruby
tan-wei/expectr
/lib/expectr/lambda.rb
UTF-8
3,501
3.15625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'expectr' require 'expectr/interface' class Expectr # Public: The Expectr::Lambda Module defines the interface for interacting # with Proc objects in a manner which is similar to interacting with # processes. module Lambda include Expectr::Interface # Public: Initialize the Expectr Lambda inte...
true
bdfb16e69558111c53ca049f3ba0074a00c3b82e
Ruby
fayvera/student-hall
/app/models/student.rb
UTF-8
393
2.59375
3
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Student < ActiveRecord::Base has_secure_password has_many :posts has_many :student_courses has_many :courses, through: :student_courses validates_uniqueness_of(:email) def slug name = first_name + last_name name.downcase.gsub(" ", "-") end def self.find_by_slug(sl...
true
ba207df55696dcc97cb5b3823d3e0264a80b9458
Ruby
berkos/git-analyzer
/lib/git_analyzer.rb
UTF-8
1,095
2.71875
3
[ "MIT" ]
permissive
require_relative 'git_analyzer/formatter/csv' require_relative 'git_analyzer/formatter/pretty' require_relative 'git_analyzer/version' require 'date' require 'pry' module GitAnalyzer class << self def contributors(period: nil) since = generate_since_day(period) result = `git shortlog -sne#{" --sinc...
true
6239e6bd50d4deaf707524f23cdfb146d775cbe4
Ruby
andrewlegend/Calculator
/methods/temperature.rb
UTF-8
123
3.375
3
[]
no_license
def c_to_f(number) puts (number*9)/5+32 end c_to_f(21) def f_to_c(number) puts (number-32)*5+32 end f_to_c(15)
true
b24530108ec790672fb899d17c2b818a664a59f5
Ruby
kevinvaldek/myspeechtime
/test/speech_test.rb
UTF-8
410
2.734375
3
[]
no_license
require 'test/helper' class SpeechTest < ActiveSupport::TestCase context "words" do setup do @speech = MySpeechTime::Speech.new("I am not a talker.") end should "split the text to an array of the words" do assert_equal %w(I am not a talker.), @speech.words end should "have the l...
true
fb78089d64f2c1f0b1b14636fb03a1a7f6e32bf6
Ruby
arnaldoaparicio/flash_cards
/lib/round.rb
UTF-8
1,542
4.1875
4
[]
no_license
require './lib/card' require './lib/turn' require './lib/deck' class Round attr_reader :deck, :turns, :percent, :correct_category def initialize(deck) @deck = deck @turns = [] @percent = percent @correct_category = correct_category end # Returns the first element def current_card @deck....
true
91d09effb517c351d77a80a2fb1a1976886271a1
Ruby
Njunu-sk/Ruby
/advancedloop.rb
UTF-8
218
3.046875
3
[]
no_license
arr = ["simon","paul","mark"] for employee in arr puts "Cityright llc employee :#{employee}" end puts "-----------------------------" arr.each do |employee| print "Cityright llc employee :#{employee}" end
true
968f99f5218794ebf89df6ddef2042b7d8722d64
Ruby
JoshCheek/javascript_interpreter
/lib/js_simulated_blocking/stdlib.rb
UTF-8
1,368
3.1875
3
[]
no_license
require 'js_simulated_blocking/env' require 'js_simulated_blocking/data_structures' class JsSimulatedBlocking class Stdlib # uhm, what is the toplevel object? pretty sure these vars should be strored there instead of in the env def self.global(stdout:, time:, env: env) env.declare(:console, console(env...
true
f470f0c86426ab7eae49559ee1e539a7589edd2d
Ruby
joshuabowers/opium
/lib/opium/extensions/string.rb
UTF-8
446
2.953125
3
[ "MIT" ]
permissive
class ::String def to_bool return true if self == true || self =~ (/^(true|t|yes|y|1)$/i) return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i) raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") end def to_geo_point Opium::GeoPoint.new( self ) end ...
true
344b6898a81f9cd140e7f492c4bb3432a0c5a2b4
Ruby
alexventuraio/vending-machine
/lib/catalog.rb
UTF-8
115
2.546875
3
[]
no_license
class Catalog attr_reader :products def initialize(initial_catalog = []) @products = initial_catalog end end
true
f5a9eff108ef79d89b862985979b9817213513e7
Ruby
jjmora/tests-ruby
/lib/05_timer.rb
UTF-8
532
3.5625
4
[]
no_license
def time_string(s) # Cuantas veces hay 3600 = 1 h # cuantas veces hay 60 = 1 min # el resto son segundos h = 0 while s > 3600 s = s-3600 h += 1 end m = 0 while s > 60 s = s - 60 m += 1 end if h < 10 h = "0#{h}" else h ="#{h}" ...
true
b3049cd5a9bb5f399905ad5fea6a37f943dcae08
Ruby
le3ah/thirsty_plants
/app/models/day.rb
UTF-8
1,417
2.671875
3
[]
no_license
class Day def self.generate_days(args) days_ago = args[:days_ago] || 0 days_from_now = args[:days_from_now] || 7 user = args[:user] ((0 - days_ago) .. days_from_now).map do |i| Day.new(Date.parse(i.days.from_now.localtime.to_s), user) end end def initialize(date, user = nil) @date =...
true
2be366f11c7841114d277092f4382739ad67d277
Ruby
esparratacus/vizeer
/app/controllers/schedules_controller.rb
UTF-8
1,946
2.609375
3
[]
no_license
# Clase encargada de controlar las acciones de objetos de tipo Schedule entre la base de datos y la vista class SchedulesController < ApplicationController #Define los parámetros que son alterables por el controlador def schedule_params params.require(:schedule).permit(:id,:user_id,:dia_semana, :hora_inicio...
true
285db104f7e9873e845a7db87b26fb696e1c57c0
Ruby
LHemingway/spartaClasswork
/w08d04/xml-parsing/xml-parsing.rb
UTF-8
196
2.53125
3
[]
no_license
require "nokogiri" doc = Nokogiri::XML(open('./xml_menu.xml')) # puts doc.search('price') # doc.search('food').each do |food| # p food.element_children(1.name) # end puts doc.xpath('//food')
true
07664124dbd5d7aafa3502e8e1d19a1f4902f111
Ruby
hatwell/wk2_day1_lab_homework
/lab_part_a_spec.rb
UTF-8
909
3.296875
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('./lab_part_a') class StudentTest < MiniTest::Test def setup @student_1 = Student.new("Drake", 13) @student_2 = Student.new("Zlatan", 14) end def test_get_name assert_equal("Drake", @student_1.name) assert_equal("Zlatan", @stud...
true
2da6cd43b863f263c00b7de25668933dcfbca9bf
Ruby
Krysta110/cli-applications-jukebox-hou01-seng-ft-042020
/lib/jukebox.rb
UTF-8
2,130
4.25
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Add your code here # def prompt_user_name # puts "Enter your name:" # end # def gets_user_name # user_name = gets.strip # return user_name # end # def say_hello(name) # puts "Hi #{name}" # end # def run_jukebox # prompt_user_name # user_name = gets_user_name # say_hello(user_name)...
true
74e99e1e9fc98519052491b6b5bb980ffd21a515
Ruby
tekzsolt/introduction-to-programming
/1_The_Basics/2.rb
UTF-8
281
3.015625
3
[]
no_license
four_digit_nr = 8576 thousands = four_digit_nr / 1000 hundreds = four_digit_nr % 1000 / 100 tens = four_digit_nr % 1000 % 100 / 10 ones = four_digit_nr % 1000 % 100 % 10 # puts "Thousands: #{thousands}" # puts "Hundreds: #{hundreds}" # puts "Tens: #{tens}" # puts "Ones: #{ones}"
true
9a9bd81f932e92e255bd044fe061a7c1dd4d2d17
Ruby
celeste-gits-it/Phase_0
/week-5/group-research-methods/my_solution.rb
UTF-8
2,680
4.40625
4
[]
no_license
# Person 1 - Emmanuel include Enumerable # Person 1's solution def my_array_finding_method(source, thing_to_find) source.grep(/#{thing_to_find}/) end def my_hash_finding_method(source, thing_to_find) source.select {|k, v| v == thing_to_find}.keys end # Identify and describe the Ruby method(s) you implemented. #...
true
487346de987c4d15724d36eed9135e917c1769ed
Ruby
escobara/RubyPractice
/mpruby_class_obj5.rb
UTF-8
480
4.15625
4
[]
no_license
puts "Before class definition, self =#{self} " var = class Dave puts "Inside class definition, self =#{self}" def say_hello puts 'hi' end self end puts "After class definition, self =#{self} " d = var.new d.say_hello # Before class definition, self =main # Inside class definition, self =Dave # After cla...
true
755cc98558c67bc8956748fd70754fa1176116d4
Ruby
andrewsheelan/bible_search
/lib/sn_snv.rb
UTF-8
1,587
2.671875
3
[]
no_license
agent = Mechanize.new page = agent.get("http://www.sinhalaholybible.com/en/read-bible-sinhala-holy-bible/read-bible-sinhala-tamil-english.html") form = agent.page.forms.first form.username='andrewsheelan' form.password='welcome123' page = form.submit form.buttons.first doc = page.parser puts "Successfully Parsed!" la...
true
51dcc3e36a6a22e0ab8f5ad1227ef328b2c6d14f
Ruby
zottwickel/data-structures_and_algorithms
/knight_moves.rb
UTF-8
1,206
3.546875
4
[]
no_license
class Board attr_accessor :coords def initialize $coords = Array.new for i in 0...8 for j in 0...8 $coords.push([i,j]) end end end end class Knight attr_accessor :pos, :prev, :moves def initialize(pos=[0,3],prev=nil,moves=[]) @pos = pos @moves = [] @prev = prev end end def next_moves(knig...
true
f4a68aec4a231680713bf9f59e79c6558454c540
Ruby
jblas-project/jblas
/examples/complex_svd.rb
UTF-8
504
2.65625
3
[ "BSD-3-Clause" ]
permissive
require 'java' require 'jblas-1.0.3.jar' java_import 'org.jblas.ComplexDoubleMatrix' java_import 'org.jblas.DoubleMatrix' java_import 'org.jblas.Singular' Matrix = ComplexDoubleMatrix M = 4 N = 3 m = Matrix.new(M, N) for i in 0...M for j in 0...N m.put(i, j, i+j, i*j) #m.put(i, j, i+j) end end puts m....
true
c34ad36aaeca2377db17f2090c7dfbb9e63eb5b6
Ruby
Sillhouette/ttt-with-ai-project-v-000
/lib/players/human.rb
UTF-8
315
3.25
3
[]
no_license
## # => Player module for cleanliness purposes ## module Players ## # => Instantiates the human player ## class Human < Player ## # => Makes a move on the board based on player input ## def move(board) puts "What position do you want to move to?" gets.strip; end end end
true
f5b7d904c726d2acc2f189543b1bc2b745d55561
Ruby
JoashWalton/congregation_management_api
/spec/controllers/souls_controller_spec.rb
UTF-8
5,276
2.5625
3
[]
no_license
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold...
true
9152144b72f13c60d61b7a87010d25dc6dd51b66
Ruby
warrenchaudhry/hometime-reservations
/app/models/guest.rb
UTF-8
432
2.53125
3
[]
no_license
class Guest < ApplicationRecord VALID_EMAIL_REGEX = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i has_many :reservations has_many :phone_numbers validates :email, :first_name, :last_name, presence: true validates_format_of :email, with: VALID_EMAIL_REGEX, allow_blank: true validates_uniqueness_of :email, ca...
true
4ee2f71c4d9cb66bf597c3a5edc0fbc89951385f
Ruby
reenz/boris_bikes
/lib/docking_station.rb
UTF-8
444
3.28125
3
[]
no_license
require_relative "bike" class DockingStation attr_reader :docked_bikes def initialize @docked_bikes = [] end def release_bike if @docked_bikes.length == 0 raise "No bike" else return @docked_bikes.pop end end def dock_bike(bike) raise "Its full" if @docked_bikes.length ==...
true
1b08164d43fb7dcb5139430d86a39160f352b56f
Ruby
hassanrehman/project_euler
/problem096.rb
UTF-8
2,609
3.609375
4
[]
no_license
require 'set' class Sudoku attr_accessor :rows, :name def initialize(rows, name=nil) @name = name @rows = rows #.map{|r| r.split("").map(&:to_i) } @indices = (0..8).to_a.product((0..8).to_a) end def to_s r = @rows.map{|r| r.each_slice(3).to_a.map(&:join).join(" ") } s = r.each_slice(3)....
true