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
bf32297171b06da220dc7571838b56085df714f2
Ruby
wstevo4891/bolt-network-react
/lib/services/json_fixture.rb
UTF-8
742
2.953125
3
[]
no_license
# frozen_string_literal: true # Service for writing a JSON fixture for javascript tests class JSONFixture def self.create(genre) new(genre).call end def initialize(genre) @genre = genre @file = file_path(genre) end def call write_fixture end private def file_path(genre) Rails.ro...
true
d4b0dc0ab14d220ddd3fdc76860510937b4a36ac
Ruby
RJTaylor8286/ruby-objects-has-many-through-lab-online-web-pt-110419
/lib/appointment.rb
UTF-8
339
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Appointment attr_accessor :patient, :doctor @@all = [] def initialize(patient, doctor) @name = name @name = name @@all << self end def self.all @@all end end ferris = Patient.new("Ferris Bueller") doogie = Doctor.new("Doogie Howser") new_appointment = Appointment.new('Ja...
true
37dee860563588e455c40dee261ae2739df75503
Ruby
yuzu-r/kaizen-chess
/spec/models/king_spec.rb
UTF-8
7,587
2.71875
3
[]
no_license
require 'rails_helper' RSpec.describe King, type: :model do describe "is_valid_move? returns false if move is not allowed" do before :each do @g = FactoryGirl.create(:joined_game) @king = King.create(position_x: 1, position_y: 2, game: @g, player: @g.white_player) @black_king = King.create(posi...
true
c6a92de07858ff8de01cea209079aa74a1238ff6
Ruby
ehelman1/ccacttt
/app3.rb
UTF-8
3,270
3.046875
3
[]
no_license
require 'sinatra' require_relative "board.rb" require_relative "sequentialAI.rb" require_relative "unbeatable.rb" require_relative "randomAI.rb" require_relative "human.rb" enable :sessions get '/' do erb :index end post "/output" do player_1 = params[:player_1] player_2 = params[:player_2] ...
true
07a787c2d6f175cd7f8022170a1c5f2da6918702
Ruby
wenbo/rubyg
/sample/CHAPTER05/095/lookahead.19.rb
EUC-JP
418
3.265625
3
[]
no_license
# CamelCaseѿ̾ñʬ v = "javaCamelCaseVariable" v.split(/(?=[A-Z])/) # => ["java", "Camel", "Case", "Variable"] v.scan(/(?:\A|[A-Z])[a-z]+/) # => ["java", "Camel", "Case", "Variable"] # Ǹ5ʸ򶭤˶ڤ "abcdefghi".split(/(?=.{5}\z)/) # => ["abcd", "efghi"] # ǽ5ʸ򶭤˶ڤRuby 1.9 "abcdefghi".split(/(?<=\A.{5})/) # => ["abcde",...
true
29e2f5ff1e3bb03976d311d33330ee786fd9e85f
Ruby
jamalhansen/razsell
/lib/razsell/results.rb
UTF-8
1,848
2.9375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'hpricot' module Razsell # This class returns the query results class Results attr_accessor :items, :result_count, :items_per_page def initialize feed @start_index = 0 @items_per_page = 0 @result_count = 0 @items = [] populate_items feed end def add ...
true
5813ea49b9755975283e1b21c8bbc3e3f7841166
Ruby
jeleencubillas/Ruby
/SOLID_Principle/test.rb
UTF-8
1,155
3.5625
4
[]
no_license
# Original Code class Member def initialize(name, email, vip=false, subscription) @type = type @email = email @vip = vip @subscription = subscription end def welcome_pack # Welcome Pack Automation puts "Welcome Package Sent" end def p...
true
1ae5620d6dffeefd4a6a420bd33ac8e4c0e5e332
Ruby
ag4ta/codeowners-checker
/lib/codeowners/checker/group/pattern.rb
UTF-8
1,745
2.96875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'line' module Codeowners class Checker class Group # Defines and manages line type pattern. # Parse the line into pattern, owners and whitespaces. class Pattern < Line attr_accessor :pattern, :owners, :whitespace def self.match?(l...
true
d97809a12badf9c6a37bdee75df6dc096e52a561
Ruby
rock-core/tools-pocolog
/test/cli_test.rb
UTF-8
7,308
2.546875
3
[]
no_license
require 'test_helper' module Pocolog describe "the pocolog command" do before do create_logfile 'test.0.log' do create_logfile_stream 'stream' write_logfile_sample Time.at(10, 100), Time.at(100, 10), 1 write_logfile_sample Time.at(20, 200), Time.a...
true
e6240fa94ac6cffd0117809a3346289ca15b5aa6
Ruby
rafaelpivato/shacip-ruby
/lib/shacip/client/data_resource.rb
UTF-8
2,437
2.96875
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'resource' module Shacip module Client ## # A resource with encapsulated data # # This base class handles the specific cases for resources containing a # common data where all fields will be contained. That is useful when # the back-end wants to...
true
499fdbd7cece2cdc15e0c130b69b7ec58e1d6b05
Ruby
RussCoding/W4D5
/execution_time.rb
UTF-8
1,629
4
4
[]
no_license
def my_min(list) # list.select do |ele| # O(n) list.all? {|ele2| ele2 >= ele} # O(n) end.pop # O(1) end # => O(n) * O(n) + O(1) => O(n^2) def my_min2(list) #Time complexity is O(n) list.inject {|acc, ele| ele < acc ? ele : acc} end list = [ 0, 3, 5, 4, -5, 10, 1, 90 ] # p my_min(list...
true
88d46893ec3b13ee1e6e02b5b3673db020326164
Ruby
ksdnlee/projectEuler
/problem9.rb
UTF-8
239
2.984375
3
[]
no_license
#!/usr/lib/ruby # #find product of abc where a**2 + b**2 = c**2 (1..999).each do |i| a = i**2 (1..i).each do |j| b = j**2 c = 1000 - i - j if (a + b == c**2) p i p j p c p i*j*c end end end
true
b4cdfc6d820db92dbb2e18d4b21aa98f12610836
Ruby
Hopezouzas/learn-co-sandbox
/examples.rb
UTF-8
766
4
4
[]
no_license
puts "Would you like Bernard's, Mandarin Gourmet, Golden Temple, or Dragon Star?" chinese = gets.chomp.to_s if chinese == "Bernard's" puts "Bernard's is 4 stars, 0.7 miles away, somewhat expensive, and is open from 11:30AM to 9PM." elsif chinese == "Mandarin Gourmet" puts "Mandarin Gourmet is 4.3 stars...
true
10f2a55abc8c9e4a0ab5aba267ecdb02fba1f81d
Ruby
SIGS-UnB/core
/app/models/category.rb
UTF-8
386
2.53125
3
[ "MIT" ]
permissive
# frozen_string_literal: true # Class category class Category < ApplicationRecord has_and_belongs_to_many :room has_and_belongs_to_many :school_room CATEGORY_EXISTS = 'Categoria já cadastrada no sistema'.freeze NULL_NAME = 'Nome não pode ser vazio'.freeze validates :name, presence: { message: NULL_NAME }, ...
true
8e39b9952a67bdccbcfacecaeaecf3dc536447e1
Ruby
cr0t/htmlarrows
/helpers/utilities.rb
UTF-8
1,586
2.578125
3
[]
no_license
module Utilities def active_link(*args, &block) # Check for block url_idx = block_given? ? 0 : 1 options_idx = block_given? ? 1 : 2 # Get the url page = current_page.url # Set the url url = args[url_idx] # Get the parent url unless page == "/" || page == "" parent_url = "...
true
3aebcf520b60bbe6ac03e4b93a5bc48a1c7c91e5
Ruby
billdueber/searchparser
/lib/searchparser/boolean_skeleton.rb
UTF-8
1,942
3.109375
3
[ "MIT" ]
permissive
require 'searchparser/basics' module SearchParser # A simple little parser that defines AND/OR/NOT # as the and_op, or_op, and not_op, respectively, # surrounded by whitespace class UppercaseEnglishOps < Parslet::Parser include Basics rule(:and_op) { space? >> str('AND') >> space? } rule(:or_op)...
true
b1583a3093a3ad22328f1e73ce5ffb098547cafc
Ruby
kathryn62/viking-ruby-converter
/test/test_tokenizer.rb
UTF-8
1,320
2.765625
3
[ "MIT" ]
permissive
gem "minitest" require 'minitest/autorun' require 'viking' ## # Class # @author Aaron(BinaryPaean) # Tests for the (crude) HTML Tokenizer # class TestHTMLTokenizer < Minitest::Test def test_linear_tags @t = Viking::HTML::Tokenizer.new("Some Text <i>with italics</i>.") assert_equal "Some Text ...
true
a5e841048ab113be7bfcdfae7d35c586f2098829
Ruby
cmaher92/launch_school
/coursework/rb100/small_problems/easy_8/double_char.rb
UTF-8
619
4.4375
4
[]
no_license
# Double char =begin Write a method that takes a string and returns a new string in which every character is doubled =end # input # string # output # string with every character in original string doubled # given a string # init a results arr # split the string into chars # for each character in the string appe...
true
3632d587a16195bdca27cd53c513e0d037899c90
Ruby
spencerjhamilton/Jungle
/spec/models/user_spec.rb
UTF-8
4,789
2.5625
3
[]
no_license
require 'rails_helper' RSpec.describe User, type: :model do before(:each) do @user = User.new end it 'saves with all fields filled in' do full_user = User.new(first_name: 'a', last_name: 'b', email: 'email@email.com', password: 'apples', password_confirmation: 'apples') full_user.save expect(...
true
1100e6f8bbd0f824bc150bcc8c366fcc66e14a98
Ruby
richarddmiranda/intro_to_programming_exercises
/5_Loops_Iterators/2.rb
UTF-8
115
3.671875
4
[]
no_license
say = nil while say != 'STOP' puts "What do you want to say?" say = gets.chomp puts "You said '#{say}'." end
true
ae392f451bda07ad75d6a8bd1144b256cd75ac89
Ruby
tubbo/choonga.ng
/app/controllers/tags_controller.rb
UTF-8
721
2.5625
3
[ "MIT" ]
permissive
# The Tags Read-Only API has been exposed in order to verify tag # eligibility, as a catch for people who may be entering the wrong tag # information into a form. However, since tags can not be edited by the # userbase, all you can do is request if a tag exists right now. class TagsController < ApplicationController ...
true
c5a3fb29c005c9ef33a0b3b417383d60f1a7e915
Ruby
TyounanMOTI/spatiala
/lib/ray.rb
UTF-8
5,822
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'vector' class Ray attr_accessor :origin, :destination, :delta BIG = 1.0e5 def initialize(origin=Vector.new(0,0), destination=Vector.new(0,0)) @origin = origin @destination = destination @delta = destination - origin end WINDOW = Ray.new(Vector.new(0,1), Vector.new(0,-1)) def origin...
true
6df18e4873a0c0999dfa6569a1706bb14d2cd63c
Ruby
thehicksivist/ruby-challenges
/canvas/total.rb
UTF-8
849
4.59375
5
[]
no_license
# 1 Create a method `total` that takes two numbers and returns their sum. # puts total(4,4) # -> 8 # 2 Adjust your method so you can yield blocks. I.e. when you're done, the following code should work: # total(4,4) do |addition_total| # puts "Addition total is #{addition}" # end # 3 Update your method ...
true
a0305caa3428a4d42cdaab164001b50d1713f09e
Ruby
swt02026/NTNU_1032_OOAD_Homework3
/Transaction/Transaction.rb
UTF-8
415
2.953125
3
[]
no_license
class Transaction attr_reader :customer attr_reader :videos def initialize(videos,customer) @videos = videos @customer = customer @valid = true end def setInvalid @valid = false @videos.map{|e| e.rented = false } @customer.reset end def isValid? @valid end def getSumOfMoney @video...
true
6bee198cf35088bd06d7d54ad7cc66cc64eb337a
Ruby
cha63506/apple_bot
/lib/apple_bot.rb
UTF-8
1,757
2.59375
3
[ "MIT" ]
permissive
require "apple_bot/version" require 'mechanize' module AppleBot class Configuration attr_accessor :user, :password def initialize self.user = 'test' self.password = 'password' end end def self.configuration @configuration ||= Configuration.new end def self.configure yield(...
true
87f8137d6ad2a6a02725ef267ce57450d55597f0
Ruby
grindars/inline_templates
/spec/inline_templates_spec.rb
UTF-8
2,835
2.6875
3
[ "MIT" ]
permissive
require 'spec_helper' describe InlineTemplates do describe 'render' do it 'builds elements' do test_rit do ~ span('test') end.should == "<span>test</span>" end it 'builds multiple elements' do test_rit do ~ span('test 1') ~ span('test 2') end.should == "<s...
true
8bf67c0965736bc36801a10ce570b4245266819d
Ruby
anhtrantuan/zklib-ruby
/lib/zklib/pin_management.rb
UTF-8
528
2.65625
3
[ "MIT" ]
permissive
class Zklib module PINManagement PIN_WIDTH_KEYWORD = '~PIN2Width' # Get PIN width def get_pin_width execute_cmd( command: CMD_DEVICE, command_string: PIN_WIDTH_KEYWORD ) do |opts| return puts "ERROR: #{options[:error]}" unless opts[:valid] data = op...
true
134cecb2dd26e0b39ab8b2dbdd66a09f1e0eb97f
Ruby
ppiron/Intro-to-Programming
/ch5/ex2.rb
UTF-8
110
3.4375
3
[]
no_license
while true puts "Your input?" input = gets.chomp if input == "STOP" break end end
true
e1686cbb8989b7468e0c572f9a79a25eb54ba5a9
Ruby
twistedpixelpete/whats-on-mel
/spec/activity_spec.rb
UTF-8
1,687
2.921875
3
[]
no_license
require_relative '../lib/activity' RSpec.describe Activity do subject(:activity) do described_class.new end #This test is to check if the instance if the activity class is created describe 'Class testing' do it 'should be an instance of Activity' do expect(activity).to be_a Activ...
true
2f7bd20f5535b0bbf354ed4b3d207e7d6a7bce11
Ruby
davelnewton/hpjs
/auctions/bid.rb
UTF-8
331
3.25
3
[]
no_license
require "exceptions" # Bids have a bidder and an amount. # # Currently the amount is expected to be a simple float; sorry. class Bid attr_accessor :bidder, :amount def initialize(bidder, amount) self.bidder = bidder self.amount = amount raise InvalidBidAmountException.new(self) if self.amount <= 0.00...
true
f3ddd616811d016b92e807ebea406cfee89d9108
Ruby
sylviapereira/object_oriented_programming
/people.rb
UTF-8
631
4.21875
4
[]
no_license
class Person attr_accessor = :person_name def initialize(person_name) @person_name = person_name end def greeting puts "Hi, my name is #{@person_name}" end end class Student < Person def learn puts "I get it!" end end class Instructor < Person def teach puts "Everything in Ruby is an ...
true
d2204cacee5240241f01e39ab331ddc1445d441e
Ruby
RickArmstrong1/scratch
/fibonacci.rb
UTF-8
65
3.109375
3
[]
no_license
a = b = 1 while a < 1000 c = a + b puts a a = b b = c end
true
54715620a4173ff06a679fe5d462cfe37381f633
Ruby
everett1992/maps
/ground_overlay.rb
UTF-8
765
2.953125
3
[]
no_license
require_relative './dimentions' class GroundOverlay attr_reader :uri, :north, :south, :east, :west include Dimentions def initialize(uri: uri, n: n, s: s, e: e, w: w) @uri = uri; @north = n @south = s @east = e @west = w end def width_in_miles north_width = Geocoder::Calculations....
true
52aa033924b6ae4fb8f97251d540462f665e74e8
Ruby
jspacco/iclickerviewer
/test.rb
UTF-8
189
3.3125
3
[]
no_license
def current_time return Time.now.to_f end def time_code start = current_time yield return current_time - start end total = time_code { sleep(2) } puts "total time is #{total}"
true
9e7a80a84c1000a1161522cfbe1fb8b6b5dbb816
Ruby
Danielbailey309/T1A3-Terminal-Application
/src/main.rb
UTF-8
3,786
3.5
4
[]
no_license
require_relative 'rock' require 'colorize' require 'tty-prompt' # Creating variables prompt = TTY::Prompt.new menu = menu_options = [1..6] # Adding default rocks to database Rock.new("Diamond", "colourless", "mineral", "none", "none", "colourless", "10") Rock.new("Sapphire", "blue", "mineral", "none", "none", "blue...
true
f3d35d4510049bb86ae850ee065b6b4d73f5eac3
Ruby
geeosh/nreduce-public
/app/models/conversation.rb
UTF-8
5,611
2.5625
3
[]
no_license
class Conversation < ActiveRecord::Base has_many :messages, :dependent => :destroy has_many :conversation_statuses, :dependent => :destroy belongs_to :latest_message, :class_name => 'Message' belongs_to :to_startup, :class_name => 'Startup' serialize :participant_ids, Array accepts_nested_attributes_for :...
true
bc556b179c52db560ad2a68c011db2f97b543cc3
Ruby
Luis-codes/linkedlist1
/linked_list.rb
UTF-8
1,102
4.03125
4
[]
no_license
class LinkedListNode attr_accessor :value, :next_node def initialize(value, next_node=nil) @value = value @next_node = next_node end end def print_values(list_node) if list_node print "#{list_node.value} --> " print_values(list_node.next_node) else print "nil\n" end e...
true
f601a205d2279466d31e784fc1c0870bceb32659
Ruby
cedlemo/lobotomy
/examples/kanas_quiz.rb
UTF-8
2,551
3.03125
3
[]
no_license
#!/usr/bin/env ruby require 'lobotomy' #handle Ctrl-C trap('INT') { puts " leaving..." exit } #clear the terminal system("clear") #set default number of questions and the default column used to build question for the quiz nb_quiz_questions = 10 question_symbol = :hiragana #user can modify the number of question...
true
078a5d438cdbf33db0c7dd2df9542d6c780d5b9c
Ruby
kaorukobo/wrong
/lib/wrong/rescuing.rb
UTF-8
307
2.859375
3
[ "MIT" ]
permissive
module Wrong module Rescuing # Executes a block that is expected to raise an exception. Returns that exception, or nil if none was raised. def rescuing error = nil begin yield rescue Exception, RuntimeError => e error = e end error end end end
true
d8772e19c0eed586338a504fb96d91b6dcba449d
Ruby
shashwat12june/digital_wallet
/transaction_history.rb
UTF-8
278
2.609375
3
[]
no_license
class TransactionHistory attr_accessor :transaction_time, :action, :amount, :source def initialize(action, amount, source) self.transaction_time = Time.now.to_s self.action = action self.amount = amount self.source = source self.status = 'abc' end end
true
af6dfc1acc0a989c0face8eb1b30f0d58b855e00
Ruby
jasperchow5915/toy_robot
/spec/extended_application_spec.rb
UTF-8
20,973
2.65625
3
[ "MIT" ]
permissive
require 'spec_helper' require 'toy_robot' describe ExtendedApplication do let(:application) { ExtendedApplication.new } subject { application } it_should_behave_like "an application" specify "model attributes" do should respond_to(:robots, :target_name, :response) end describe "initial state" do ...
true
0d48638f556e6d594132672c0d6b34d812bf9555
Ruby
MatTerra/EngSoftware-2020-2
/hw1/src/rps_tournament.rb
UTF-8
536
2.765625
3
[]
no_license
require_relative './rock_paper_scissors' class RockPaperScissorsTournament def rps_tournament_winner(tournaments) if RockPaperScissorsGame.is_game(tournaments[0]) return RockPaperScissorsGame.new.rps_game_winner( [RockPaperScissorsGame.new.rps_game_winner(tournaments[0]), RockPaperScissors...
true
6bb561f6df7be0fe1429a019f1867ce4a594d485
Ruby
TiSer/manager
/app/helpers/milestones_helper.rb
UTF-8
785
2.546875
3
[]
no_license
module MilestonesHelper def bill start_data = @milestone.start_date end_data = @milestone.end_date bookings = @milestone.project.bookings.where(:date => start_data..end_data) bill_array = [] @summ = 0 bookings.each do |booking| activity_cos = ActivityCost.where(:project_id => @mileston...
true
70ece70041b945e3c9d89fa3800eebaf0ce8094e
Ruby
domain7/direct_address
/lib/direct_address/harvester/geoname.rb
UTF-8
1,117
2.734375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Geoname class InvalidModelError < StandardError; end def self.retrieve_to_db raise(InvalidModelError, 'Country and Region models must be generated before populating the database. Please make sure the gem is installed into a rails project then try running: script/generate direct_address') if !gem_integrated?...
true
4e54c5323777af08e303a30ff194bf2ccaec7199
Ruby
codigonet/E6CP2A1
/1 metodos/ejercicio5.rb
UTF-8
340
3.609375
4
[]
no_license
# Crear un metodo que reciba como parametro dos numeros enteros positivos # e imprima los numeros pares que existen entre esos dos numeros. def pares_entre_ellos(pmta, pmtb) (pmta..pmtb).each do |item| puts item if item.even? end # (pmt_1..pmt_2).each do |item| # puts item if item.even? # end end pares...
true
13d3ce9953a0a77134ec5581e1e661450aa701e4
Ruby
ttaylorr/lisp.rb
/spec/interpreter_spec.rb
UTF-8
237
2.703125
3
[ "MIT" ]
permissive
require "rspec" require_relative "../lib/interpreter.rb" describe Interpreter do it "stores value literals in variables" do i = Interpreter.new i.evaluate([:define, :x, 3.0]) expect(i.evaluate([:x])).to eql(3.0) end end
true
e7544e0e503274d794f1233ebffa7b3d3a3ddd9e
Ruby
trisulnsm/trisul-scripts
/trp/cert-extract/certx.rb
UTF-8
4,433
2.578125
3
[]
no_license
# Trisul Remote Protocol TRP Demo script # # # Print Cert Chains from particular IP # require 'rubygems' if RUBY_VERSION < '1.9' require 'trisulrp' # investigate_certs # 1. Connect to a trisul probe with demo certs # 2. For the past 1 month # 3. Search for all HTTPS flows for a particular host # 4. Print the...
true
cbfcea6a7e8caad0638ad7e0d58d4978e7a8bb89
Ruby
jtrudell/RampUp
/testing.rb
UTF-8
370
2.984375
3
[]
no_license
require 'minitest/autorun' class MyTest < Minitest::Unit::TestCase def test_that_addition_works assert_equal 4, 2 + 2 end def test_that_my_array_has_a_value animals = ["fish", "cat", "dog"] assert animals.include?("cat") end def test_assert_delta assert_in_delta 3.1534, 3, 0.2 end def test_assert_ma...
true
d2f72dd7473d1eba23606a43555aaecc7296203f
Ruby
ATRAYI/repo
/factorial1.rb
UTF-8
90
2.9375
3
[]
no_license
class Fact def facts n=gets.chomp.to_i puts((1..n).inject(:*)) end f=Fact.new f.facts end
true
867ae717e9b2e757daa2bedc91d6af74b7ce1ab1
Ruby
mloar22/your_home
/db/seeds.rb
UTF-8
1,218
2.890625
3
[]
no_license
require 'faker' # Create Users 5.times do user = User.new( name: Faker::Name.name, email: Faker::Internet.email, password: Faker::Lorem.characters(10) ) # user.skip_confirmation! user.save! end users = User.all # Note: by calling `User.new` instead of `create`, # we create an in...
true
5aaa2b3606033d0e4fe566c1e18315790f07a8f3
Ruby
dvdbng/advent-of-code-2020
/day22p1.rb
UTF-8
416
3.015625
3
[]
no_license
# frozen_string_literal: true require 'set' require 'active_support/all' p1, p2 = File.read('inputd22').strip.split("\n\n").map { |p| p.split.drop(2).map(&:to_i) } while p1.length.positive? && p2.length.positive? c1 = p1.shift c2 = p2.shift if c1 < c2 p2.push(c2) p2.push(c1) else p1.push(c1) ...
true
7ab6cb0cb40e908802ba1a2f7efef0c5c00a07c7
Ruby
micxer/e-comments
/server/backends.rb
UTF-8
2,348
3.25
3
[ "MIT" ]
permissive
# # Attempt to load both "redis" and "sqlite3", it doesn't matter if # one of them fails so long as the other succeeds! # %w( redis sqlite3 ).each do |library| begin require library rescue LoadError puts "Failed to load the library: #{library}" end end # # This is an abstraction layer between our Sin...
true
b61e15cdf46e40a49bd0ac97ef2b7e8448707849
Ruby
lunaeidi/model-class-methods-lab-v-000
/app/models/boat.rb
UTF-8
1,329
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Boat < ActiveRecord::Base belongs_to :captain has_many :boat_classifications has_many :classifications, through: :boat_classifications def self.first_five Boat.all.limit(5) end def self.dinghy Boat.where("length < 20") end def self.ship Boat.where("length >= 20") end def self....
true
a18dd55c79be690e2f765ddada4ce3164eb09de8
Ruby
jesselsmith/JavaScriptandRailsProject
/donjons-and-dragoons-api/app/models/monster.rb
UTF-8
3,985
2.921875
3
[ "MIT" ]
permissive
class Monster < ApplicationRecord belongs_to :character validates :current_hp, numericality: { only_integer: true, less_than_or_equal_to: :max_hp, greater_than_or_equal_to: 0 } validates :attack_bonus, numericality: { only_integer: true } validates :damage, numericality: { only_integer: true, greater_than_or...
true
afb2dce892d7807b03706a0c734d36bfeb12bb5d
Ruby
KevSeenan/CodeClan_Caraoke
/guests.rb
UTF-8
182
2.609375
3
[]
no_license
class Guests attr_reader :name, :check_in, :check_out def initialize(name, check_in, check_out) @name = name @check_in = check_in @check_out = check_out end end
true
1532d4fb711dd0b956680ea30111934a780b5977
Ruby
edean11/terminal-color-capture
/test/integration/test_basic_usage.rb
UTF-8
767
2.609375
3
[ "MIT" ]
permissive
require_relative '../helper' class BasicUsageTest < MiniTest::Test def test_invalid_menu_choice shell_output = "" expected = "" IO.popen('././terminal_color_capture','r+') do |pipe| expected << menu_prompt pipe.puts "21" string = "You must choose one of ...
true
1f8cc518dc200f16da4a383fcebe53a98f52b385
Ruby
yanchengvip/2016-work-stock
/lib/stock_random.rb
UTF-8
1,123
2.84375
3
[]
no_license
class StockRandom def self.coupon_lottery @@coupon_pickup ||= Pickup.new({ "5" => 20, "10" => 74, "20" => 4, "50" => 2 }) return @@coupon_pickup.pick.to_i end def self.new_user_coupon @@nu_coupon_pickup ||= Pickup.new({ "5" => 835, "10" => 150, "15" => 10, "20" => 5 }) return @@nu_coupon_pickup....
true
16a853f02e38daa5bdf6d4540a2c167c1b9a6530
Ruby
gsomoza/code-samples
/google/2010.Africa/Qualification/C.T9Spelling/main.rb
UTF-8
757
3.625
4
[]
no_license
#!/usr/bin/ruby $map = { 2 => ['a','b','c'], 3 => ['d','e','f'], 4 => ['g','h','i'], 5 => ['j','k','l'], 6 => ['m','n','o'], 7 => ['p','q','r','s'], 8 => ['t','u','v'], 9 => ['w','x','y','z'], } def t9(c) if c == ' ' return [0,1] else i = nil $map.each do |key,val| return [key,...
true
f2d3a75a2c0c528702b06a106a3eaa4e2207506c
Ruby
drbuys/jabbas_palace
/specs/question_spec.rb
UTF-8
589
2.90625
3
[]
no_license
require 'minitest/autorun' require('minitest/rg') require_relative('../question.rb') class TestQuestions < MiniTest::Test def setup @question1 = Question.new( {"In how many languages is C-3P0 fluent?" => [ "6 million", "16 million"]} ) end def test_question_has_question() assert_equal("In how many lang...
true
e2e400410db670d4f9a03ca26cc78b07fb9b44cd
Ruby
ebag22/ttt-7-valid-move-002
/lib/valid_move.rb
UTF-8
589
3.6875
4
[]
no_license
# code your #valid_move? method here def valid_move?(board, position) position = position.to_i if position.between?(1, 9) == false return false elsif position_taken?(board, position) == true return false else return true end end # re-define your #position_taken? method here, so that you can use ...
true
ac794d9d11fe6f8cfae6041c78b72b5ce4f6aeaf
Ruby
roussev/Ruby-Meta-Programming
/07_namespace.rb
UTF-8
584
3.671875
4
[]
no_license
p "Namespace illustrated with constants" module M class C X = 'constant' end C::X # => "constant" end M::C::X # => "constant" p "If you’re sitting deep inside the tree of constants" p "you can provide the absolute path to an outer constant by using a leading double colon as root" module M Y = 'another co...
true
e7f80fe163f9a659e9af42aebe70625d5973301b
Ruby
bteixeira1/phase-0-tracks
/ruby/secret_agent.rb
UTF-8
1,362
4.53125
5
[]
no_license
# encrypt # - Loop through the string # - Use .next! method on the letter def encrypt(string) for i in 0...string.length string[i] = string[i].next[0] end string end # print encrypt("string") # decrypt # - Assign a variable to alphabet # - Loop through the string # - get the index of each letter and sub...
true
d6274e0c5a361919ab7631915b1fd002b8c1cd08
Ruby
archan937/directiverecord
/lib/directive_record/query.rb
UTF-8
575
2.578125
3
[ "MIT" ]
permissive
require "directive_record/query/sql" require "directive_record/query/mysql" require "directive_record/query/big_query" module DirectiveRecord module Query def self.new(klass, connection = nil) class_for((connection || klass.connection).class.name.downcase).new(klass) end private def self.class...
true
4a2ec9e36e1d09ca97dfb144c337e0dad79c3009
Ruby
brentshermana/RubyTutorial
/class.rb
UTF-8
499
3.796875
4
[]
no_license
class Parent attr_accessor :a def initialize(_a) @a = _a #@ resolves a class instance variable end public def getA @a end protected def protectedMethod puts "protected method" end private def privateMethod put...
true
023892e1e9ebde07bb0699a4147bb198bc97a02b
Ruby
nhu313/Mastermind_Ruby
/lib/mastermind/console.rb
UTF-8
2,759
3.96875
4
[]
no_license
require 'mastermind/code_parser' require 'mastermind/result_converter' require 'mastermind/code' module Mastermind class Console def initialize(input=STDIN, output=STDOUT, input_parser=Mastermind::CodeParser.new) @input = input @output = output @input_parser = input_parser @result_conv...
true
e5e0deebfa9fc9d133ad0058e628848440a38ac9
Ruby
smook1980/AlgorithmsDataStructures
/week_3/in_class/lib/tree_traversal.rb
UTF-8
203
2.9375
3
[]
no_license
class TreeNode attr_accessor :value, :children def initialize(value) self.value = value self.children = [] end def depth_first_flat_list end def breadth_first_flat_list end end
true
a7ce562f394da30e90e1860da664c211917fa8ad
Ruby
lkdjiin/vim-loc
/autoload/loc.rb
UTF-8
221
2.546875
3
[ "MIT" ]
permissive
class Loc def initialize @buffer = VIM::Buffer.current end def execute total = (1..@buffer.length).reject do |index| @buffer[index] =~ /^\s*(#.*)?$/ end.length VIM::message(total) end end
true
1832679e7f872783ef425c0c031fa65b3f12c96d
Ruby
janat-t/sysprog-sig
/pty.rb
UTF-8
817
2.828125
3
[]
no_license
#!/usr/bin/env ruby require 'pty' sig2esc = { 'INT' => '^C', 'QUIT' => '^]', 'TSTP' => '^Z', } script = STDIN.readlines.map {|l| l.chomp } STDOUT.sync = true begin PTY.spawn(*ARGV) do |pin, pout, pid| pin.sync = true pout.sync = true Thread.new do sleep 0.5 script.each do |cmd| ...
true
14a3d99c6e91c8950bd4bcf68dac5894e8456554
Ruby
corinna-fab/hotel
/lib/frontdesk.rb
UTF-8
3,230
3.296875
3
[]
no_license
require 'date' require_relative 'date.rb' require_relative 'reservation.rb' module Hotel class FrontDesk attr_reader :all_reservations, :rooms def initialize @all_reservations = all_reservations || [] @rooms = [*1..20] end def assign_room(new_reservation) taken_rooms = [...
true
e5b63b09f06298b40db0a4cebb867f637e877602
Ruby
Henry577/programming-univbasics-4-crud-lab-online-web-prework
/lib/array_crud.rb
UTF-8
604
3.546875
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def create_an_empty_array [] end def create_an_array ["word1", "word2", "word3", "word4"] end def add_element_to_end_of_array(array, element) << "word5" end def add_element_to_start_of_array(array, element) .unshift end def remove_element_from_end_of_array(array) .pop end def remove_element_from_start_of...
true
c71a97f117c3b28330532447e45c0599a0a75762
Ruby
SauloSilva/doando.se
/spec/models/address_spec.rb
UTF-8
3,524
2.609375
3
[]
no_license
require 'spec_helper' describe Address do it 'Should have a valid address' do FactoryGirl.build(:address).should be_valid end it 'Lat should not be required' do FactoryGirl.build(:address, lat: nil).should be_valid end it 'Lng should not be required' do FactoryGirl.build(:address, lng: nil).sho...
true
1ddf537a767f9edce1f6c20a3a10148ea0329fbb
Ruby
jpeace/keystone
/spec/objects.rb
UTF-8
2,155
2.53125
3
[]
no_license
def asset_path "#{File.dirname(__FILE__)}/environment/assets" end module TestObjects module AssetTools class ReplaceQs include Keystone::AssetTool def should_run?(asset) asset.type == :boring end def transform(asset) asset.content.gsub(/[qQ]/, '*') end end ...
true
f350ea39f91e45afc005714138afb97a58ce41ac
Ruby
speartail/rget
/lib/rget/downloader.rb
UTF-8
3,165
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'fileutils' require 'ostruct' require 'open-uri' require 'pathname' require 'pp' require 'uri' module RGet # @abstract Subclass and override {#download} to implement a custom Downloader class Downloader DEFAULT_OPTIONS = { :quiet => false, :overwrite => false } attr_reader :url, :file, :options ...
true
529a6e4a57c454d686d269e7b1ed3fee7cb9d247
Ruby
serverless/examples
/aws-ruby-cron-with-dynamodb/src/common/services/create_meal_order_service.rb
UTF-8
527
2.609375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'date' require 'securerandom' require 'faker' require_relative '../adapters/dynamo_db_adapter' class CreateMealOrderService MealOrderSchema = Struct.new(:id, :dish_name, :created_at) def call order = build_order save(order) end def save(order) DynamoDBAdap...
true
398c15b4871b8a3c1931c597ab63c941b84e77d8
Ruby
magnars/Adventur-Compiler
/test/commands/test_add_deed.rb
UTF-8
1,013
2.546875
3
[]
no_license
require 'test/unit' require 'commands/add_deed' require 'room' class CommandsAddDeedTestCase < Test::Unit::TestCase def setup room = [':slem => An evil deed'].extend(Room) @evil_deed = AddDeed.parse?(room.current, room) room = [':snill => A good deed'].extend(Room) @good_deed = AddDeed.parse?(room.c...
true
5cc98cd0605eba80b555dda67192d6737b9d0f1b
Ruby
imsal/superblog
/app/models/application_record.rb
UTF-8
571
2.53125
3
[]
no_license
class ApplicationRecord < ActiveRecord::Base self.abstract_class = true # Category.first.all_posts_of_year_with_category(2018) def all_posts_of_year_with_category(year) posts.where(year: year) end # Category.first.all_posts_of_year_with_category(2018, 8) def all_posts_of_month_with_category(year, mont...
true
22a58189e618d99f417024315fbf1f9900be979d
Ruby
sullivant/euler
/ruby/24.rb
UTF-8
304
3.5
4
[]
no_license
require 'euler.rb' m = ARGV[0].to_i - 1 # Max p = ARGV[1].to_i # Range to permute str = "" range = (0..p) chars = range.to_a range.each do |n| f = (p-n).factorial #(9-0)! , (9-1)!... s = m/f.to_i # str += chars[s].to_s m = m % f chars.delete_at(s) chars = chars.compact end p str
true
a308709a3dca50f90da3efe3a6ee097688fd5f45
Ruby
Jhowden/chess
/lib/chess_piece.rb
UTF-8
599
3.28125
3
[]
no_license
class ChessPiece attr_reader :captured, :position, :board, :team, :possible_moves, :move_counter def initialize( file, rank, team, board ) @position = Position.new( file, rank ) @board = board @team = team @captured = false @possible_moves = [] @move_counter = 0 end def captured...
true
d508e03317a219d0ce4363752e65b62e3a8a40a5
Ruby
vizvamitra/patme
/lib/patme/pattern_matching.rb
UTF-8
846
2.578125
3
[ "MIT" ]
permissive
module Patme module PatternMatching def self.included(klass) klass.include(InstanceMethods) klass.extend(ClassMethods) end module ClassMethods def method_added(name) @patme_methods ||= {} @patme_methods[name] ||= Patme::Method.new(name) method_obj = self.instan...
true
431329311a05be3ff362007326dcab0ca2a3b6e0
Ruby
Kevine97/Programacion-RUBY
/Archivo/listar_app.rb
UTF-8
981
3.65625
4
[]
no_license
require_relative "./inicio.rb" require_relative "./lista.rb" class Listar_app def initialize @lista = Lista.new end def run puts "Bienvenido a nuestra lista de compra" loop do puts "a - Agregar un Registro" puts "v - Mostrar todos los Registros" puts "s - Salir" puts "_______...
true
a55f4f936cff61993971a7d4bc031e058a683620
Ruby
DrummerHead/galNum-galFly
/make.rb
UTF-8
1,290
2.84375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # Executes gulp, by default this compresses main.css and main.js puts %x[gulp] def compact_gal(which) css_min = File.read("temp/#{which}/main.css") js_min = File.read("temp/#{which}/main.js") html = File.read("src/#{which}/index.html") bookmarklet = File.read("src/#{which}/bookmarklet.js")...
true
eb876e4393805de80667835c36c69f42d01ffe82
Ruby
HideTheMess/academy
/w3d5/active_record_lite/lib/active_record_lite/sql_object.rb
UTF-8
1,696
2.78125
3
[]
no_license
require_relative './associatable' require_relative './db_connection' require_relative './mass_object' require_relative './searchable' class SQLObject < MassObject extend Searchable, Associatable def self.set_table_name(table_name) @table_name = table_name end def self.table_name @table_name end ...
true
ea8129b3c5aa531259132d04bd9ca1776006b760
Ruby
waynedelcorraljr/hurricane_cli_app
/lib/storm.rb
UTF-8
2,359
3.15625
3
[ "MIT" ]
permissive
require 'colorize' class Storm attr_accessor :name, :region, :details, :last_updated, :location, :movement, :wind_speed, :pressure, :url @@all = [] def initialize(storm_hash) @name = storm_hash[:name] @last_updated = storm_hash[:last_updated] @location = storm_hash[:location] ...
true
1177eab06d800d181f28afcba0a9fea86945649e
Ruby
Kouch-Sato/AtCoderProblems
/ABC/141/141B.rb
UTF-8
220
3.484375
3
[]
no_license
s = gets.split("") ans = "Yes" n = s.size n.times do |i| if i.odd? if s[i] == "R" ans = "No" break end end if i.even? if s[i] == "L" ans = "No" break end end end puts ans
true
ee9cb215569376c048a79aa3a4df49f8ea8a13cd
Ruby
juniormp/domain-event
/partner_application.rb
UTF-8
903
2.703125
3
[]
no_license
require_relative 'domain_events/publishing' require_relative 'rejected_partner_application' class PartnerApplication attr_accessor :rejected_at attr_reader :id, :name def initialize(id, name) @id, @name = id, name end def reject(event_publishing: DomainEvents::Publishing.instance) update(rejected_a...
true
994f6ccb6242c17eef99a4c21e3bb2693eb5036c
Ruby
vshl/exercism.io
/armstrong-numbers/armstrong_numbers.rb
UTF-8
366
3.3125
3
[]
no_license
=begin Write your code for the 'Armstrong Numbers' exercise in this file. Make the tests in `armstrong_numbers_test.rb` pass. To get started with TDD, see the `README.md` file in your `ruby/armstrong-numbers` directory. =end class ArmstrongNumbers def self.include?(number) n = number.digits.count number.digi...
true
5cc9eaf180a2cf8d281d89dfea717f5289e4addf
Ruby
eddsansome/clean-code-training
/ex5/ex5.rb
UTF-8
870
3
3
[]
no_license
# frozen_string_literal: true require 'test/unit' require 'ostruct' class UserNotifier def call(user, message, sender) sender.send(user.contact, message) end end class Sender def self.send(receiver, message) # do some coool stuff here "sending #{message} to #{receiver}" end end class EmailSender...
true
0327f1a71f1f7da04bdb3dadf9c233b9db7791ab
Ruby
nate-r-a/catan
/catan-api/app/models/game.rb
UTF-8
2,346
2.8125
3
[]
no_license
class Game < ApplicationRecord has_many :player_games, -> { order("position") }, inverse_of: :game accepts_nested_attributes_for :player_games has_many :players, through: :player_games NUMBER_TILES = [5,2,6,3,8,10,9,12,11,4,8,10,9,4,5,6,3,11].freeze RESOURCES = %w[wo sh wh br st] RESOURCE_NAMES = { wo:...
true
be8c8b7ba3ba5b657a18ddeb51943436e6b3da06
Ruby
gijolopez/night_writer
/test/encoder_test.rb
UTF-8
2,555
3.03125
3
[]
no_license
require "minitest/autorun" require "minitest/pride" require "./lib/encoder.rb" require "./lib/dictionary.rb" class EncoderTest < Minitest::Test def test_data_is_initialized file_contents = Encoder.new(Reader.new('test_reader_file.txt')) assert_instance_of Encoder, file_contents end def test_file_data...
true
51feb6bfac9f614522f18146ea5f1491d079f89f
Ruby
Rokkimies/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
1,190
4.28125
4
[]
no_license
#write your code here def translate str #transform to array words = str.split(" ") translated_words = "" puts "words to array: " + words.to_s #Check the word words.each {|word| puts "Word going to check: " + word #puts "Word after check" + check word translated_words += check word translate...
true
0148a0feb5b64c0c4e04ceb33aca8dce9c3b42ae
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/grade-school/5a04ca88c17345658c4b497256555b26.rb
UTF-8
222
2.984375
3
[]
no_license
class School def db @db ||= {} end def add(name, num) grade(num) << name end def grade(num) db[num] || db[num] = [] end def sort db.each_value { |n| n.sort! } Hash[db.sort] end end
true
98a2addbd21858ed93947d9542161ec34cdb08af
Ruby
mntjones/interview-cake
/merge-list.rb
UTF-8
2,842
4.1875
4
[]
no_license
# Interview Cake Practice Problem # In order to win the prize for most cookies sold, # my friend Alice and I are going to merge our Girl Scout # Cookies orders and enter as one unit. # Each order is represented by an "order id" (an integer). # We have our lists of orders sorted numerically already, in arrays. # W...
true
027f6bc433ab41d8d73b1ec590e19673fd568b92
Ruby
meruba/sisfa
/app/models/cuarto.rb
UTF-8
565
2.59375
3
[ "Apache-2.0" ]
permissive
# == Schema Information # # Table name: cuartos # # id :integer not null, primary key # nombre :string(255) # created_at :datetime # updated_at :datetime # class Cuarto < ActiveRecord::Base has_many :camas validates :nombre, :presence =>true validates_uniqueness_of :nombre, :case_sensitive ...
true
f124a93c4433529f3cb4c530e9e7578afcbe35e4
Ruby
timsheng/druid
/spec/druid/elements/unordered_list_spec.rb
UTF-8
1,058
2.5625
3
[]
no_license
require 'spec_helper' require 'druid/elements' describe Druid::Elements::UnOrderedList do let(:ul) { Druid::Elements::UnOrderedList.new(ul_element) } describe "interface" do let(:ul_element) { double('ul_element').as_null_object } let(:li_element) { double('li_element').as_null_object } it "should re...
true
2c3cdf80c1aeca99c15040207c2cb0192886ab1b
Ruby
sancopanco/rlox
/lib/lox/parser.rb
UTF-8
19,262
3.46875
3
[]
no_license
## Expression grammer # expression → assignment ; # assignment -> IDENTIFIER "=" assignment | equality | logical_or ; # logical_or -> logical_and ("or" logical_and)* ; # logical_and -> equality ("and" equality)* ; # equality → comparison ( ( "!=" | "==" ) comparison )* ; # comparison → addition ( ( ">"...
true
52a35e1c55ce48020fb0f5eda749964180cd6e71
Ruby
DouglasAllen/code-Programming_Ruby_3rd_ed
/Part_IV--Ruby_Library_Reference/ch27_Built-in_Classes_and_Modules/Alphabetical_Listing/ARGF/ARGF_class_methods/ARGF.rb
UTF-8
2,831
3.421875
3
[]
no_license
# ARGF.rb text = <<ET = ARGF < Object ------------------------------------------------------------------------------ = Includes: Enumerable (from ~/.ri) (from ~/.ri) ------------------------------------------------------------------------------ ARGF is a stream designed for use in scripts that process...
true
dd3c2e63319996b334dbfbaab7554324ae048c57
Ruby
sierraflynn/A_Bakers_Dozen
/app/models/comment.rb
UTF-8
583
2.71875
3
[]
no_license
#=header class Comment < ActiveRecord::Base #relationships belongs_to :user belongs_to :recipe #validations validates :content, presence: true, length: { maximum: 300 } validates :rating, presence: true, :numericality => {:greater_than => 0, :less_than => 5} validates :user_id, presence: true validate...
true
835c7e5f4fe71c570511a3c43eaa22e375c1b747
Ruby
TheLevelUp/levelup-sdk-ruby
/lib/levelup/endpoints/permissions_requests.rb
UTF-8
777
2.515625
3
[ "MIT" ]
permissive
module Levelup module Endpoints # The endpoint holding all functions related to managing permissions requests. class PermissionsRequests < Base def initialize(app_access_token) self.app_access_token = app_access_token end # Requests a set of permissions from the specified user. ...
true
345bd837b0d04a63fe35585abdcd0caa34fcfebc
Ruby
Amnesthesia/Project-Rheya
/speak.rb
UTF-8
17,392
2.765625
3
[]
no_license
require "twitter" require "sqlite3" require "arrayfields" require "pickup" require "./see.rb" class Mouth attr_accessor :debug, :db, :question_starters, :previously_said, :emotions, :last_poll_id, :poll_db debug = true def initialize(*args) @db = SQLite3::Database.new("dictionary.db") @db.results_as_...
true
1b7b02ef26b8d78ba296468e45f495b78c9a4eea
Ruby
hectorbus/ledger
/ledger.rb
UTF-8
2,038
3.046875
3
[]
no_license
require 'thor' require_relative 'commands/balance' require_relative 'commands/register' require_relative 'commands/print' class Ledger < Thor CONFIG_FILE = 'config.ledger'.freeze REGISTER_ALIAS = 'reg'.freeze BALANCE_ALIAS = 'bal'.freeze DOLLAR_SIGN = '$'.freeze class_option :file, type: :string, ali...
true