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
121b0c57b95f1321bc5cc56cdbb0087d463841b3
Ruby
catks/verto
/lib/verto/dsl/file.rb
UTF-8
956
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Verto module DSL class File def initialize(filename, path: Verto.config.project.path) @filename = filename @path = Pathname.new(path) end def replace(to_match, to_replace) content = file.read file.open('w') do |f| ...
true
b96dd2d5b8ad0aa1ef29eb6e6c3911695ba31473
Ruby
louispinot/promo-2-challenges
/01-Ruby/06-Parsing/02-Numbers-and-Letters/spec/longest_word_spec.rb
UTF-8
2,216
3
3
[]
no_license
# Encoding: utf-8 require "spec_helper" require "longest_word" describe "#generate_grid" do let(:grid) { generate_grid(9) } it "should generate grid of required size" do grid.size.must_equal 9 end it "should generate random grid" do grid.wont_equal generate_grid(9) end it "should allow for repe...
true
92e1eb6e7c65ba702bb30695f57fb2520423a7a8
Ruby
marina-h/LaunchSchool
/course_120/lesson_2/03_lecture_inheritance.rb
UTF-8
2,406
4.40625
4
[]
no_license
# 1. Given this class: # class Dog # def speak # 'bark!' # end # # def swim # 'swimming!' # end # end # # teddy = Dog.new # puts teddy.speak # => "bark!" # puts teddy.swim # => "swimming!" # One problem is that we need to keep track of different breeds of dogs, since # they have sli...
true
2bf65e00920f5f130eb8ae07dea357c4ea2a3487
Ruby
jkgit/sample-ror-application
/app/models/catalog.rb
UTF-8
3,072
2.828125
3
[]
no_license
class Catalog < ActiveRecord::Base attr_accessible :name has_many :items # return an array of item objects corresponding to a batch of items related to this catalog def get_batch_of_items (page = nil, size=nil) # set reasonable defaults for page and convert to an int page=page.nil? ? 1 : page.to_i ...
true
4275c3256f4338b4ffba2c53c45d5bff182b1301
Ruby
SProjects/ruby-friday
/symbols.rb
UTF-8
946
4.4375
4
[]
no_license
=begin Symbols are like literal constants only that they don't hold a value or object BUT their name is important. They are written with a preceding full colon. USES: 1.used commonly in ruby as parameters to functions e.g attr_accessor :firstname :lastname or attr_accessor(:firstname :lastname) 2.used as keys in hash...
true
1cb06ca54c3da1aafcd637961030947bf3dc7509
Ruby
samg/timetrap
/lib/timetrap/formatters/csv.rb
UTF-8
514
2.96875
3
[ "MIT" ]
permissive
module Timetrap module Formatters class Csv attr_reader :output def initialize entries @output = entries.inject("start,end,note,sheet\n") do |out, e| next(out) unless e.end out << %|"#{e.start.strftime(time_format)}","#{e.end.strftime(time_format)}","#{escape(e.note)}","#{...
true
7c49dcc1200716be3302667072b934d44a2927e1
Ruby
jiripospisil/rock_config
/lib/rock_config/config.rb
UTF-8
508
2.875
3
[ "MIT" ]
permissive
module RockConfig class Config def initialize(hash) @hash = hash end def [](key) fetch(key) end def method_missing(name, *args, &block) fetch(name.to_s) end def raw @hash.dup end private def fetch(key, default = nil) value = @hash[key.to_s] ...
true
d2a61b2adfd9c304ee3ab73759866afc7f9aea9d
Ruby
Machi427/ruby_scripting
/sample_scripts/lecture06/randseek.rb
UTF-8
480
3.3125
3
[]
no_license
#!/usr/bin/env ruby # -*- coding: utf-8 -*- thisfile = "randseek.rb" # このファイルの名前 sz = File.size(thisfile) open(thisfile, "r") do |file| while true while line = file.gets print line end puts "読み終わりました。[Enter]でもう一度。やめたい場合は C-c" gets file.seek(rand(sz)) # 乱数でファイルポインタを移動 prin...
true
fbd469533131a84e6e73c395ea8ffc996d308627
Ruby
almendragr/introduccion_ruby
/ventas_faker/pedido.rb
UTF-8
1,410
3.625
4
[]
no_license
require 'faker' class Pedido attr_reader :codigo # attr_reader :total # la suma total del pedido attr_accessor :productos # almacenar una lista/array de productos attr_reader :fecha_creacion # fecha de hoy attr_accessor :fecha_entrega # sumar a la fecha...
true
042462d04b3ed4b41fe06b5693daa2384902c38f
Ruby
powersjcb/notes
/w1d5/TicTacToeAI/skeleton/lib/tic_tac_toe_node.rb
UTF-8
1,184
3.515625
4
[]
no_license
require_relative 'tic_tac_toe' class TicTacToeNode def initialize(board, next_mover_mark, prev_move_pos = nil) @board = board @next_mover_mark = next_mover_mark @prev_move_pos = prev_move_pos @parent = nil end def losing_node?(evaluator) if @board.won? @board.winner != evaluator el...
true
38d76b4cbfb71c56ebe3374f1fe461fcd31f5d6a
Ruby
BenDunjay/FizzBuzz
/spec/fizzbuzz_spec.rb
UTF-8
1,138
3.375
3
[]
no_license
require "./lib/fizzbuzz.rb" RSpec.describe FizzBuzz do let(:numbers) { described_class.new(15) } context "initializing" do it "creates a new instance" do expect(numbers).to be_instance_of(FizzBuzz) end it " works with no argument" do expect(FizzBuzz).to respond_to(:new).with(1).arguments ...
true
2b6d8436e2123fe6bfa71b1bc677d6d0ac3e40c8
Ruby
godfat/struct_trans
/lib/struct_trans/hash.rb
UTF-8
306
2.515625
3
[ "Apache-2.0" ]
permissive
module StructTrans module_function def trans_hash struct, *schemas transform(:hash, struct, schemas) end def construct_hash {} end def write_hash hash, key, value raise KeyTaken.new("Key already taken: #{key.inspect}") if hash.key?(key) hash[key] = value end end
true
80ca474a0f9afe327bc42c2fea7153c1d35c598b
Ruby
SHINOZAKI-RYOSUKE/Re-view_etc...
/test.rb
UTF-8
4,447
3.640625
4
[]
no_license
#puts 'Hello, World!' #puts 5 + 3 #puts "5 + 3" #puts "5" + "3" #puts "I" + "am" + "Sam" #puts "Samの年齢は" + 27.to_s + "です" #puts 100 + "200".to_i #puts "私の名前は" + "メンター太郎" + "です。" + "年齢は" + 24.to_s + "歳です。" #puts "WEBCAMP".length #puts "webcamp".upcase #webcamp = "プログラミング学習" #puts webcamp #webcamp = "オンラインプログラミン...
true
05cd42570d5f8864a1241d1da7950e56106b679a
Ruby
weirdpercent/oversetter
/lib/oversetter/hablaa/getlangs.rb
UTF-8
954
2.640625
3
[ "MIT" ]
permissive
# coding: utf-8 %w{httpi multi_json multi_xml rainbow}.map { |lib| require lib } module Oversetter class Hablaa # Fetches supported languages from Hablaa. class Getlangs # @param search [String] The word or phrase to search for. # @param params [Hash] The search parameters to use. def get_lang(search,...
true
960a11b357b26916a9b3d2030dbcececb01d5df7
Ruby
prongstudios/tutorial
/lib/drm.rb
UTF-8
348
2.53125
3
[ "MIT" ]
permissive
require 'rest-client' require 'json' class Drm def check begin @response = RestClient.get 'http://tutorialthegame.com/pages/drm.json', {:accept => :json} return JSON.parse(@response)["status"] rescue Exception => e return 'error checking drm: ' + e.message end end def success return JSON.parse(@res...
true
847db69337ababc8c6ee91f46a4b26473b4a7cb0
Ruby
cherylsiew/ownpairbnb
/app/models/booking.rb
UTF-8
423
2.515625
3
[]
no_license
class Booking < ApplicationRecord belongs_to :user belongs_to :listing validate :overlap? def overlap? if self.listing.bookings.where("(start_date BETWEEN ? AND ?) OR (end_date BETWEEN ? AND ?)", self.start_date, self.end_date, self.start_date, self.end_date).count > 0 errors.add(:start_date, "is not ...
true
e250ba33fbbddd2a2fcc78b339ded33297bb8bef
Ruby
activeadmin/arbre
/lib/arbre/element/builder_methods.rb
UTF-8
2,227
2.96875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Arbre class Element module BuilderMethods def self.included(klass) klass.extend ClassMethods end module ClassMethods def builder_method(method_name) BuilderMethods.class_eval <<-EOF, __FILE__, __LINE__ def #{method_na...
true
2db5d07dc8a1411acefe43844f373c3e5ae12fdb
Ruby
ivanjankovic/e-appacademy
/Ruby/*05_sudoku_game/board.rb
UTF-8
1,879
3.53125
4
[]
no_license
require_relative 'tile' # require 'colorize' class Board attr_reader :grid def initialize @grid = Array.new(9) { Array.new(9) } end def from_file File.readlines('./puzzles/sudoku1.txt') # File.readlines('./puzzles/sudoku1_almost.txt') end def populate (0...9).each do |row| (0......
true
4d4bedea2e91ab93970f0c080e263571e64b527d
Ruby
cyrilpestel/searchzt
/src/ZTSearchProvider.rb
UTF-8
1,214
2.6875
3
[]
no_license
require 'rubygems' require 'nokogiri' require 'open-uri' require "cgi" require_relative 'Util' class ZTSearchProvider def search(term, neededQuality) termEncoded = CGI::escape(term) url = "http://www.zone-telechargement.com/films-gratuit.html?q=#{termEncoded}&minrating=0&tab=all&orderby_by=popular&orderby_order...
true
b0dc429f9e5428f0e63bd33fc45d8853c24d0ca6
Ruby
lime1024/rubybook
/chapter_07/7-4-6.rb
UTF-8
382
3.890625
4
[]
no_license
# 品物の値段を返す price メソッドをつくる # キーワード引数で item を渡し item が"コーヒー"のときは 300 を # "カフェラテ"のときは 400 を戻り値として返す def price(item:) if item == 'コーヒー' 300 elsif item == 'カフェラテ' 400 end end puts price(item: 'コーヒー') puts price(item: 'カフェラテ')
true
24c1776a7d2e780e3182d986044944443c275710
Ruby
ibariens/tweakers
/question3.rb
UTF-8
430
3.515625
4
[]
no_license
x1, y1, z1 = [30,50,90] x2, y2, z2 = [4096, 65536,9] dx, dy, dz = [(x2-x1),(y2-y1),(z2-z1)] distance_two_points = Math.sqrt((x1-x2)**2+(y1-y2)**2+(z1-z2)**2) distance_travelled = 20*60*25 percentage_travelled = distance_travelled / distance_two_points puts x1 + dx*percentage_travelled puts y1 + dy*percentage_tra...
true
8d6ab73b9747a7b827f5697ad492a844a404f68e
Ruby
bmorrall/fun_with_json_api
/lib/fun_with_json_api/attributes/boolean_attribute.rb
UTF-8
793
2.828125
3
[ "MIT" ]
permissive
module FunWithJsonApi module Attributes # Ensures a value is either Boolean.TRUE, Boolean.FALSE or nil # Raises an argument error otherwise class BooleanAttribute < Attribute def decode(value) return nil if value.nil? return value if value.is_a?(TrueClass) || value.is_a?(FalseClass) ...
true
e72d6580814c994904bdffe612de4f90943598a8
Ruby
bolshakov/fear
/lib/fear/partial_function/guard/and.rb
UTF-8
889
2.921875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Fear module PartialFunction class Guard # @api private class And < Guard # @param c1 [Fear::PartialFunction::Guard] # @param c2 [Fear::PartialFunction::Guard] def initialize(c1, c2) @c1 = c1 @c2 = c2 end ...
true
36e8c84cf0960dfc44d428be308f2312a1d5a036
Ruby
kaledoux/ruby_small_problems
/Medium2/matching_parentheses.rb
UTF-8
3,019
4.75
5
[]
no_license
# Write a method that takes a string as argument, and returns true if all # parentheses in the string are properly balanced, false otherwise. # To be properly balanced, parentheses must occur in matching '(' and ')' pairs. # # Examples: # # balanced?('What (is) this?') == true # balanced?('What is) this?') == false # b...
true
86c7fcea10ec1042ac30d9e0b5826883252e55be
Ruby
outstand/shipitron
/lib/shipitron/docker_image.rb
UTF-8
541
2.53125
3
[ "Apache-2.0" ]
permissive
require 'shipitron' module Shipitron class DockerImage < Hashie::Dash property :registry property :name property :tag def name_with_tag(tag_override = nil) tag_str = [tag_override, tag, ''].find {|str| !str.nil? } tag_str = tag_str.to_s if !tag_str.empty? && !tag_str.start_with?('...
true
ac596f3758af8f24b605945d0242f3dfba5687e1
Ruby
Sarvotam/some_solution
/Problem1.rb
UTF-8
329
4.5625
5
[]
no_license
# Problem 1: # Given three numbers X, Y & Z. write a function/method that finds the greatest among the numbers. def greatest puts "Enter value of X" x = gets.chomp puts "Enter value of y" y = gets.chomp puts "Enter value of z" z = gets.chomp max_num = [x,y,z].max puts "The greates number is #{max_num}" end ...
true
6c8dea08bc0fc91d0a2d9974028525a824de0ac5
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/b23fe40bcee242c886e1a30e1f4fa938.rb
UTF-8
370
3.578125
4
[]
no_license
class Bob def hey message empty = ->(message) { message == '' } shouting = ->(message) { message == message.upcase } question = ->(message) { message.end_with?('?') } case message.to_s when empty 'Fine. Be that way!' when shouting 'Woah, chill out!' when question 'Sure...
true
d0a77892563dd8b6bd6d06ae223058479c364844
Ruby
anastasiiatulentseva/tulenmenu
/test/models/dish_day_test.rb
UTF-8
1,022
2.71875
3
[]
no_license
require 'test_helper' class DishDayTest < ActiveSupport::TestCase def setup @dish = dishes(:borsch) @dish_day = dish_days(:one) @dish_day_past = dish_days(:two) end test "should be valid" do assert @dish_day.valid? end test "dish id should be present" do @dish_day.dish_id = nil ...
true
ea0f1245291f40113e6fdf70c46c42eedb583eb5
Ruby
motaHack/project100knock
/projectEuler/025.rb
UTF-8
158
2.859375
3
[]
no_license
start_time = Time.now f1 = 0 f2 = 1 n = 0 while (f1.to_s).length < 1000 do f3 = f1 + f2 f1 = f2 f2 = f3 n += 1 end p n puts(Time.now - start_time)
true
1989762b8d639ef4546dfe7ec3d0116499c9ddde
Ruby
okamiarata/okamiarata
/lib/api_url_generator.rb
UTF-8
1,493
2.59375
3
[ "MIT" ]
permissive
require "api_url_generator/version" module APIURLGenerator @@url def self.url(x) @@url = x end def self.get_url @@url end def self.dectect_polymorphic(object) object.instance_variables.each do |variable| if variable.to_s[-9..-1] == "able_type" return { name: {variable...
true
a929dc24330d52deff6303913e81cbb821c54c43
Ruby
honorwoolong/launch_school
/RB100/Ruby_Basics_User_Input.rb
UTF-8
6,921
4.15625
4
[]
no_license
#Repeat after me puts ">> Type anything you want:" answer = gets.chomp puts answer #Your Age in Months puts ">> What is your age in years?" answer = gets.chomp months = answer.to_i * 12 puts "You are #{months} months old." #Print Something (Part 1) puts ">> Do you want me to print something? (y/n)" answer = gets.chom...
true
823969792672075b911ce27069c7ac8589514b56
Ruby
lmilekic/bluejadetwitter
/seeds.rb
UTF-8
1,137
3.0625
3
[]
no_license
require 'sinatra' require 'sinatra/activerecord' require './config/environments' require 'faker' require './app' #100 users # 10 tweets each # each follows 10 people puts "This is the seed file!!!" test_users = Array.new (0..99).each do #create user user = User.create(:username => Faker::Internet.user_name, ...
true
3e719d032eda4341db98ade39c46826bacfeb39f
Ruby
GreenTer/My-knowledge
/L [11-20]/L15.1.0.rb
WINDOWS-1251
1,631
3.546875
4
[]
no_license
# encoding: cp866 # 3 ( ) class Albom attr_accessor :name, :songs def initialize name @name = name @songs = [] end def add_song song @songs << song end end class Song attr_accessor :name, :durations def initialize name @name = name @durations = [] # @duration = duration s...
true
11765d4bfc2c31f07312991bbcf17b54767865b7
Ruby
tamu222i/ruby01
/tech-book/5/5-252.rb
UTF-8
141
3.390625
3
[]
no_license
# maxメソッドとmax_byメソッド (1..10).map{|v|v % 5 + v} (1..10).max{|a,b|(a % 5 + a) <=> (b %5 + b)} (1..10).max_by{|v|v % 5 + v}
true
f78be0b7c3a6372dbe9d12f47446b4095d88c149
Ruby
KaoruDev/ruby-mud
/spec/enemy_characters/dragon/actions/basic_attack_spec.rb
UTF-8
555
2.515625
3
[]
no_license
require_relative "../../../spec_helper" module EnemyCharacters class Dragon module Actions RSpec.describe BasicAttack do let(:dummy) { DummyCharacter.new.generate_attributes } describe ".run_against" do it "will deal a range of damage to target" do prev_hp = dummy.hp ...
true
c8148544a61f30b292fbca8bb36dab7918524277
Ruby
moveson/set-card-game
/lib/card.rb
UTF-8
972
3.78125
4
[ "MIT" ]
permissive
class Card COLORS = %w[R G B] NUMBERS = %w[1 2 3] SHADINGS = %w[E H F] SHAPES = %w[S O D] def initialize(color, number, shading, shape) @color = color # R, G, B @number = number # 1, 2, 3 @shading = shading # E, H, F @shape = shape # S, O, D validate_setup end def to_s "#{color}#...
true
6cee52a9fdc892fc5bbf34fdc74968a045ddc8d4
Ruby
liaa2/wdi30-homework
/sarita_nair/Week4/Thursday/main.rb
UTF-8
1,485
2.671875
3
[]
no_license
require 'sinatra' require 'sinatra/reloader' require 'sqlite3' require 'pry' get '/' do erb:home end get '/animals' do sql_stmt = "select * from animal" @results = query_db sql_stmt # binding.pry erb:animal_list end get '/animals/new' do erb :animal_new end get '/animals/:id' do @results = query_db "SEL...
true
6e196f0f7017cbe58daa7647e4c52e9634f71194
Ruby
todd-fritz/secure-data-service
/tools/odin/lib/Shared/date_utility.rb
UTF-8
8,893
3.1875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
=begin Copyright 2012-2013 inBloom, Inc. and its affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
true
6592cec9af88e32c7637e3159e3ee04e97065c43
Ruby
lawrenae/sportsgamr
/lib/resultscalculator.rb
UTF-8
624
3.015625
3
[]
no_license
class ResultsCalculator # attr_accessor :description, :estimate def self.calculate_moneyline_winnings line, bet, win line_as_integer = line.to_i if line_as_integer > 0 then percentage = line/100.0 return (bet*percentage).to_i else return (bet/line.abs.to_f...
true
6c54d9b0ea1c75c023e6e3521de24be42ce27093
Ruby
librarySI2UNAL/BookShare_BackEnd
/app/daos/users_dao.rb
UTF-8
701
2.78125
3
[]
no_license
class UsersDAO def self.validate_email( email ) User.exists_user_with_email( email ) end def self.create_user( user_h ) latitude = user_h[:latitude] longitude = user_h[:longitude] user_h[:city] = City.load_city_by_position( latitude, longitude ) user_h[:interests] = Interest.load_interests_by_ids( user_h...
true
73f506153ce7326de2faf9368141bed4c1cbebbd
Ruby
vishB/vehicle_factory
/spec/models/vehicle_spec.rb
UTF-8
1,197
2.53125
3
[]
no_license
require 'spec_helper' describe Vehicle do it "should get created with proper values" do FactoryGirl.build(:vehicle).should be_valid end end describe Vehicle do it "Should not be valid without an identifier" do vehicle = FactoryGirl.build(:vehicle, v_identifier:nil) vehicle.should_not be_valid end ...
true
aa07d39d9d810b8b6a6466d6a82eaab2a268cf68
Ruby
hdeploy/hdeploy
/api/lib/hdeploy/api.rb
UTF-8
13,109
2.609375
3
[]
no_license
require 'sinatra/base' require 'json' require 'hdeploy/conf' require 'hdeploy/database' require 'hdeploy/policy' require 'pry' #require 'hdeploy/policy' module HDeploy class API < Sinatra::Base def initialize super @conf = HDeploy::Conf.instance @db = HDeploy::Database.factory # Decor...
true
5b4a2daf656815812c87a61c7b85949a5379f8a7
Ruby
livash/learn_ruby
/10_timer/timer.rb
UTF-8
744
3.625
4
[]
no_license
######################## # @author Olena Ivashyna # @date April 14, 2013 ####################### class Timer def initialize @seconds = 0 end def seconds=(seconds) @seconds = seconds.to_i end def seconds @seconds end def time_string hours = 0 min = 0 seconds = @seconds ...
true
159452871d6eaab55eeabcae02cfcef0bf52302c
Ruby
Owlyes/codewars
/q02_6kyu.rb
UTF-8
710
3.734375
4
[]
no_license
# Your order, please def order(words) words_array = [] words_order = [] ws = 0; pre_i = 0 words.size.times do |i| if words[i] == " " words_array[ws] = words[pre_i .. (i - 1)] pre_i = i + 1; ws += 1 elsif i == words.size - 1 words_array[ws] = words[pre_i .. i] else end if (...
true
7f15854eadb7ef70319bdcd5ac29abcf687b246f
Ruby
JonathanYiv/project-euler
/problem-two.rb
UTF-8
185
3.5
4
[]
no_license
sum = 0; a = 1; b = 2; while a < 4000000 and b < 4000000 if a % 2 == 0 sum = sum + a; end if b % 2 == 0 sum = sum + b; end a = a + b; b = a + b; end puts sum
true
364605b903fce05e362fe87124cb0ad4c0ded67a
Ruby
tangod0wn/rubyexcercises
/excersize.rb
UTF-8
2,553
3.734375
4
[]
no_license
class Customer def initialize(customer) @customer = customer end def print_customer_name puts @customer["first_name"] + " " + @customer["surname"] end def print_balance puts "Your balance is " + @balance["balance"] end end puts "Home", "1. Add customer", "2. Remove customer", "3.Edit customer",...
true
11e7be444b36af1d27bf847dadf3bab7228f6438
Ruby
dimasumskoy/ruby
/part_2/task_3.rb
UTF-8
167
2.984375
3
[]
no_license
# Заполнить массив числами фибоначчи до 100 array = [0, 1] while (count = array[-1] + array[-2]) < 100 array << count end p array
true
700948765dcd5613307f18102e994512973bc077
Ruby
raywu/eulers
/problem1.rb
UTF-8
994
4.59375
5
[]
no_license
#Problem 1 #If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. #Use inject method on arrays a = (0...1000).to_a #array of 0 to 999 #first, create an array of the satisfying element...
true
d805df3a1b7222007fcd54248fa310b9e669680d
Ruby
SE-Seedling/hipster_food
/test/event_test.rb
UTF-8
4,269
3.1875
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require './lib/item' require './lib/food_truck' require './lib/event' class EventTest < Minitest::Test def test_it_exists_and_has_readable_attributes event = Event.new("South Pearl Street Farmers Market") assert_instance_of Event, event assert_equal "S...
true
c404067d0cae2e20ad4a214c57d434d2f7adee98
Ruby
brendanronan/textrazor-ruby
/lib/text_razor/topic.rb
UTF-8
1,369
2.65625
3
[ "MIT" ]
permissive
module TextRazor # * Represents a single abstract topic extracted from the input text. # Requires the "topics" extractor to be added to the TextRazor request. class Topic < TextRazorObject attr_accessor :_topic_json attr_accessor :link_index self.descr = %w(id label score wikipedia_link) def i...
true
670c84573a599a481b6dfe6af784e3f2d2a4f169
Ruby
wpliao1989/debugging_like_a_pro
/ruby/8_find_where_object_is_mutated.rb
UTF-8
383
3.53125
4
[]
no_license
##################################################################### # An object is being mutated, but I don’t know where ##################################################################### def level_1 arg = 'hello' # arg.freeze level_2 arg end def level_2(arg) arg.replace('world') level_3 arg end def...
true
aabbe0ef0b9c073346195d40b9f05bac11bcb1e4
Ruby
Kaamio/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
2,290
3.359375
3
[]
no_license
#write your code here # Rule 1: If a word begins with a vowel sound, add an "ay" sound to the end of the word. # # Rule 2: If a word begins with a consonant sound, move it to the end of the word, and then add an "ay" sound to the end of the word. =begin def translate string sanat = string.split #[kapina aapinen m...
true
c99c7cd3b287582ffdcd1b09245793654c111f55
Ruby
toriejw/headcount
/test/headcount_analyst_test.rb
UTF-8
1,673
2.578125
3
[]
no_license
require_relative '../lib/headcount_analyst' class HeadcountAnalystTest < Minitest::Test attr_reader :ha def setup directory = File.expand_path 'fixtures', __dir__ dr = DistrictRepository.new(DataParser.new(directory)) @ha = HeadcountAnalyst.new(dr) end def test_initializes_with_a_repo assert h...
true
5a5df0d56b005339b74bd4afef2584f910ac9bda
Ruby
UnknownBlack/god_test
/simple.rb
UTF-8
68
2.640625
3
[]
no_license
data = '' loop do echo 'Hello' 100000.times { data << 'x' } end
true
ea24e1e5451c74d43e36bd4f65c900904a2ed7ae
Ruby
DanDaMan23/eCommerceSportsCards
/db/seeds.rb
UTF-8
1,362
2.609375
3
[]
no_license
require 'rest-client' Card.delete_all Player.delete_all Team.delete_all def create_players(number_of_players) number_of_players.times do player = Faker::Sports::Basketball.unique.player Player.create(name: player) end end def create_teams team_url = "https://www.balldontlie.io/api/v1/teams" response ...
true
5b65f3e2816f2d01db3c29ec66dd2a7e831867c2
Ruby
sam-david/algorithms
/challenges/leet-code/237-delete-node-in-linked-list.rb
UTF-8
678
4.375
4
[]
no_license
# https://leetcode.com/problems/delete-node-in-a-linked-list/ # Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. # Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after call...
true
2b2ce7c5ef894c0e6b72077ffc7ea149dd829fe9
Ruby
joaomosm/adventofcode
/2021/7/7_part_one.rb
UTF-8
666
3.515625
4
[]
no_license
require './../module_helpers.rb' class Day07PartOne include Helpers class << self def run new.run end end def initialize @numbers = read_input_chomp('7_input.txt') .map { |number| number.split(',') } .flatten .map(&:to_i) @min_distance = nil end def run max_i...
true
4cbcd83848c61a4501e3e742e45748cf784f2ac1
Ruby
pipivybin/ruby-collaborating-objects-lab-online-web-pt-021119
/lib/artist.rb
UTF-8
391
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Artist attr_accessor :name, :songs @@all = [] def initialize(name) @name = name @songs = [] save end def self.all @@all end def add_song(name) @songs << name end def save @@all << self end def self.find_or_create_by_name(input_name) self.all.find {|x| x.name == (input_name) } || self.new(inpu...
true
94153aa9b8ad48255c401dbf4bfd36cd30cb40d8
Ruby
rails/rails
/activesupport/test/json/decoding_test.rb
UTF-8
5,941
2.53125
3
[ "MIT", "Ruby" ]
permissive
# frozen_string_literal: true require_relative "../abstract_unit" require "active_support/json" require "active_support/time" require_relative "../time_zone_test_helpers" class TestJSONDecoding < ActiveSupport::TestCase include TimeZoneTestHelpers class Foo def self.json_create(object) "Foo" end ...
true
47efd0cfdb178d2afc7e6d80fcb788fb4e2ac429
Ruby
DamienNeuman/Chess
/chess/display.rb
UTF-8
805
3
3
[]
no_license
require "colorize" require_relative "board.rb" require_relative "cursor.rb" require "byebug" class Display attr_reader :board, :cursor def initialize(board) @cursor = Cursor.new([0,0],board) @board = board end def render() #debugger board.grid.each do |row| r = [] row.each_index do ...
true
1e25eeb5a522128a13f6199f22ef7240b5dc1953
Ruby
orocos-toolchain/utilrb
/lib/utilrb/configsearch/configuration_finder.rb
UTF-8
2,841
2.8125
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Utilrb # Find configuration files within the pathes given # by ROCK_CONFIG_PATH environment variable # class ConfigurationFinder # Find a file by searching through paths defined by an environment variable # and a given package directory. Package name is appended to all pathes fo...
true
41a4c6ee3a05b45a7c913a69771260fb175957fe
Ruby
shaoevans/aA-Classwork
/W4D4/tdd_project/lib/tdd.rb
UTF-8
1,215
3.5
4
[]
no_license
class Array def my_uniq results = [] self.each { |ele| results << ele if !results.include?(ele) } results end def two_sum pairs = [] (0...self.length).each do |i| (i+1...self.length).each do |j| pairs << [i,j] if self[i] + self[j] == 0 end end pairs end end ...
true
c9cc81f9a091e6f6dd566fb53df85698c12e7499
Ruby
cyx/cyrildavid.com
/lib/project.rb
UTF-8
243
2.5625
3
[]
no_license
class Project attr :title attr :description attr :url def initialize(atts) @title = atts[:title] @description = atts[:description] @url = atts[:url] end def self.all DB.projects.map { |atts| new(atts) } end end
true
a8781468edff20d43ae42e37f06cd3630fe58a8d
Ruby
bomberstudios/rack-footnotes
/lib/rack/footnotes.rb
UTF-8
1,018
2.59375
3
[]
no_license
require "rack" class Rack::FootNotes VERSION = "0.0.4" def initialize(app, options = {}, &block) puts("Using rack-footnotes " + VERSION) @app = app @options = { :notes_path => 'notes', :css => "position: fixed; bottom: 0; left: 0; width: 100%; padding: 1em; background-color: rgba(245,242...
true
cb1408fba23f36738390ad67581e426aec00b08a
Ruby
unindented/unindented-rails
/app/decorators/partial_date_decorator.rb
UTF-8
480
2.53125
3
[ "MIT" ]
permissive
class PartialDateDecorator < ModelDecorator delegate_all def localize array = to_a format = [:year, :month, :day][array.length - 1] l(Date.new(*array), format: format) end def route convert_to_route(to_a) end def parent_route convert_to_route(to_a[0...-1]) end private def con...
true
55dce64fe3c5b718d251906a747e8a182482d3d0
Ruby
digital-york/arch1
/lib/tasks/concepts.rake
UTF-8
4,242
2.6875
3
[]
no_license
namespace :concepts do require 'csv' desc "TODO" task load_subjects: :environment do puts 'Creating the Concept Scheme' begin #@scheme = ConceptScheme.find('cj82k759n') @scheme = ConceptScheme.new @scheme.preflabel = "Borthwick Institute for Archives Subject Headings for the Archbish...
true
f8e5dda9328fea97c0d656d88332005625781398
Ruby
uzairali19/linter-ruby
/spec/linter_spec.rb
UTF-8
6,285
3.0625
3
[]
no_license
require 'linter' # rubocop:disable Layout/LineLength RSpec.describe 'Linter Check' do subject(:lint) { Linter.new('../test.rb') } describe 'Empty line' do context 'If line is empty' do it 'Returns Error' do empty_line_test = lint.empty_line(' ', 1) expect(empty_line_test).to eq(["\e[0;3...
true
9c29bb6e782bbc718eba88075f2bd0d3435f0adb
Ruby
Erikzaksf/contacts-sinatra
/lib/address.rb
UTF-8
427
3.09375
3
[ "MIT" ]
permissive
class Address def initialize(attributes) @street = attributes.fetch(:street).to_s @city = attributes.fetch(:city).to_s @state = attributes.fetch(:state).to_s @zip = attributes.fetch(:zip).to_s end def full_address full_address = @street full_address += ", " full_address += @city f...
true
701e9ada9143031a6a04b39f521d3f99cd398cc2
Ruby
dinosaurjoe/Zentangle
/app/models/request.rb
UTF-8
2,184
2.671875
3
[]
no_license
class Request < ApplicationRecord attr_reader :message belongs_to :created_by, :class_name => "User" belongs_to :user, :class_name => "User" # belongs_to :user belongs_to :role # validates :user_confirm, presence: true #nil is pending, false is declined # validates :owner_confirm, presence: true #nil is ...
true
fd6b8ce2263743642d89c14f9e07f6c8b33ac71d
Ruby
NatdanaiBE/ruby-and-rails
/ruby-scripts/03_triangle_stars.rb
UTF-8
131
2.671875
3
[]
no_license
print '> ' input = $stdin.gets.to_i for i in 0..input do for j in 0..(input - i - 1) do print '* ' end print "\n" end
true
81c828bd501bfc5a8c405088ac276788dae2fbf1
Ruby
alicodes/hello_world
/assessment_109_practice/small_problems/16.rb
UTF-8
64
3
3
[]
no_license
(1..99).each do |index| if index.odd? puts index end end
true
fa70111cd047c23a694928ad63225df40695ec37
Ruby
marekaleksy/learn_ruby
/exercise_11.rb
UTF-8
247
4.15625
4
[]
no_license
print "How old are you?" age = gets.chomp.to_i print "How tall are you?" height = gets.chomp.to_i # centimetres print "How much do you weight?" # kilograms weight = gets.chomp.to_i puts "So you're #{age} old, #{height} tall and #{weight} heavy."
true
68e29648c4faa2c9ab5656e9d7aba60e4d71018e
Ruby
yggie/intro-to-rust-for-web-devs
/ruby/code_breaker.rb
UTF-8
2,279
3.625
4
[ "MIT" ]
permissive
class CodeBreaker attr_accessor :dictionary def initialize(dictionary, key_length, &block) @dictionary = dictionary @cipher_factory = block @key_length = key_length end def crack(ciphertext, plaintext) counter = 0 each_possible_dictionary_combination do |guess| cipher = @cipher_facto...
true
6315c2c3fce7a96bbe4586f1916458bbba59d4f8
Ruby
bocalo/black_jack
/deck.rb
UTF-8
377
3.078125
3
[]
no_license
# frozen_string_literal: true require_relative 'card' class Deck attr_reader :deck def initialize @deck = create_deck end # def deal_cards # @deck.pop # end def create_deck all_cards = [] Card::VALUES.each do |value| Card::SUITS.each do |suit| all_cards << Card.new(suit, ...
true
f7bf2dc2f39731b7cf150fb0da4605704c4e26b5
Ruby
justindelacruz/youtube-captions
/lib/youtube/api.rb
UTF-8
3,954
2.890625
3
[]
no_license
require 'googleauth' require 'google/apis/youtube_v3' module Youtube class Api Youtube = Google::Apis::YoutubeV3 def initialize(api_key: nil) @youtube = Youtube::YouTubeService.new @youtube.key = api_key || 'YOUR_API_KEY' end # Return the "uploads" channel for a given user. def get_...
true
f4e0b905788a10bb397e420313c677f7b42807a0
Ruby
kierendavies/cs-honours-project
/scripts/gen_axioms.rb
UTF-8
4,685
2.875
3
[]
no_license
#!/usr/bin/env ruby require 'singleton' CLASS_NAMES = %w(C D E F G H I J K) OBJECT_PROPERTY_NAMES = %w(r s t u v w x y z) module OneOfSubclasses def subclasses ObjectSpace.each_object(singleton_class).select { |c| c.superclass == self } end def all depth subclasses.map { |sc| sc.all depth }.flatten ...
true
a920c7427ba77c98184ab18cb344e7dcec495314
Ruby
rmangaha/phw
/rb/ex12a.rb
UTF-8
122
3.5625
4
[]
no_license
print "Give me a dollar amount: " dollar = gets.chomp.to_f tip = dollar * 0.1 puts "Ten percent of #{dollar} is #{tip}"
true
74b8f97a1a9123a0b08d64665e70728622c853e2
Ruby
raymondknguyen/enigma
/test/enigma_test.rb
UTF-8
1,610
2.671875
3
[]
no_license
require_relative 'test_helper' class EnigmaTest < Minitest::Test def setup @enigma = Enigma.new end def test_it_exist assert_instance_of Enigma, @enigma end def test_it_can_encrypt expected = { encryption: "keder ohulw", key: "02715", date...
true
7d410a28254057751ca2a8f114545008c58462ff
Ruby
MikeSap/algo-practice
/arrays/two-sum.rb
UTF-8
258
3.40625
3
[]
no_license
def two_sum(nums, target) num_hash = {} nums.each_with_index do |num, i| remainder = target - num if num_hash[remainder] remainder_i = nums.find_index(remainder) return [remainder_i,i] end num_hash[num] = true end nil end
true
8e4d6854b4bc009e0528dabe28df5db23ee68be4
Ruby
Mitchmer/palindrome_checker
/brainteaser2.rb
UTF-8
591
3.796875
4
[]
no_license
def user_input puts "What would you like to input as your palindrome?" input = gets.strip.downcase checkinput(input) end def checkinput(word) checkprep = word.gsub(/[ ]/, '').split(//) initialarr = checkprep.map {|x| x} reversearr = [] while checkprep.length > 0 reversearr << checkprep.pop end if...
true
263b1b319f794129898bad0ddd3c9dd059e41622
Ruby
justinhamlin/ttt-6-position-taken-rb-q-000
/lib/position_taken.rb
UTF-8
121
2.953125
3
[]
no_license
# code your #position_taken? method here! def position_taken?(board, position) if board[0] == " " "false" end end
true
4962ca8c39e931d799511f54e51b9666f0ee4997
Ruby
twohlix/database_cached_attribute
/spec/database_cached_attribute_spec.rb
UTF-8
5,148
2.546875
3
[ "MIT" ]
permissive
require 'temping' require 'database_cached_attribute' ActiveRecord::Base.establish_connection("sqlite3:///:memory:") Temping.create :no_include_class do with_columns do |t| t.string :string_attribute t.integer :integer_attribute end end Temping.create :include_class do include DatabaseCached...
true
fb29acf5fe4378b0b18b55cb46068c3beb6f5cd6
Ruby
jtlai0921/PG20249_example
/PG20249_sample/Ruby268-SampleProgram-UTF8/Ch9/sample217-01.rb
UTF-8
329
2.625
3
[]
no_license
t0 = Time.now # 測量前的實際時間 tms0 = Process.times # 測量前的CPU時間 100000.times{ File.read("/etc/hosts") } # 讀取檔案10萬次 t1 = Time.now # 測量後的實際時間 tms1 = Process.times # 測量後的CPU時間 p [t1 - t0, tms1.utime - tms0.utime, tms1.stime - tms0.stime] #=> [1.987855, 0.96, 0.99]
true
5c4ac7e61ff4dff800e852c25073ec1c2d56b841
Ruby
dblem/oo-tic-tac-toe-q-000
/lib/tic_tac_toe.rb
UTF-8
2,484
4.15625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe def initialize(board = nil) @board = board || Array.new(9, " ") end def display_board puts " #{@board[0]} | #{@board[1]} | #{@board[2]} " puts "-----------" puts " #{@board[3]} | #{@board[4]} | #{@board[5]} " puts "-----------" puts " #{@board[6]} | #{@board[7]} | #{@boar...
true
2723a48ad7f56bc5589415fc41991e1b9f4f711d
Ruby
raiet13/collections_practice-v-000
/collections_practice.rb
UTF-8
983
3.875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
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 do |a, b| a.length <=> b.length end end def swap_elements(array) array[1], array[2] = array[2], array[1] array end def swap_elements_from_to(array, index, destina...
true
d002c38233aa7cc396b4afb79d95b6bd1f100a56
Ruby
donaldpiret/google_data_source
/lib/google_data_source/base.rb
UTF-8
4,216
2.71875
3
[ "MIT" ]
permissive
module GoogleDataSource def self.included(base) base.extend(ClassMethods) end ## # Class Methods module ClassMethods def google_data_source(params, options = {}) joins = options[:joins] result = self.connection.execute(Parser.query_string_to_sql(params[:tq], self, joins)) cols = ...
true
d5c6565fdf6b7c29d29cba98140aa1ce50f257fc
Ruby
secrgb/randomsnippets
/rails_host_without_www.rb
UTF-8
1,480
2.53125
3
[ "MIT" ]
permissive
# RandomSnippets by Jaan Janesmae <jaan@naojo.se> # # Copyright (c) 2009-2010 Jaan Janesmae # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation # files (the "Software"), to deal in the Software without # restriction, including without limitati...
true
e9416d5d3fae3f440d793a9bc3401c9247d47c7e
Ruby
influxdata/influxdb-scripts
/generators/gaussian.rb
UTF-8
1,679
3
3
[]
no_license
require "influxdb" ACTIONS = [ {mean: 500, stddev: 75, name: "welcome#index", count: 50_000}, {mean: 1000, stddev: 100, name: "users#new", count: 500}, {mean: 200, stddev: 10, name: "sessions#create", count: 5000}, {mean: 5000, stddev: 800, name: "exceptions#create", count: 200}, {mean: 400, stddev: 10, name...
true
b414b5f2cbde99ec026fadefbd546bf562db6cca
Ruby
ltarnowski1/Ruby_Projekt3
/spec/manager_spec.rb
UTF-8
1,212
2.6875
3
[]
no_license
require 'rspec' require_relative '../spec/spec_helper' describe 'Manager' do obj = Manager.new it 'should add book' do expect{ obj.addBook("title", "author", "release_year", "price") }.not_to raise_error end it 'should get books' do expect { obj.getBooks }.not_to raise_error en...
true
7d0be52a2ab61f40ccbdbbfffc5403ce4240f77a
Ruby
taka521/playground-for-ruby
/hello-world/keyword_args.rb
UTF-8
188
3.171875
3
[ "MIT" ]
permissive
def method(arg1: 'A', arg2: 'B', arg3: 'C') puts "aeg1 = #{arg1}, arg2 = #{arg2}, arg3 = #{arg3}" end method(arg1: 'Hello!') method(arg2: 'World!') method(arg1: 'Hello', arg3: 'World!')
true
b9855dc56046d49dd6b8da57c43963e05c7a328d
Ruby
pbanos/therapeutor
/lib/therapeutor/questionnaire/section.rb
UTF-8
1,404
2.65625
3
[ "Apache-2.0" ]
permissive
require 'therapeutor/questionnaire/question' class Therapeutor::Questionnaire::Section include ActiveModel::Validations attr_accessor :name, :description, :questions, :questionnaire validates :name, presence: {allow_blank: false} validates :questionnaire, presence: true validate :validate_questions def i...
true
bff1b5abdfaf5ba8c74fac8124323b9f111b989b
Ruby
Ami-tnk/rubybook
/chapter4/drinks5.rb
UTF-8
182
3.21875
3
[]
no_license
drinks = ["モカ", "コーヒー", "カフェラテ"] # 配列の末尾から要素を1つ削除 drinks.pop p drinks # 配列の先頭から要素を1つ削除 drinks.shift p drinks
true
ffd87731f4f33452e2d2cac152e891fad61fbb6a
Ruby
stoic-plus/backend_prework
/day_7/10_little_monkeys.rb
UTF-8
816
4
4
[]
no_license
def in_words(int) numbers_to_name = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Nine", 10 => "Ten", } return numbers_to_name[int] || int end # Will only print rhyme with word numbers for 1 - 10 times. de...
true
388fa9728b682bd54ad1161690a12fda82fb43f9
Ruby
delphist/marleyspoon-test
/app/queries/list_recipes_query.rb
UTF-8
417
2.515625
3
[]
no_license
# frozen_string_literal: true class ListRecipesQuery PER_PAGE = 3 FIELDS = %w[sys.id fields.title fields.description fields.photo].freeze def initialize(repository, page) @repository = repository @page = page || 1 end def call repository.entries( skip: (page - 1) * PER_PAGE, limit: ...
true
51a38006812fc5ca933d604500b1d337ef48067b
Ruby
Eversilence/ramda-ruby
/spec/ramda/list_spec.rb
UTF-8
10,281
2.875
3
[ "Ruby", "MIT" ]
permissive
require 'spec_helper' describe Ramda::List do let(:r) { described_class } context '#all' do it 'test' do equals3 = R.equals(3) expect(r.all(equals3, [3, 3, 3, 3])).to be_truthy expect(r.all(equals3, [3, 3, 1, 3])).to be_falsey end it 'is curried' do equals3 = R.equals(3) ...
true
bf29e029dcadba17b74d4a5c51d463dacad455cd
Ruby
wf1101/MediaRanker
/test/models/work_test.rb
UTF-8
1,852
2.53125
3
[]
no_license
require "test_helper" describe Work do describe "validations" do before do @work = Work.new end it "is valid when a work has a unique title " do title_ex = "coolbanana" @work.title = title_ex result = @work.valid? result.must_equal true end it "is invalid when a wo...
true
7d2d5d25ae278c36616a4eae61cb5b7297db6642
Ruby
jserme/ruby-study
/01基本环境/helloworld.rb
UTF-8
284
3.546875
4
[]
no_license
#双引号的内转义字符会被处理 print("hello world from ruby\n") #单引号的不处理 print('hello world from ruby\n') #puts自动加上换行 puts "hello world" #p方法明确显示是字符串还是数字 p 100 p "100" p '100' #输出中文 puts "听说我是中文"
true
94bb09fe1895f4528b1ba763805a4766b7f00034
Ruby
AleaToir3/20exo
/exo/exo_10.rb
UTF-8
72
2.5625
3
[]
no_license
puts "Donne moi ton année de naissance" ddn = gets.to_i puts 2017 - ddn
true
44b58cc554a58aa5b3bbf4ca8637020385797f75
Ruby
usiegj00/right_data
/lib/FileSystemTree.rb
UTF-8
5,019
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'escape' module RightData class FileSystemTree attr_reader :relativePath attr_reader :parent attr_reader :ignore_children attr_reader :duplicate_children attr_accessor :duplicates attr_accessor :ignorable def initialize path, args if args[:parent] @relative...
true
a11483a70ec6815d80ffd2045aa3a1c8eca12bef
Ruby
lukesarnacki/subscriptions
/subscription/domain/subscription.rb
UTF-8
1,173
2.546875
3
[]
no_license
# frozen_string_literal: true require 'securerandom' require_relative '../../common/result' require_relative './pauses' class Subscription attr_accessor :status, :available_pauses, :last_pause_date, :pauses protected :status, :pauses def initialize(pauses: Pauses.new, status: :new, subscriber_id:) self.stat...
true