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
87f305b049062c4f9d4ba82f63a33b24e001cfa5
Ruby
scalone/design-patterns-builder
/lib/design/patterns/builder/computer.rb
UTF-8
343
2.625
3
[ "MIT" ]
permissive
module Design module Patterns module Builder class Computer attr_accessor :display, :motherboard, :drives def initialize(display = :crt, motherboard = Motherboard.new, drives = []) @display = display @motherboard = motherboard @drives = drives end ...
true
ed215bf9678898cb83dbcf60467759a48e4cf7d3
Ruby
edgcastillo/Programming_Challenges
/HackerRank/test_n.rb
UTF-8
167
3.796875
4
[]
no_license
def reverse(str) ar = [] (0..str.length).each do |x| ar.push(str[str.length - x]) end return ar.join('') end puts reverse("string") puts reverse("Hello! World")
true
0402ad3d666e496c646c014db6954248b52e8fd6
Ruby
eljefesun/learn_ruby
/10_temperature_object/temperature.rb
UTF-8
1,797
4.6875
5
[]
no_license
# Did not know what an options was or how to implement it. Found the use case on stack overflow and was able to implement it here. STill a little confusing but I get the general idea to have the option to use a has as an argument in your fuction. I was also able to re-use code from the previous temperature section. cl...
true
97335160a56c8459b989e432cb94323cf3076158
Ruby
ArthuruhtrA/Spring-2015
/Practicum-1/measure.rb
UTF-8
737
3.1875
3
[]
no_license
require_relative 'measure_util' # Measurement Conversion Main Driver # For each line of CSV input from $stdin: # - parse the input line into appropriate fields # - convert the measurements to TSP # - perform the computation if requested # - output the result as "Result = xx TSP" $stdin.each do |line| ## ...
true
1d298c50449c5f7e8011c02e094404129532413c
Ruby
SindhuVempati/restaurant-foods
/lib/support/string_extend.rb
UTF-8
145
3.078125
3
[]
no_license
class String #capitalizes the first letter of every word def titelize self.split(' ').collect{|word| word.capitalize}.join(" ") end end
true
52dfc56fa2b3b6b9c7160652a72f51761bdddae2
Ruby
beck03076/monee
/lib/monee/comparison.rb
UTF-8
457
3.140625
3
[ "MIT" ]
permissive
module Monee # modularizing the comparison of money objects method in a separate module module Comparison include Comparable # this is the spaceship operator overriding, this will take care of >, <, == # # @params other [Money, Numeric] # @return [Boolean] def <=>(other) if currency =...
true
e4050d49d6973b373a4fb0f3a4ad504e3d5f8823
Ruby
StephenVarela/ruby_fundamentals1
/exercise4.rb
UTF-8
1,285
4.25
4
[]
no_license
## Exercise 4 puts "Please Enter a Number" user_number = gets.chomp.to_i if(user_number >= 100) puts "Thats a big number!" else puts "Why not dream bigger?" end ## Part 2 identifying difference in age puts "Tell me yo age foo!" user_age = gets.chomp.to_i if(user_age > 105) puts "Im not sure i believe you!" els...
true
25c45586e7351ad5d09f4bef8c55d43d0fe5d506
Ruby
tiffaniechia/Learning-Ruby-4-Roman-Numerals
/lib/roman.rb
UTF-8
1,714
4.1875
4
[]
no_license
def divisible_by_1000(num) num / 1000 end def divisible_by_500(num) remainder_1000=num%1000 remainder_1000 / 500 end def divisible_by_100(num) remainder_1000=num%1000 remainder_500=remainder_1000%500 remainder_500 / 100 end def divisible_by_50(num) remainder_1000=num%1000 remainder_500=remainder_100...
true
98b96eecad84639f067d56353837eee854e7dd6b
Ruby
apires89/food-delivery-reboot-767
/app/views/sessions_view.rb
UTF-8
293
2.546875
3
[]
no_license
require_relative "base_view" class SessionsView < BaseView def print_element(element,index) puts "#{index + 1} -- #{element.username} -- #{element.role}" end def print_wrong_credentials #print this if user inputs wrong password puts "Wrong password... try again!" end end
true
7ee7bc0c736da2ae875c4bf2233d4453fabd0d21
Ruby
jonmagic/git-gc-msgpack-object-experiment
/script/run
UTF-8
3,501
2.625
3
[]
no_license
#!/usr/bin/env ruby require "fileutils" require "lorem" require "msgpack" require "open3" require "pathname" require "pry" require "rugged" class Runner def initialize @results_in_bytes = { :parent_oid => [], :oid => [] } @obj = {} @counter = nil end attr_reader :results_in_bytes ...
true
008de1f871133defb3623892412fa6c6ee207f42
Ruby
clouder/learn_ruby
/04_simon_says/simon.rb
UTF-8
287
3.65625
4
[]
no_license
def echo(text) text end def shout(text) text.upcase end def repeat(text, times = 2) ((text + ' ') * times).chop end def start_of_word(word, num) word[0..num-1] end def first_word(text) text.split[0] end def capitalize(word) "Obama" end def titleize(text) "Barack Obama" end
true
88e671a17756045fe137af70f8fb9876b5eb59b2
Ruby
nekokat/codewars
/7kyu_1/coding-meetup-number-4-higher-order-functions-series-find-the-first-python-developer.rb
UTF-8
339
3.4375
3
[ "Unlicense" ]
permissive
#Kata: Coding Meetup #4 - Higher-Order Functions Series - Find the first Python developer #URL: https://www.codewars.com/kata/5827bc50f524dd029d0005f2 def get_first_python(users) res = users.keep_if{|i| i[:language] == "Python"}.first res.nil? ? "There will be no Python developers" : "#{res[:first_name]}, #{r...
true
d575bb4f35d388117af9589564f9d6713de5d317
Ruby
reneedv/antikythera
/lib/antikythera.rb
UTF-8
238
2.515625
3
[ "MIT" ]
permissive
module BeforeAndAfter def before?(time) self < time end def after?(time) self > time end end class Time include BeforeAndAfter end class DateTime include BeforeAndAfter end class Date include BeforeAndAfter end
true
7ec2d4def00b4a8e2b6048f7a54d84a614508920
Ruby
inokappa/kaminari
/mrblib/kaminari/verify.rb
UTF-8
738
2.96875
3
[]
no_license
module Kaminari class Verify def initialize(path) @path = path end def verify puts "分割した #{@path} を検証します.".color(:blue) return 'Verification error.'.color(:red) unless merge_files == read_orignal_file 'Verified.'.color(:green) end def read_orignal_file original = ...
true
e44853e67680f454f4a875170c2f9f825b667c11
Ruby
dragonnova5091/flashdrivebackup
/Projects in Programming/AI/text interpretation/text_interpretation.rb
UTF-8
1,332
3.390625
3
[]
no_license
class Reader def initialize(sentence) begin @meanings = File.open("oldMeanings.txt", "a+") @meanings_array = IO.readlines("oldMeanings.txt") rescue @meanings = File.new("oldMeanings.txt", "a+") @meanings_array = IO.readlines("oldMeanings.txt") end #meaning = "P|this is a test" found = fal...
true
976209849305674abd59728f5ba96364edfb3c86
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/filtered-submissions/befeebf2999e487c8b31b5e06bbed85b.rb
UTF-8
224
3.046875
3
[]
no_license
def compute(str1 = "", str2 = "") sequence_1, sequence_2, distance = str1.chars, str2.chars, 0 sequence_1.zip(sequence_2).each do |n1, n2| distance += 1 unless (n1 == n2) or n2.nil? end distance end
true
c34184239d6102b2e662de30d607aa5e9a0f1518
Ruby
markryall/lwnn
/lib/lwnn/operation.rb
UTF-8
291
2.796875
3
[ "MIT" ]
permissive
require 'lwnn/trace' module Lwnn class Operation include Trace def initialize name, &block @name, @block = name, block end def evaluate state trace "calling operation #{@name}" @block.call state end def to_s @name.to_s end end end
true
183a5545ea698bdecc75f61c3b6128e31d4d5687
Ruby
cavery8989/myrecipes
/test/models/recipe_test.rb
UTF-8
1,574
2.640625
3
[]
no_license
require 'test_helper' class RecipeTest < ActiveSupport::TestCase def setup @chef = Chef.create(name: "bob", email: "bob@bobby.com") @recipe = @chef.recipes.build(name:"chicken hat", summary: "this is ha food and ha hat", description:"what you gonna do when they come for you chicken hat chicken hat") end ...
true
f809876b8d826385702009fa4996fc7c5525473c
Ruby
randyher/deck-of-cards-dumbo-web-100818
/solution.rb
UTF-8
537
3.46875
3
[]
no_license
require 'pry' class Card attr_reader :rank, :suit def initialize(suit,rank) @rank = rank @suit = suit end end class Deck attr_reader :cards, :suit, :rank def initialize @suit = ["Spade", "Heart", "Club", "Diamond"] @rank = ["A", "2", "3", "4", "5", "6","7", "8", "9","10", "J", "Q", "K"] ...
true
ee0529ca1c6d6ad42cc8e64dafdf3719fdbc11b3
Ruby
tbpgr/ruby_samples
/object/object_send.rb
UTF-8
1,005
2.5625
3
[]
no_license
require 'tbpgr_utils' class Hoge def public_hoge return "public_hoge" unless block_given? yield end protected def protected_hoge return "protected_hoge" unless block_given? yield end private def private_hoge return "private_hoge" unless block_given? yield end end hoge = Hog...
true
0174e507d97c7c2949fa00d87dad1fcfe902774e
Ruby
danielperzales/deli-counter-001-prework-web
/deli_counter.rb
UTF-8
500
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here def line(katz_deli) if katz_deli == [] puts "The line is currently empty." else puts "The line is currently: 1. Logan 2. Avi 3. Spencer" end end def take_a_number(katz_deli, name) katz_deli.push(name) num = katz_deli.size puts "Welcome, #{name}. You are number #{num} in line." end ...
true
fa0cdf6bf83cca39b11e22d3f4e4b0635dce597f
Ruby
Smack247/BeastStreet
/app/controllers/posts_controller.rb
UTF-8
1,456
2.59375
3
[]
no_license
class PostsController < ApplicationController before_action :find_post, only: [:show, :edit, :update, :destroy, :upvote, :downvote] #Cool this method inside of find_post will get the post by its parameters and only display for edit, destroy, before_action :authenticate_user!, except: [:index, :show] #You need to sign u...
true
33b08faae3b8181c76949314149edf589236df14
Ruby
chrisbgalileo/Ruby
/Lab1/Computer.rb
UTF-8
973
3.1875
3
[]
no_license
class Computer @@users = {} def initialize username, password @username = username @password = password @files = {} end def create nombre if (@files.key?(nombre)) puts "Error" else @files[nombre] = Time.now end end def rm nombre if (@files.key?(nombre)...
true
0a950ef14bfc2e8293146b435eb4259ab58eff99
Ruby
mjbotes/Expert_Systems_Ruby
/main.rb
UTF-8
4,692
2.59375
3
[]
no_license
#!/usr/bin/ruby -w require "./toRPN" require "./solveRPN" require "./colorize" puts "██╗ ██╗███████╗██╗ ██████╗ ██████╗ ███╗ ███╗███████╗ ████████╗ ██████╗ ██║ ██║██╔════╝██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝ ╚══██╔══╝██╔═══██╗ ██║ █╗ ██║█████╗ ██║ ██║ ██║ ██║...
true
d1f816bee613cf1eee4cb79d0e5a5a31cc092193
Ruby
ryanmmhmm/algorithm-solutions
/balancing-brackets/solution1.rb
UTF-8
614
4.25
4
[]
no_license
## Counter method for determining single-type bracket closure def balanced?(string) stack = [] closure = 0 string.each_char do |c| if c == "(" closure += 1 elsif c == ")" closure -= 1 end break if closure < 0 end closure == 0 end string = "()" puts "#{string} is #{balanced?(...
true
3d1a691fe5923a4a245cc8f44ccc9ff7aeb51d8e
Ruby
Nexproc/App-Academy
/projects/HashMap Algorithms/lib/p01_int_set.rb
UTF-8
855
3.46875
3
[]
no_license
class MaxIntSet def initialize(max) @store = Array.new(max, false) end def insert(num) raise "Out of bounds" if num > @store.size || num < 0 @store[num] = true end def remove(num) @store[num] = false end def include?(num) @store[num] end end class IntSet def initialize(length ...
true
c960c7192d55f72a31e01ffc6c81e7c22e041726
Ruby
sunkibaek/log_analysis
/array.rb
UTF-8
487
3.5625
4
[]
no_license
# Monkeypatching Array for mean, median, and mode. # Mode returns the element of smallest index if there are more than one class Array def mean return nil if empty? reduce(:+).to_f / length end def median return nil if empty? mid_index = ((length.odd? ? length + 1 : length) / 2) - 1 sort[...
true
899cbdf9308c0d26537dd7a28b56fa375486dbba
Ruby
dankb82/battleship
/human_player.rb
UTF-8
166
2.890625
3
[]
no_license
require './player.rb' require './computer_player.rb' class HumanPlayer < Player def initialize(name = "Dave") @name = name end def name @name end end
true
3ca189ef4ea42f392cd8f553ad72586b6b5c3ace
Ruby
Drenmi/push-up-bot-demo
/lib/bot.rb
UTF-8
604
3.171875
3
[]
no_license
# This is our initial bot implementation. It works by listening for messages # and checking them against a regular expression that matches a number followed # by a bang, e.g. "36!". This is how users will report their push ups in the # Slack channel. class Bot < SlackRubyBot::Bot PUSH_UP_COUNT = /^\s*(?<count>\d+)!\...
true
fba3bbe2b3890057270f324643c053a1a307719d
Ruby
abdibogor/Ruby
/3.Smartherd/Ruby/60.Difference between Procs and lambda/difference_proc.rb
UTF-8
237
3.15625
3
[]
no_license
# Difference Between Procs and Lambda # Program of a Proc def my_method puts "before proc" my_proc = proc{ puts "Inside proc" #return } my_proc.call puts "after proc" end my_method
true
075882bb1909dc1e52731ce356ef7b8c1b978e5f
Ruby
chessbyte/chess
/board.rb
UTF-8
2,177
3.46875
3
[]
no_license
require 'piece' class Board def setup @board = Hash.new @board['a1'] = Piece.new(:rook, :white) @board['b1'] = Piece.new(:knight, :white) @board['c1'] = Piece.new(:bishop, :white) @board['d1'] = Piece.new(:queen, :white) @board['e1'] = Piece.new(:king, :white) @board['f1'] = Piece.n...
true
e7ed4fe1214b5b37b8de9c2513fe52e89a68777b
Ruby
kvnchu2/Two-O-Player-Math-Game
/player_turn.rb
UTF-8
137
3.328125
3
[]
no_license
class PlayerTurn attr_accessor :turn def initialize(turn) @turn = turn end def switch(turn) self.turn = turn end end
true
b5eebc1944326a636e03537f20c2702c41b59512
Ruby
JordanLong1/programming-univbasics-4-array-simple-array-manipulations-online-web-prework
/lib/intro_to_simple_array_manipulations.rb
UTF-8
625
3.046875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def using_push(array, string) array.push(string) end def using_unshift(array, string) array.unshift(string) end def using_pop(array) array.pop end def pop_with_args(array) array.pop(2) end def using_shift(array) array.shift end def shift_with_args(array) array.shift(2) end def using_concat(array, new_array)...
true
90fe1d275214cd0a9e8d283edea6e9036d3ac468
Ruby
CristopherVidalMachado/reservations
/spec/models/report_spec.rb
UTF-8
4,240
2.515625
3
[ "MIT", "AGPL-3.0-or-later" ]
permissive
# frozen_string_literal: true require 'spec_helper' describe Report, type: :model do before(:each) do @report = Report.new end describe Report::Column do it 'can be constructed from arrays' do column = Report::Column.arr_to_col ['Name', :scope, :type, :field] expect(column.name).to eq('Name'...
true
e8ff5c7f743efd8212175384eb502ffbf458bdfa
Ruby
commuterjoy/BBC-News-Mobile-Search
/spec/search_spec.rb
UTF-8
2,843
2.859375
3
[]
no_license
require 'app/lib/news/search.rb' require 'spec_helper.rb' describe Search do it "should contain no results before a search" do search = Search.new search.results.should have(0).things end it "should return a list of results" do search = Search.new search.fetch('cats') ...
true
6f73262844d2711f3f8bd1a7538364a463651bf9
Ruby
stelligent/SWFpoc
/lib/setup.rb
UTF-8
469
2.625
3
[]
no_license
def usage_config puts <<USAGE To run the samples, put your credentials in config.yml as follows: access_key_id: YOUR_ACCESS_KEY_ID secret_access_key: YOUR_SECRET_ACCESS_KEY USAGE exit 1 end def setup config_path = File.expand_path(File.dirname(__FILE__)+"/../config/aws.yml") unless File.exist?(config_path) ...
true
65a8322b5e7a9e8f196aac9a5448348f069c831c
Ruby
hakonb/TimeFlux
/app/controllers/reporting.rb
UTF-8
3,338
2.734375
3
[ "MIT" ]
permissive
module Reporting private def setup_calender if params[:calender] year = params[:calender]["date(1i)"].to_i month = params[:calender]["date(2i)"].to_i else year = params[:year].to_i if params[:year] && params[:year] != "" month = params[:month].to_i if params[:month] && params[:mont...
true
e79ea1b0b4918a17017238af251d15550ac2c608
Ruby
traday/prr_activerecord_querying_examples
/db/seeds.rb
UTF-8
4,748
2.796875
3
[]
no_license
# # A bunch of users to test find_each and find_in_batches # (1..10000).each do name = Faker::Name.name User.create!(name: name, username: Faker::Internet.user_name(name)) end # # The Join exmple models # Category.create!([{name: "Technical"}, {name: "Gossip"}, {name: "Politics"}]) tech = Category...
true
14551d35b97e1f24806cdd92fabb360e653716a2
Ruby
cjwind/booksr
/lib/booksr/api_handler.rb
UTF-8
931
2.8125
3
[]
no_license
#encoding: utf-8 class ApiHandler GOOGLE_MAX_RESULTS = 40 # const def search_by_google(query_string, query_type) responses = Array.new parser = Parser.new # https://www.googleapis.com/books/v1/volumes?q=field:qeury_string&startIndex=#{start_index}&maxResults=#{GOOGLE_MAX_RESULTS} query_string = URI::escape...
true
a9655b96648858d998b293aa83882201ebd1d371
Ruby
jayniz/lacerda
/lib/lacerda/conversion/data_structure/member/type.rb
UTF-8
3,207
2.8125
3
[]
no_license
module Lacerda module Conversion class DataStructure class Member class Type def initialize(type_definition, is_required, scope) @type_definition = type_definition @scope = scope @type_name = type_definition['element'] @is_required = is_requi...
true
16096e8b1c3ba9c9aed32a2e30407b9c868ee9ac
Ruby
mkrahu/launchschool-courses
/101_programming_foundations/03_practice_problems/03_medium_1/question6.rb
UTF-8
257
3.65625
4
[]
no_license
answer = 42 def mess_with_it(some_number) some_number += 8 end new_answer = mess_with_it(answer) p answer - 8 # => 34 - integers are immutable (and assignment does not mutate # the caller, mess_with_it does not affect the value of the variable answer)
true
52983c3411daf0d4bf453c32013b861e5cb9eb49
Ruby
seyitals/Enigma
/characters.rb
UTF-8
110
2.8125
3
[]
no_license
class Characters def character_map ('a'..'z').to_a.concat(("0".."9").to_a).push(" ", ".", ",") end end
true
daa8169807639001542453e549f47b4bb8e3d9ff
Ruby
handwerger/ruby_challenges
/piglatin.rb
UTF-8
1,527
4.0625
4
[]
no_license
# test first letter of word begins with vowel go to method to add ay and that is result # else: # itterate through letters as the ones that are consenants get added to the end of the word then ay # qu must also need to be moved # squ must be moved # x followed by consenant does not get moved require 'pry' class PigLati...
true
8105b1ffe079b63f72e0f8d57444fb37ead3739c
Ruby
lianwangtao/CHUniqueLinkedList
/CHUniqueLinkedList.rb
UTF-8
1,493
3.75
4
[]
no_license
#!/usr/bin/ruby require_relative './CHNode' require 'set' class CHUniqueLinkedList def initialize() @head = nil @set = Set.new() end def add(value) if value == nil return end if @head == nil @head = CHNode.new(value, nil) @set.add(value) return end if @set....
true
b3a7eaa45632088fa940a834c68007fa69d6e9cd
Ruby
learn-co-students/nyc-web-071618
/04-oo-one-to-many/user.rb
UTF-8
682
3.078125
3
[]
no_license
class User attr_accessor :username @@all = [] def initialize(username) @username = username @@all << self end def tweets # ask Tweet.all for the tweets authored by self Tweet.all.select do |tweet_instance| tweet_instance.user == self end end def post_tweet(message) # user...
true
5627d49d72de859ed84af67d14e418e6f98d5e92
Ruby
energon-a-secas/enerbot-slack
/scripts/feedback.rb
UTF-8
783
2.65625
3
[ "MIT" ]
permissive
module Feedback def self.quote quotes = [ 'Lo hiciste excelente durante el año. *Bajo lo esperado*', 'Jugaste fifa todo el año. *Excepcional*, sigue así', 'Jugaste magic en la oficina. *Bajo lo esperado*', 'Tomaste desayuno en la oficina 2 veces en el año. *Bajo lo esperado*', 'Eres ...
true
2590e54609d93d63d5330d14859b10297c1fa2af
Ruby
jessiebaude/ttt-10-current-player-v-000
/lib/current_player.rb
UTF-8
293
3.421875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def turn_count(board) counter = 0 board.each do |icon| if icon == "X" || icon == "O" counter += 1 end end return counter end def current_player(board) turn_number = turn_count(board) + 1 if turn_number.even? == true return "O" else return "X" end end
true
f03afec89f0aab1d5e74696e9d544904a4404b1f
Ruby
rfrm/uninortehorarios
/lib/subject_getter.rb
UTF-8
724
2.671875
3
[]
no_license
require_relative 'getter' class SubjectGetter < Getter def get_subjects(subject_code) r = Typhoeus.post "http://guayacan.uninorte.edu.co/registro/resultado_codigo.asp", body: form_values(subject_code) subjects = {} doc = Nokogiri::HTML(r.body) doc.css("div").each do |div| ...
true
31197e45ce7082833231cac177a5b6b5ac772129
Ruby
mariapacana/etherealpath
/app/models/twilio_client.rb
UTF-8
351
2.5625
3
[]
no_license
class TwilioClient attr_accessor :client def initialize @client = Twilio::REST::Client.new Rails.application.secrets.TWILIO_ACCOUNT_SID, Rails.application.secrets.TWILIO_AUTH_TOKEN @twilio_phone = '+16506459949' end def send_message(phone, message) @client.messages.create from: @twilio_phone, to:...
true
a1b6763981497c50d464521cc580766a7704847c
Ruby
Shengliang/language
/ruby/arr.rb
UTF-8
196
3.71875
4
[]
no_license
array = [1,3,4,71,11] num = 5 def isSum(array, sum) array.each do |x| array.each do |y| return "yes:",x,y if sum == (x+y) and x!= y end end return "no" end puts isSum(array, num)
true
7ee73b435ea0c84b0d3c436d59ae03b9f46654a0
Ruby
mpochwat/Test-First-Ruby
/09_timer/timer.rb
UTF-8
365
3.578125
4
[]
no_license
class Timer def initialize @seconds = 0 end def seconds=(num) @seconds = num end def seconds @seconds end def time_string hours = @seconds / 3600 minutes = (@seconds % 3600) / 60 seconds = @seconds % 60 padded(hours) + ":" + padded(minutes) + ":" + padded(seconds) end def padded(time) time...
true
ceec9fb50b1cd3198db1f12517962661fa6efed6
Ruby
jimbojambo91/Week_2_Day_3_Snakes-Ladders
/player.rb
UTF-8
495
3.875
4
[]
no_license
class Player attr_reader :name, :position def initialize(name, position) @name = name @position = position end def move_position(dice) @position += dice.roll end def win(position) if @position >= 100 return "You win" end return false end def snake(position) if @pos...
true
18944508ce43dbd2d038ba286f7c5f78980d8c10
Ruby
tyronepost/command_line_games
/tictactoe/lib/tictactoe/main.rb
UTF-8
1,818
3.125
3
[]
no_license
require_relative 'menus/main_menu' require_relative 'general/board' require_relative 'menus/layout_menu' require_relative 'menus/game_mode_menu' require_relative 'menus/player_menu_factory' require_relative 'menus/player_order_menu' require_relative 'menus/symbol_menu' require_relative 'menus/difficulty_menu' require_r...
true
78a394e6b552227f0dc229b1a2f7415b6d41c999
Ruby
salrepe/katas
/poker_hands/spec/card_spec.rb
UTF-8
334
2.640625
3
[]
no_license
require_relative '../card' describe Card do describe '#suit' do it 'returns the suit of the card' do card = Card.new('2H') expect(card.suit).to eq('H') end end describe '#value' do it 'returns the value of the card' do card = Card.new('2H') expect(card.value).to eq('2') e...
true
cef6a333a6574201048206b5a4112c7c94ed6edc
Ruby
acockell/confidentqa_cucumber
/features/lib/pythagorean.rb
UTF-8
840
3.6875
4
[]
no_license
class Pythagorean attr_accessor :final def initialize @final = 0 @a = 0 @b = 0 end def check_non_real n if n.to_i >= 0 return n else @final = -1 end end def side_one a a = check_non_real a @a = a.to_i end def side_two b b = check_non_real b @b = ...
true
67a924f35824640a9dec8195a5bb74cfcb9d3c34
Ruby
whoward/budget
/lib/budget/awesome_nested_set_tree.rb
UTF-8
1,573
2.84375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Budget class AwesomeNestedSetTree include Enumerable def self.from_nodes(nodes) by_id = Hash[nodes.map { |n| [n.id, n] }] # TODO: zomg the dirty dirty populate = lambda do |n| nodes.select { |c| c.parent_id == n.node.id } .map do |...
true
4cc897c328fdc65043d50aa13dd42cc497a9b847
Ruby
knlynda/status-page-ruby
/lib/status_page_ruby/services/build_history_table.rb
UTF-8
676
2.546875
3
[]
no_license
module StatusPageRuby module Services class BuildHistoryTable HEADINGS = %w[Service Status Time].freeze attr_reader :status_repository def initialize(status_repository) @status_repository = status_repository end def call(service = nil) Terminal::Table.new( ...
true
d5a033062561d5029438aebc74649bace5b5e590
Ruby
kerryb/goos-ruby
/lib/xmpp/auction_message_translator.rb
UTF-8
1,592
2.65625
3
[]
no_license
module Xmpp class AuctionMessageTranslator def initialize sniper_id, listener, failure_reporter @sniper_id, @listener, @failure_reporter = sniper_id, listener, failure_reporter end def handle_message message event = AuctionEvent.from message case event.type when "PRICE" @l...
true
01247ef31c01a24edd1294b1b47e48b47e21db9e
Ruby
SergeyBerdnikovich/airplanes_monitor
/app/services/fly_queue/append_service.rb
UTF-8
516
2.53125
3
[]
no_license
class FlyQueue::AppendService attr_reader :airplane, :fly_queue def initialize(params) @fly_queue = FlyQueue.new(params) @airplane = fly_queue.airplane end def append! raise Exception.new('Airplane is already in queue') if airplane_in_queue? ActiveRecord::Base.transaction do fly_queue.s...
true
25757f805b84eab8966b2d0aa474ba5cfed85384
Ruby
anjalirai13/RubyLearning
/Pattern_1.rb
UTF-8
234
3.359375
3
[]
no_license
# Draw half diamond in downward pattern j = -1 9.downto(1) { |i| # Print the * for every odd number if (i%2 !=0) if(j >= 0) for k in 0..j printf " " end end for i in 1..i printf "*" end j = j + 1 end puts }
true
7d62e2444652fb472b2536008eb3c6f76297a01f
Ruby
cxn03651/writeexcel
/lib/writeexcel/write_file.rb
UTF-8
1,343
2.84375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# -*- coding: utf-8 -*- class WriteFile def initialize @data = '' @datasize = 0 @limit = 8224 # Open a tmp file to store the majority of the Worksheet data. If this fails, # for example due to write permissions, store the data in memory. This can be # slow for lar...
true
e626accaa33ef736c0a7842b97f275998deb8b06
Ruby
gizele22/Day2
/game.rb
UTF-8
1,639
3.71875
4
[]
no_license
# Force Flush Ruby old_sync = $stdout.sync $stdout.sync = true # set initial values @easy_secret = rand(1..10) @medium_secret = rand(51..70) @hard_secret = rand(71..100) @count = 1 @previous_tries = [] # << Array @history = {} # << Hash @chances = 6 # start here puts "Welcome to Numix-Lucky Number" puts "Enter Your ...
true
26f511049e856da92109d9b51a1de371ac07cd3b
Ruby
joeainsworth/ls-tick-tac-toe
/tic_tac_toe.rb
UTF-8
4,319
3.984375
4
[]
no_license
require 'pry' MAX_ROUNDS = 5 INITIAL_MARKER = ' ' PLAYER_MARKER = 'X' COMPUTER_MARKER = 'O' WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9], [1, 5, 9], [7, 5, 3]] # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def display_board(board) system 'c...
true
20e3af10d743aacfe634e650feb5270a581660e0
Ruby
ValdemarTeodoro/bootcamp_ruby_exchange
/lib/app.rb
UTF-8
821
2.734375
3
[]
no_license
require 'faker' require_relative 'file_process/file_process' require_relative 'billings/billing_partners' require_relative 'billings/billing' require_relative 'exchange/exchange' require_relative 'exchange/exchange_file' billing_partners = BillingPartners.new billing_partners.process_data billing = Billing.new("Leon...
true
81a3c4a8f866f69c9cc3b832e5f0f01e64b9bcb2
Ruby
brasten/field_ex
/lib/field_ex.rb
UTF-8
950
2.53125
3
[ "MIT" ]
permissive
require "field_ex/version" # FieldEx parses field query expressions # # @see FieldEx::Parser.parse # module FieldEx SEPARATOR = "," NESTING = "()" WILDCARD = "*" NEGATION = "!" # Helper method for filtering options hashes provided to as_json(opts) # methods. # # @param [Hash] options # @param [S...
true
e35395d604798841c6a41d41335c637ee21aec47
Ruby
gionaufal/rubymonk
/chapters/strings.rb
UTF-8
926
3.640625
4
[]
no_license
rubymonk = "Ruby Monk" puts rubymonk # to use placeholders, the string has to be with double quotes puts "This string has #{rubymonk.length} characters" def string_length_interpolater(incoming_string) "The string you just gave me has a length of #{incoming_string.length}" end # methods that return boolean values us...
true
28f91335d73713d43c9b003e397d6a878b1b6b7e
Ruby
ankane/pghero
/lib/pghero/methods/explain.rb
UTF-8
2,086
2.5625
3
[ "MIT" ]
permissive
module PgHero module Methods module Explain # TODO remove in 4.0 # note: this method is not affected by the explain option def explain(sql) sql = squish(sql) explanation = nil # use transaction for safety with_transaction(statement_timeout: (explain_timeout_sec *...
true
f0014c1ef7272278e682be4e68eda42aca5629be
Ruby
TakahiroTanaka-dev/Test-Drills
/14.rb
UTF-8
219
3.5625
4
[]
no_license
def police_trouble(a, b) if (a == true && b == true) or (a == false && b == false) puts "True" else puts "False" end end police_trouble(true, false) police_trouble(true, true) police_trouble(false, false)
true
034d397d1a989acf7a281b0cb075f2e93f0b861d
Ruby
tbeeley/Q-R-
/spec/quarter_spec.rb
UTF-8
954
2.71875
3
[]
no_license
require 'quarter' describe Quarter do let(:quarter1) { Quarter.new(data1) } let(:data1) { {:AGILENT_TECHNOLOGIES_INC => 455, :ALCOA_INC => 322, :AARONS_INC => 636} } let(:quarter2) { Quarter.new(data2) } let(:data2) { {:AGILENT_TECHNOLOGIES_INC => 1104, :ASSET_ACCEP_CAP_CORP => 86, :APPLE_INC => 1215} } c...
true
8248dbe854c8fd5fcff5163462e51963f96b2f95
Ruby
all-your-database/HSTracker
/app/log/log_reader_manager.rb
UTF-8
2,286
2.578125
3
[ "MIT" ]
permissive
class LogReaderManager TimeoutRead = 0.5 def start log :reader_manager, starting: true init_readers @starting_point = get_starting_point start_log_readers end def init_readers log :reader_manager, init_readers: true @power = LogReader.new('Power', self, ...
true
3d75e095185aa501eba72fedf9433ad244f11498
Ruby
natenorberg/monstercheckout_rails
/app/models/reservation_equipment.rb
UTF-8
1,042
2.65625
3
[]
no_license
# == Schema Information # # Table name: reservation_equipment # # id :integer not null, primary key # reservation_id :integer # equipment_id :integer # quantity :integer # class ReservationEquipment < ActiveRecord::Base self.table_name = 'reservation_equipment' # Tries to default to ...
true
a828d404f81b80d0f97d63c4eedc4979b7f44a81
Ruby
Adong520/stockpicker
/stock_picker.rb
UTF-8
308
3.171875
3
[]
no_license
def stock_picker (stock) revenue = stock[1] - stock[0] pick = stock[0..1] for i in 0..stock.length-1 for j in i+1..stock.length-1 rev = stock[j]-stock[i] if rev > revenue pick = [i,j] revenue = rev end end end return pick end ###############################################
true
cbab8575e5a6a985f863248e99cd41c8401f7b9e
Ruby
heydanhey/fun_tests
/prime_number.rb
UTF-8
1,502
3.71875
4
[]
no_license
require 'rspec' class PrimeNumber def is_prime?(number) if number == 1 return false else i = number - 1 while i > 1 if number % i == 0 return false else i -= 1 end end end return true end def highest_prime_number_under(number)...
true
364cef6569b7c2e33edbb71e821a0a4bc5fb5e92
Ruby
Drashti92/Hackerank-Solutions
/Day5_Loops.rb
UTF-8
147
2.78125
3
[]
no_license
n = gets.strip.to_i i = 1 while i<=10 d=n*i puts "#{n} x #{i} = #{d}" i = i+1 # this will cause execution to exit the loop end
true
92dd0b72bc81972100142ec3b19cc452e28d9ffe
Ruby
cassiejdelacruz/course101
/small_problems/easy_set_1/easy1_9.rb
UTF-8
178
3.609375
4
[]
no_license
def sum(integer) array = integer.to_s.chars array.map! { |n| n.to_i } array.reduce(:+) end puts sum(23) == 5 puts sum(496) == 19 puts sum(123_456_789) == 45 puts sum(456)
true
0c3b9e83bbe180bb734ccdaeb3834a8f18d0fd24
Ruby
classHANA/likelion
/ruby/scraper.rb
UTF-8
539
2.96875
3
[]
no_license
require 'mechanize' require 'pry' require 'csv' print '뭘 찾을까요?? : ' input = gets.chomp agent = Mechanize.new agent.user_agent_alias = 'Mac Safari' page = agent.get('https://www.amazon.com') search_form = page.form search_form['field-keywords'] = input page = search_form.submit items = page.search('...
true
d50e1d2133f494c5c2c9c937a21d9f1c8c0d5375
Ruby
vincent-psarga/ruby-tap-parser
/lib/tap-parser.rb
UTF-8
1,749
2.875
3
[ "MIT" ]
permissive
module TapParser class Test attr_reader :passed, :skipped, :number, :description, :directive, :diagnostic def initialize(passed, number, description = '', directive = '', diagnostic = '') @passed = passed @number = number @description = description @directive = directive @diagno...
true
727f7592494863c8670157abb0fd3fade9458d9d
Ruby
Skylonatron/magic_statistics
/app/models/deck.rb
UTF-8
1,767
2.765625
3
[]
no_license
class Deck < ApplicationRecord validates :name, presence: true has_many :decks_cards, class_name: "DecksCards", foreign_key: "deck_id", dependent: :destroy has_many :cards, through: :decks_cards belongs_to :user def cards_with_sideboard self.cards.select("cards.*, decks_cards.sideboard") end def...
true
604c771727b4c6cae1d4daa36b856cd203c5b3b7
Ruby
paullewallencom/ruby-978-1-78439-295-6
/02/02-custom_matchers-v1.rb
UTF-8
893
3.203125
3
[]
no_license
# v1 : custom error message without a custom matcher class Customer def initialize(opts) # assume opts = { discounts: { "foo123" => 0.1 } } @discounts = opts[:discounts] end def has_discount_for?(product_code) @discounts.has_key?(product_code) end def discount_amount_for(product_code) @disco...
true
b0c9cd6d8b7aee4a7a8c0b7d246dad66f2dcdb3f
Ruby
wgreenberg/larceny
/app/models/simulation.rb
UTF-8
247
2.625
3
[]
no_license
class Simulation < ApplicationRecord def self.current_time Simulation.last.sim_time end def self.next_time Simulation.current_time + 1 end def self.advance sim = Simulation.last sim.sim_time += 1 sim.save end end
true
1830b0610c026845a359837373fc3ebf3cf8708e
Ruby
parkermatheson/study_group
/vowel.rb
UTF-8
170
3.703125
4
[]
no_license
vowel = ['a', 'e', 'i', 'o', 'u'] count = 0 str = 'Hello, this is Parker' arr = str.split('') arr.map do |i| if vowel.include?(i) count += 1 end end puts count
true
4240a9d7cf43bc502973ae86a205d7143cd3e0fb
Ruby
DavidEGrayson/redstone-bot2
/lib/redstone_bot/brain.rb
UTF-8
766
3.140625
3
[]
no_license
require 'thread' module RedstoneBot class Brain attr_reader :synchronizer def initialize(synchronizer) @synchronizer = synchronizer end def start stop @thread = Thread.new do @synchronizer.synchronize do begin yield ensure ...
true
743a7974986b01be43afb780489097e16a23a3d0
Ruby
atruby-team/internship-18-summer
/at-luantran/Week3/2018_07_03_exercise2_rubyday2.rb
UTF-8
64
3.125
3
[]
no_license
a = [1, 2, 3, 1] a.map! { |x| x.even? ? 'even' : 'odd' } puts a
true
0d5808a2337bad37054b5c0ff51dfeb45225d0b4
Ruby
justonemorecommit/puppet
/acceptance/lib/puppet/acceptance/service_utils.rb
UTF-8
7,212
2.625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
require 'puppet/acceptance/common_utils' module Puppet module Acceptance module ServiceUtils # Return whether a host supports the systemd provider. # @param host [String] hostname # @return [Boolean] whether the systemd provider is supported. def supports_systemd?(host) # The Win...
true
476a0d90a7fc8e666fbc59d44cbe30bdfb841f51
Ruby
elan690/learning-ruby-on-hard-way
/ex28.rb
UTF-8
971
3.6875
4
[]
no_license
puts true and true true puts false and true false puts1 == 1 and 2 == 1 true puts "test" == "test" true puts 1 == 1 or 2 != 1 true puts true and 1 == 1 true puts false and 0 != 0 false puts true or 1 == 1 true puts "test" =...
true
306f03e574e0d6a3143c910a864ca1d9f2f26d3e
Ruby
jebediahelliott/sinatra-mvc-lab-v-000
/models/piglatinizer.rb
UTF-8
589
3.328125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class PigLatinizer def piglatinize(input) new_string = "" input = input.split input.each do |word| # binding.pry new_word = word.split(/([aeiouAEIOU].*)/) if new_word[0] == "" new_word[0] = "way" new_word[0], new_word[1] = new_word[1], new_word[0] else ne...
true
eed60581714cf753868445696cf11f06da4f4551
Ruby
Sophie5/Boris-bikes-final-
/lib/docking_station.rb
UTF-8
704
3.328125
3
[]
no_license
require_relative 'bike' class DockingStation # Docking station starts empty. Bike is created outside DEFAULT_CAPACITY = 20 attr_reader :capacity def initialize(capacity = DEFAULT_CAPACITY) @capacity = capacity @bikes_arr = [] end def release_bike fail "no bikes" if empty? @bikes_arr.pop...
true
40377db16bb94939d5170399042125b850142297
Ruby
jimberlage/tictactoe
/lib/computer_player.rb
UTF-8
408
3.203125
3
[]
no_license
require './lib/tree_node' class ComputerPlayer def initialize(symbol, board) super(symbol, board) @tree_root = TreeNode.new end def make_game_tree(root) end def is_winning_node?(node) node.value[:board].winning_board?(@symbol) end def is_losing_node?(node) node.value[:board].losing_b...
true
5f36df333fed02a17421bc7e8177c0a153a955ac
Ruby
bkichler/chessapp
/spec/models/knight_spec.rb
UTF-8
1,237
2.8125
3
[]
no_license
require 'rails_helper' RSpec.describe Knight, type: :model do it 'is created with populate_game method' do game = FactoryBot.create(:game) expect(game.pieces.where(type: "Knight").size).to be(4) end it 'has a valid_move? method that returns true for a 2-to-1 move in any direction' do game =...
true
a57808fe9bc3d9b0eb4a1f270a6723269109ac0b
Ruby
jochenseeber/calificador
/lib/calificador/key.rb
UTF-8
1,992
2.546875
3
[ "MIT" ]
permissive
# typed: strict # frozen_string_literal: true require "minitest" module Calificador # Test subject key class Key include Util::EscapeHatch NO_TRAIT = :"<none>" DEFAULT_TRAIT = :"<default>" class << self sig { params(type: Module, trait: T.nilable(Symbol)).returns(Key) } def [](type, ...
true
a6f1b3a9d256ab4860847581120036b108001b29
Ruby
s-daoud/w1
/w1d1/iteration_review.rb
UTF-8
897
3.859375
4
[]
no_license
def factors(num) (1..num).select{ |el| num % el == 0 } end def substrings(string) subs = [] (string.length).times do |x| (string[x..-1].length).times do |y| subs << string[x..x + y] unless subs.include?(string[x..x + y]) end end subs end def subwords(word, dictionary) words = substrings(word...
true
6391abd36bd5d8ea159e1d59c09f8e030a4c9691
Ruby
nikhgupta/handlisted
/spec/support/matchers/merit_badge_matcher.rb
UTF-8
1,971
2.546875
3
[]
no_license
module CustomMatchersForCapybara class HaveBadge def initialize(*expected) name, level = [expected].flatten @badge = Merit::Badge.find_by_name_and_level(name, level) end def matches?(page_or_model) @page_or_model = page_or_model is_page? ? page_has_badge? : model_has_badge? en...
true
5e16122b6b33bcf205cec12df288a4f4227352c2
Ruby
dball/acts_as_calendar
/spec/models/calendar_spec.rb
UTF-8
2,363
2.625
3
[]
no_license
require File.dirname(__FILE__) + '/../spec_rails_plugin_helper' describe Calendar, "when empty" do before(:each) do @calendar = Factory(:calendar) end it "should have no dates" do @calendar.dates.should == [] @calendar.dates.values.should == [] end it "should have no events" do @calendar.ev...
true
13dc5476ca12f667ae75ccda9e18309d401bea5d
Ruby
oliverpople/battle_canace
/lib/player.rb
UTF-8
250
3.28125
3
[]
no_license
require_relative 'game.rb' class Player attr_reader :name, :hp_value DEFAULT_HP_VALUE = 60 def initialize(name, hp_value = DEFAULT_HP_VALUE) @name = name @hp_value = hp_value end def receive_damage @hp_value -= 10 end end
true
1023fb0e8c9e61c47418ed3c6aade037e6b651f0
Ruby
kalanchoej/check_upload_queues
/check_queue.rb
UTF-8
2,659
3.015625
3
[]
no_license
#!/usr/bin/ruby # The purpose of this script is to check the size of the queues to central. # It uses the Expect module to log in to the server and go to monitor upload # queue. require 'pty' require 'expect' host = ARGV[0] login = ARGV[1] pass = ARGV[2] site = ARGV[3] ARGV[4] ? timeout = ARGV[4].to_i : timeout = 5 ...
true
66ac3d44fa6b795830a0550c8716483a3ba257b9
Ruby
learn-academy-2021-bravo/week-6-assessment-hexflores87
/rails-commenting.rb
UTF-8
1,697
2.65625
3
[]
no_license
# ASSESSMENT 6: Rails Commenting Challenge # Add comments to the Rails Blog Post Challenge # Explain the purpose and functionality of the code directly below the 10 comment tags # FILE: app/controller/blog_posts_controller.rb # ---1) # This purpose represents creating a controller called BlogPostsController. In a ...
true
192b26289ffae094e3019bd1f20121d3d17f6bf6
Ruby
adk9/citadown
/citadown
UTF-8
15,003
2.671875
3
[]
no_license
#!/usr/bin/env ruby # == Synopsis # This is a simple CLI utility to download (BibTex) citations # of known authors from DBLP. # # == Usage # citadown [options] # # Options: # -h, --help Display this help message # -V, --version Display the version # -v, --verbose Verbose output # -...
true
7eb53000c9448ee4735267c0da968b140d61efc0
Ruby
keydunov/maglev
/lib/maglev/support/transformer.rb
UTF-8
1,236
2.6875
3
[]
no_license
module Maglev module Support class Transformer # Maglev::Transformer.to(NSString) do |value, reversed| # end def self.to(klass, params = {}, &transform_value) if !transform_value || ![1,2].member?(transform_value.arity) raise Maglev::Error::BlockRequiredError, "Need to include...
true
4cc486720c9ed05b55b3d836478d9b8e95c10de7
Ruby
pesekvik/MI-RUB
/cviceni_3_ukol.rb
UTF-8
3,066
3.453125
3
[]
no_license
class Graph attr_reader :number_of_vertices def initialize(number_of_vertices) @number_of_vertices = number_of_vertices @vertices = Array.new @number_of_vertices.times{|i| @vertices[i + 1] = Vertex.new(i + 1) #start index with 1 } end def get_vertex(pos) return @vertices[pos]; end def bfs(start) q...
true
8523e741d34535183dd3913c12ae9ce515b78262
Ruby
sbetack/phase-0-tracks
/databases/simplify_radicals/sqlite3_file.rb
UTF-8
1,157
2.90625
3
[]
no_license
########################makes the database table require_relative 'simplify_radicals' require 'sqlite3' db = SQLite3::Database.new("simplify_rads.db") create_table_cmd = <<-SQL CREATE TABLE IF NOT EXISTS simplifying_radical_problems( id INTEGER PRIMARY KEY, problem VARCHAR(255), solution VARCHAR(255), leve...
true