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
cf7f859af4add615dc13269890ce60267f673aaf
Ruby
ctram/chess
/lib/board.rb
UTF-8
3,235
3.8125
4
[]
no_license
require_relative 'pieces' require 'byebug' class Board attr_accessor :grid def initialize(fill_board = true) make_starting_grid(fill_board) end def [](pos) x, y = pos unless on_board?(pos) raise "invalid position" end @grid[x][y] end def []=(pos, piece) x, y = pos unles...
true
3e7f996f89f49977bf514ad184ac3d5a7bf87e71
Ruby
kdonovan/searchbot
/lib/searchbot/sources/website_properties/listing_parser.rb
UTF-8
1,245
2.59375
3
[ "MIT" ]
permissive
class Searchbot::Sources::WebsiteProperties::ListingParser < Searchbot::Generic::ListingParser parses :identifier, :link, :title, :price, :cashflow, :revenue, :teaser, :state def identifier if match = doc.at('.listing-number')&.text&.match(/\((\d+)\)/) match[1] end end def link title_node['...
true
5694ac679012b855aa926e30fc856a40037db669
Ruby
brandonc/attr_injected
/spec/lib/attr_injected_spec.rb
UTF-8
2,393
2.53125
3
[]
no_license
# frozen_string_literal: true require "spec_helper" RSpec.describe AttrInjected do class ExampleAttrInjected include AttrInjected attr_injected(:a_required_field, instance_accessor: true) attr_injected(:an_optional_field, instance_accessor: true, required: false) attr_injected(:a_defaulted_field, in...
true
233cd3bc834e3d36c2e31f67a0b16127206d0bad
Ruby
joemsak/vending-machine
/lib/vending_machine/change_dispenser.rb
UTF-8
382
2.515625
3
[ "MIT" ]
permissive
module VendingMachine class ChangeDispenser def dispense_balance(change_due) dispense_coins(change_due.in_coins) dispense_bills(change_due.in_bills) end def dispense_coins(amount) # use the appropriate low-level electronics API here end def dispense_bills(amount) # use th...
true
0dbeaeadb6618ce80a9f5f4075537f6c8f47832c
Ruby
cadolmb/Brick-Breaker
/paddle.rb
UTF-8
536
3.171875
3
[]
no_license
class Paddle def initialize @img = Gosu::Image.new('bin/paddle.png') @x = WIDTH / 2 - @img.width / 2 @y = HEIGHT * 0.9 @step = 7.5 end def x; @x end def y; @y end def w; @img.width end def h; @img.height end def move(s) case s when "left" @x -= @step when...
true
ae81e918d0bc3d98bf67a0a724d27a40e4eb046b
Ruby
choria-io/vagrant-demo
/environments/production/modules/hocon/spec/unit/puppet/type/hocon_setting_spec.rb
UTF-8
3,345
2.6875
3
[ "Apache-2.0" ]
permissive
require 'puppet' require 'puppet/type/hocon_setting' describe Puppet::Type.type(:hocon_setting) do let(:resource) do Puppet::Type.type(:hocon_setting).new( title: 'hocon setting', path: '/tmp/hocon.setting', setting: 'test_key.master', value: 'value', type: 'text', ) end it ...
true
2f97f0c788d16cf648f7290ccbb5f0909fcea059
Ruby
cheezenaan/procon
/atcoder/abc055/b.rb
UTF-8
81
2.953125
3
[]
no_license
n = gets.to_i m = 10 ** 9 + 7 puts 1.upto(n).inject(1) { |r, i| r = r * i % m }
true
9732c5b40501b7d49547984773f16c48b2fe9915
Ruby
SebastianN97/first-ruby
/hello_world.rb
UTF-8
90
3.171875
3
[]
no_license
names = ["Sebastian", "Jenny", "Sara"] names.each do |name| puts "Hello #{name}" end
true
07d76c2de40738cfa49d2cb293db57aea2b2bb90
Ruby
timhabermaas/Mima
/lib/crazy_number.rb
UTF-8
334
3.640625
4
[]
no_license
class CrazyNumber def initialize(number, bits = 32) @number = number & (2**bits - 1) @bits = bits end def to_i @number end def +(other) CrazyNumber.new(@number + other.to_i, @bits) end def -(other) CrazyNumber.new(@number - other.to_i, @bits) end def coerce(other) [self, ot...
true
4b59bbe6f4ef06ee80b7d8b0e8d36f511eb92a60
Ruby
miguelms95/gradient
/lib/gradient/opacity_point.rb
UTF-8
240
2.859375
3
[ "MIT" ]
permissive
module Gradient class OpacityPoint attr_reader :opacity, :location def initialize(location, opacity) @location, @opacity = location, opacity end def <=>(other) self.location <=> other.location end end end
true
ffa84bd22bf8ba0988cfd8d97d48aead2553eb35
Ruby
dawsonandrews/services-user-auth
/lib/user_auth/password_verifier.rb
UTF-8
304
2.578125
3
[ "MIT" ]
permissive
require "bcrypt" module UserAuth class PasswordVerifier def initialize(digest) @bcrypt = BCrypt::Password.new(digest) rescue BCrypt::Errors::InvalidHash @bcrypt = nil end def verify(plaintext) return false unless @bcrypt @bcrypt == plaintext end end end
true
f1d3c6e22294ab4e48aa468beeadb61f6d5f7e67
Ruby
nanjakkun/project-euler-ruby
/src/001-100/010.rb
UTF-8
306
3.53125
4
[]
no_license
# frozen_string_literal: true # # https://projecteuler.net/problem=10 # # Summation of primes # Problem 10 # # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # # Find the sum of all the primes below two million. # require 'prime' puts (3..2_000_000).step(2).select {|n| Prime.prime?(n) }.sum + 2
true
e7167b4edcaac8b460617072a576a5618098c104
Ruby
denvolchkevich/GeekBrains_Ruby
/fifth_lesson/Winery/winery/user.rb
UTF-8
227
3.203125
3
[]
no_license
require_relative 'calculate_years' class User include CalculateYears def initialize(name, date_of_birth) @name = name @date = Date.parse date_of_birth end def to_s "#{@name} - Date: #{@date}" end end
true
d1e259c6b7697edcad7930ee9cf4b75431e0a20c
Ruby
conr/covoid19-api-ruby-wrapper
/lib/covid19.rb
UTF-8
2,485
2.6875
3
[]
no_license
# frozen_string_literal: true require 'http' # Ruby wrapper for https://covid19api.com/. class Covid19 BASE_URL = 'https://api.covid19api.com'.freeze STATUSES = %w[confirmed recovered deaths].freeze class << self def info serve_request('') end # Warning: returns 10MB of data - use with cauti...
true
cad55fabc9ea0c40587734da7dec3ac45b4c7f04
Ruby
ankitbarak/interview-cake
/007_temperaturetracker.rb
UTF-8
2,171
4.5
4
[]
no_license
# TODO: # Write a class TempTracker with these methods: # 1. insert() - records a new temperature # 2. get_max() - returns the highest temp we've seen so far # 3. get_min() - returns the lowest temp we've seen so far # 4. get_mean() - returns the mean of all temps we've seen so far # 5. get_mode() - returns a mode of a...
true
5edfce79bd4036ca167ead52f6122cf2d2586d6d
Ruby
itggot-Bill-Falk/standard-biblioteket
/lib/is_empty.rb
UTF-8
256
3.625
4
[]
no_license
# str - the string to be looked upon # # Examples # is_empty("") #=> true # is_empty("hej hopp") #=> false # # Return true or false def is_empty(str) if str == "" output = true else output = false end return output end
true
7cb2e04a90a122478d090429bd2ee5759ef54d21
Ruby
nathankleyn/advent-of-code-2015
/ruby/spec/adventofcode/day_4/part_1_spec.rb
UTF-8
561
2.625
3
[ "MIT" ]
permissive
require 'spec_helper' require 'adventofcode/day_4/part_1' RSpec.describe(AdventOfCode::Day4::Part1) do describe('#run') do let(:challenge_input) { load_fixture('day_4.txt') } it('returns the correct answer for example one') do expect(subject.run('abcdef')).to eql(609_043) end it('returns the ...
true
87ad01fcfdb9e42ac38231fd372faf3cac1dc624
Ruby
hankeliu2015/badges-and-schedules-nyc-web-100818
/conference_badges.rb
UTF-8
848
3.6875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def badge_maker(name) "Hello, my name is #{name}." end def batch_badge_creator(attendees) counter = 0 multi_message = [] while counter < attendees.length multi_message.push("Hello, my name is #{attendees[counter]}.") counter += 1 end multi_message end def assign_rooms(attendees) counter = 0 m...
true
2e28ac559c70f7020607fcd17292b4fd8e492195
Ruby
sdabroski/W2D1-actual
/chess/Board.rb
UTF-8
1,328
3.65625
4
[]
no_license
require_relative "Piece.rb" require_relative "Display.rb" class Board attr_accessor :grid def initialize @grid = Array.new(8) {Array.new(8)} self.place_pieces end def place_pieces (0..7).each do |i| (0..7).each do |j| if i < 2 || i > 5 @grid[i][j] = Piece.new([i,j]) ...
true
0d67ec397fdfb033555a0a596333f5b287f80f44
Ruby
AnnemarieKohler/takeaway-challenge
/lib/takeaway.rb
UTF-8
1,269
3.296875
3
[]
no_license
class TakeAway attr_reader :basket, :total def initialize(dish_class=Dish, order_confirmation_class=OrderConfirmation) @dish_class = dish_class @order_confirmation_class = order_confirmation_class.new @basket = [] end def list_menu menu = {"Bratwurst in a bun" => 2.49, "Bockwurst in a ...
true
38df0a1fafff07481d640957ff0f3086a15a8bf1
Ruby
susutou/Soundmap
/app/models/sound.rb
UTF-8
948
2.53125
3
[]
no_license
# == Schema Information # # Table name: sounds # # id :integer not null, primary key # title :string(255) # description :text # location :string(255) # path :string(255) # username :string(255) # created_at :datetime not null # updated_at :datetime not null...
true
833b6b5ff1bf6dd34d0ffe7523dce6184b36fd00
Ruby
code4tots/aa
/2014-08-08/knights.rb
UTF-8
1,185
3.5625
4
[]
no_license
require 'set' require_relative 'tree_node' class KnightPathFinder attr_reader :root def initialize start @start = start @visited_positions = Set.new end def build_move_tree @root = PolyTreeNode.new(@start) queue = [@root] @visited_positions = [@start].to_set until queue.empty? ...
true
bdd29d191943fbdf2ce77658518eceace10aa0f2
Ruby
joesus/recursion-exercises
/recursion_exercises.rb
UTF-8
1,131
4.21875
4
[]
no_license
require 'pry' # Write a recursive function that computes the sum of all numbers from 1 to n, where n is given as parameter. # return the sum 1+ 2+ 3+ ...+ n def sum(int=0, n) return int if n == 0 sum(int += n, n-1) end # Write a recursive function that finds and returns the minimum element in an array, # where t...
true
9fad76bbbb0c7dfada9bcd6705217e260a32d01c
Ruby
anishphophaliya1021/sentence_reversal
/sentence_reversal.rb
UTF-8
1,120
3.390625
3
[]
no_license
def reverseSentences(filename) file = File.open(filename, "r") @full = String.new while(line = file.gets) @word = line.split(/ /) @sentence = Array.new i = 0 @para = String.new @sentence[i] = String.new @word.each do |w| unless(w == nil) w.strip! w.downcase! if(w.match(/[.]/))...
true
6a7277cf96c39db304fb338731b63baa0250100b
Ruby
SampsonCrowley/project_cli_connect_four
/spec/player_spec.rb
UTF-8
551
2.953125
3
[]
no_license
require 'rspec' require_relative '../lib/player' describe Player do describe "piece" do it "should start as nil" do expect(Player.new.piece).to be_nil end it "should be able to get and set a piece" do player = Player.new player.piece = 'X' expect(player.piece).to eq('X') ...
true
487da91f6cfca41454ff096d0c380eaeb5288cf2
Ruby
PavelSher09/Black_jack
/main.rb
UTF-8
2,104
3.75
4
[]
no_license
require_relative 'deck' require_relative 'card' require_relative 'game' require_relative 'gamer' require_relative 'bank' require_relative 'main' class Main attr_accessor :name attr_reader :game, :gamer, :cards, :winner def create_game puts 'Input your name: ' @name = gets.strip @game = Game.new(name...
true
4325cc84860f10a1f6bcb992abf855d3a13c7718
Ruby
Hammadk/rails_auto_i18n
/lib/auto_i18n.rb
UTF-8
1,723
2.578125
3
[]
no_license
$LOAD_PATH.unshift(File.dirname(__FILE__)) require "rubygems" require "nokogiri" require "auto_18n/uniquify_id" require "auto_18n/yml_path_finder" # Usage: ruby i18n_helper <directory_with_views> module AutoI18n extend UniquifyID extend YMLPathFinder BLACK_LIST = %w[ script ] def self.parse_views(views_dir) ...
true
39925c1a488d15e1f82ac0a405c06af125965e4c
Ruby
JaeWoongHwang/ruby_training
/basic/hello.rb
UTF-8
155
2.828125
3
[]
no_license
# puts "Hello, World!" def hello(names) names.each do |name| puts "HELLO, #{name.upcase}" end end rubies = ['MRI', 'jruby', 'rubinius']
true
68d3482c9726ffaaca9df95e0236f80ee326a414
Ruby
seek4science/seek
/app/helpers/work_groups_helper.rb
UTF-8
2,142
2.515625
3
[ "BSD-3-Clause" ]
permissive
module WorkGroupsHelper def work_group_select_choices WorkGroup.all.map { |wg| [wg.project.title + ' at ' + wg.institution.title, wg.id] } end WorkGroupOption = Struct.new(:id, :institution_name) class ProjectType attr_reader :project_name, :options, :project, :editable attr_writer :options de...
true
c378f2ddcb4196b61e3a2d97a6a21c81ace10d98
Ruby
innervisions/challenges
/medium_challenges/simple_linked_list.rb
UTF-8
1,202
3.609375
4
[]
no_license
class Element attr_reader :datum, :next def initialize(datum, next_el = nil) @datum = datum @next = next_el end def tail? @next.nil? end end class SimpleLinkedList attr_reader :head def initialize @head = nil end def push(item) @head = Element.new(item, @head) end def pop...
true
0445732d9230d333d5516df769d90c463cb0b2c0
Ruby
dmastylo/PayWithMe
/app/pdfs/event_pdf.rb
UTF-8
3,595
2.515625
3
[]
no_license
class EventPdf < Prawn::Document # Initializes the document def initialize(event, view) super() @event = event @view = view font_families.update( "Lato" => { bold: "#{Rails.root}/app/assets/fonts/Lato-Bold.ttf", normal: "#{Rails.root}/app/assets/fonts/Lato-Regular.ttf" ...
true
c4aa658f905157ab4186bdfa9873d4e35fe845ac
Ruby
kkristof93/AoC-2017
/Day-16/day16-part2.rb
UTF-8
871
3.28125
3
[]
no_license
moves = [] File.open('input.txt') do |file| line = file.gets moves = line.split(',') end programs = *('a'..'p') def dance(programs, moves) moves.each { |move| case move[0] when 's' num = move[1..-1].to_i a = programs[-num..-1] b = programs[0..(-num - 1)] programs = a + b wh...
true
fc5b2fa72e16d89391bf74fbeefc9e48d0523a27
Ruby
OneCuteLiz/sinatra-project-class-reg
/app/helpers/helpers.rb
UTF-8
273
2.625
3
[]
no_license
class Helpers def self.current_user(session) User.find_by(id: session[:user_id]) end def self.is_logged_in?(session) !!session[:user_id] # :user_id will be nil and thus falsey if you haven't logged in # !!turns falsey values to 'false' end end
true
f63214f1f0e9572d0f4180e128664807ad323785
Ruby
penapono/ciner
/app/models/studio.rb
UTF-8
980
2.59375
3
[]
no_license
# frozen_string_literal: true class Studio < ActiveRecord::Base include Searchables::Studio # Associations belongs_to :city belongs_to :state belongs_to :country # Validations validates :name, presence: true # Delegations delegate :name, to: :city, allow_nil: true, prefix: true deleg...
true
29578e6003a59a25c66e2cb8a429ad423c07de2e
Ruby
that-jpg/fibonacci_ruby
/fibonacci.rb
UTF-8
389
3.765625
4
[]
no_license
def get_fibonacci( number ) factor1 = 0 factor2 = 1 factor3 = factor1 + factor2 i = 3 puts "#{factor1}" puts "#{factor2}" until i > number factor1 = factor2 factor2 = factor3 factor3 = factor1 + factor2 puts "#{factor3} " i = i + 1 end end print "what number of fibonacci do you w...
true
d7f3f63cccdd779731d290edc874be9c434c7fa8
Ruby
mteam/awesome
/build.watchr
UTF-8
310
2.734375
3
[]
no_license
require 'date' def run command puts "[#{Time.now.strftime("%R")}] #{command}" system command puts "" end def make what = nil command = ['make'] command << what.to_s unless what.nil? command = command.join " " run command end watch('.*\.coffee') { |md| make }
true
430e3936c07a34d44bf71c44baa0e03573cf0de7
Ruby
ctoneal/bfrb
/lib/bfrb/interpreter.rb
UTF-8
3,042
3.6875
4
[]
no_license
require File.expand_path(File.join(File.dirname(__FILE__), "memory.rb")) module BfRb # interprets brainfuck code class Interpreter attr_reader :program_counter, :memory_counter attr_accessor :input_stream, :output_stream # initialize the interpreter def initialize @memory = Memory.new initialize_en...
true
5c6183ba33a1d9e02640349c38440fa045889793
Ruby
toddt67878/parsing_a_string_with_multiple_matches
/parsing_a_string_with_multiple_matches.rb
UTF-8
653
3.03125
3
[ "MIT" ]
permissive
require 'rspec' string_array = [ "Web IconHTML & CSS100%", "Command LineLearn the Command Line100%", "Ruby IconRuby50%", "Rails IconLearn Ruby on Rails100%", "Git IconLearn Git100%", "SassLearn Sass20%", "JQuery IconjQuery1%", "Angular JSLearn AngularJS 1.X100%", "Javascript IconLearn JavaScript55%" ...
true
03d846e86a0d8705de56b14955585aff48ad60b3
Ruby
GetJobber/prawnto
/lib/prawnto/template_handlers/renderer.rb
UTF-8
2,249
2.53125
3
[ "MIT" ]
permissive
require "prawnto/template_handlers/partials" module Prawnto module TemplateHandlers class Renderer include Partials def initialize(view_context, calling_object = nil) @view_context = view_context @calling_object = calling_object set_instance_variables @pdf = Prawn::Do...
true
57bd6be27c773a71e07d6cfd0d6038aa88130b6e
Ruby
kylerippey/cah
/test/deck_test.rb
UTF-8
1,265
3.046875
3
[ "MIT" ]
permissive
require 'test_helper' class DeckTest < MiniTest::Unit::TestCase def setup @deck = Cah::Deck.new(File.expand_path("../../cards/white.yml", __FILE__)) end def test_can_load_deck_from_yaml assert @deck.count > 0, "should have loaded cards from yaml" end def test_cards_may_be_drawn_and_discarded o...
true
778c47e812c1a14736eb9b1d69a266c1047ae5c2
Ruby
CourtneeM/Exercises-RB101-RB109-Small-Problems
/Easy_2/tip_calculator.rb
UTF-8
1,976
4.6875
5
[]
no_license
def tip_calculator() puts "=> What is the bill?" bill_subtotal = gets.chomp puts "What is the tip percentage?" tip_percentage = gets.chomp total_tip = bill_subtotal.to_f * (tip_percentage.to_f * 0.01) total_bill = bill_subtotal.to_f + total_tip puts "The tip is $#{total_tip} \nThe total is $#{total_bil...
true
dcd123dbc26b100351964e8191ef630e03be8538
Ruby
vickytsang/bloodsugarsim
/bin/bloodsugarsim.rb
UTF-8
288
2.6875
3
[]
no_license
require 'io/console' require_relative '../lib/bloodsugarsimapp.rb' if ARGV.length > 0 myApp = BloodSugarSimApp.new for i in 0 ... ARGV.length file_name = ARGV[i] puts "*******input file #{file_name}" myApp.parse_csv(file_name) end myApp.run done = STDIN.getch end
true
0c8f7f7e9d52198ce9bcd1ed184012077ab320e1
Ruby
ryosuke-endo/open_bd
/lib/open_bd/response.rb
UTF-8
354
2.65625
3
[ "MIT" ]
permissive
module OpenBD class Response def initialize(response) @response = response end def body @response.body end def empty? @response.body.all?(&:nil?) end def resources body.map do |source| OpenBD::Resource.new(source) end end def status @...
true
c14fa7b38e7da8d777778292c35ada48f29eb36f
Ruby
ClaFiore/Mod4BackEnd
/app/models/restaurant.rb
UTF-8
736
2.640625
3
[]
no_license
class Restaurant < ApplicationRecord has_many :tables def availableHours( date, party_size) openHours = [10, 11, 12, 13, 14, 17, 18, 19, 20, 21] availableHours =[] availableTables = [] tables = self.tables.where("seats >= #{party_size.to_i}")#5 tables op...
true
6bc4ee30f87dd7ef94e2de461c348504fb19870b
Ruby
Ruhinas/FamilyTree-w-AR-Ruby
/family_tree.rb
UTF-8
4,872
3.25
3
[]
no_license
require 'bundler/setup' require 'pry' Bundler.require(:default) Dir[File.dirname(__FILE__) + '/lib/*.rb'].each { |file| require file } database_configurations = YAML::load(File.open('./db/config.yml')) development_configuration = database_configurations['development'] ActiveRecord::Base.establish_connection(developmen...
true
4ce73ec81369234e94217cfc14e2f12430cde68e
Ruby
devalot/coders-src
/ruby/print_args.rb
UTF-8
71
3.21875
3
[]
no_license
ARGV.each_with_index do |arg, i| puts("Argument #{i} is #{arg}") end
true
fa75ebcd3fc721fc30198e30b2c60b645c0ae481
Ruby
drransom/App-Academy-unfinished-projects
/games/war/lib/deck.rb
UTF-8
853
3.609375
4
[]
no_license
require_relative 'card' class Deck include Enumerable attr_reader :cards def self.fresh_deck cards = [] Card::RANKS.each do |rank| Card::SUITS.each do |suit| cards << Card.new(rank, suit) end end Deck.new(cards) end def self.two_decks complete_deck = Deck.fresh_deck ...
true
36405c72ee6974173139612a15ea190909ad4c54
Ruby
ander/habits
/lib/habits/whip.rb
UTF-8
984
2.78125
3
[ "BSD-3-Clause" ]
permissive
require 'habits/habit' module Habits module Whip extend self @@transitions = {} @@ticks = [] # Add block to be executed when status changes to given status. # A habit which changes to this status is passed to the block. def on(status, &blk) raise "No block given" if blk.nil? ...
true
c2b743f0d7ea3e703262b6c88716c9094d664ce5
Ruby
alx/feevy
/lib/texty_helper.rb
UTF-8
4,890
2.765625
3
[]
no_license
module TextyHelper def self.append_features(base) # :nodoc: super base.extend ClassMethods end module ClassMethods def read_encoding(file) logger.debug "----read_encoding---" logger.debug "----" charset = file.charset.gsub("\"", "") logger.debug "file charset: #{charset}"...
true
fe7e87021e5d92b6162e3ae30096d85c54954e3f
Ruby
DeBillieJoe/ruby-retrospective-3
/solutions/04.rb
UTF-8
2,328
2.984375
3
[]
no_license
module Asm module Instructions def mov(destination_register, source) @registers[destination_register] = get_actual_value(source) end def inc(destination_register, value = 1) @registers[destination_register] += get_actual_value(value) end def dec(destination_register, value = 1) ...
true
932cca358610b286b7a60ba6c37111cf299ff5f3
Ruby
SpeciesFileGroup/taxonworks
/lib/batch_load/import/descriptors/qualitative_interpreter.rb
UTF-8
2,270
2.53125
3
[ "NCSA", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module BatchLoad class Import::Descriptors::QualitativeInterpreter < BatchLoad::Import # needed? attr_accessor :descriptors attr_accessor :character_states # @param [Hash] args def initialize(**args) @descriptors = {} @character_states = {} super(**args) end # @return ...
true
d507023fa74b061430a24427729e48cb2a25ad00
Ruby
Visiona/learn_ruby
/05_silly_blocks/silly_blocks.rb
UTF-8
200
3.578125
4
[]
no_license
def reverser yield.split(" ").each {|word| word.reverse!}.join(" ") end def adder(x=1) yield + x end def repeater(x=1) if block_given? while x > 0 x -=1 yield end end end
true
76791d95c6badccc80c17aa48bc0edfb85f1d6ae
Ruby
RBGeomaticsRob/lrthw
/ex4.rb
UTF-8
1,002
4.0625
4
[]
no_license
# Makes the variable 'cars' equal to 100. cars = 100 # Makes a new variable equal to a floating point number space_in_a_car = 4.0 # Makes a new varaiable equal to 30 drivers = 30 # Makes a new variable equal to 90 passengers = 90 # Makes a new variable to hold the result of minus'ing one previous variable from another....
true
c0cb7eeb1c6ecb209c0b613a240a27df6b6f314f
Ruby
Salamangkero/project_euler
/0015.rb
UTF-8
246
3.296875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby grid = Array.new(21) { Array.new(21) { 0 } } 21.times { |i| grid[i][0] = grid[0][i] = 1 } (1..20).each { |row| (1..20).each { |column| grid[row][column] = grid[row - 1][column] + grid[row][column - 1] } } puts grid[20][20]
true
f14fa9a3cdb1efee856800533d6dc93e5a6b6713
Ruby
cylon-v/jet_set
/lib/jet_set/entity_mapping.rb
UTF-8
2,340
3.109375
3
[ "MIT" ]
permissive
require 'jet_set/reference' require 'jet_set/collection' module JetSet # Entity mapping is an element of JetSet mapping definition, see +JetSet::Mapping+. # Should be instantiated by method +entity+ of +JetSet::Mapping+ instance. class EntityMapping attr_reader :references, :collections, :fields, :type, :dep...
true
d0b3a83781d76f457a1e1f9efd5e689722487962
Ruby
shokai/gyazz-markup
/test/test_gyazz-markup.rb
UTF-8
4,390
2.65625
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/test_helper.rb' class TestGyazzMarkup < MiniTest::Unit::TestCase def setup @gm = GyazzMarkup::Markup.new end def test_markup_image img_url = "http://example.com/foo.png" assert @gm.markup_image("[[#{img_url}]]") == "<a href=\"#{img_url}\"><img src=\"#{img_url}\"><...
true
04fab355cf151f7b231e69ee484ef0057a2ed38e
Ruby
hybridgroup/capable
/lib/capable/source_parser.rb
UTF-8
9,340
2.609375
3
[]
no_license
module Capable # This is the source parser. It handles cloning repositories, generating files, # and everything needed for the Capable.load (namely generating sha2, marking # the location and ref) class SourceParser extend Forwardable def_delegators :@sources, :git def initialize(contents) ...
true
0df6d413cf4f8bdc7690437792c0481efb349d6b
Ruby
tbierwirth/enigma
/lib/rotate.rb
UTF-8
517
3.8125
4
[]
no_license
class Rotate def initialize() @chars = ("a".."z").to_a << " " end def find_character_index(char) @chars.index(char.downcase) end def get_character(index) @chars[index] end def shift_character(char, offset, unshift = false) if @chars.include?(char.downcase) index = find_character_...
true
d4cfe6a1c76db0a6d321815353f6a5fa86c70e13
Ruby
ShunichiTanaka/StockManagement
/app/models/google_chart.rb
UTF-8
944
2.734375
3
[]
no_license
class GoogleChart def initialize @data_table = GoogleVisualr::DataTable.new end def line_chart(data, flag) line_types case flag when true data.each_with_index do |d, count| @data_table.set_cell(count, 0, d["date"].to_s) @data_table.set_cell(count, 1, d["close"]) @dat...
true
d6ad95d1b82f7e2e6ad2863393a726f81c906221
Ruby
angelmore/ISW2
/02-Numeros/Ejercicio/fraccion.rb
UTF-8
2,132
3.5
4
[]
no_license
require './numero' class Fraccion < Numero def initialize(numerador,denominador) @numerador = numerador @denominador = denominador end def numerador @numerador end def denominador @denominador end def es_cero false end def es_uno false end def == un_objeto (un_ob...
true
ba52eca0e5a147c5ca6e7a30e2b5e2ac69b15e70
Ruby
18F/identity-lambda-functions
/lib/audit/github.rb
UTF-8
10,924
2.578125
3
[]
no_license
# frozen_string_literal: true require 'json' require 'logger' require 'yaml' require 'aws-sdk-secretsmanager' require 'aws-sdk-ses' require 'octokit' module IdentityAudit # Auditor of github teams and membership # # This script requires a Github access token with the `read:org` scope on the # organization y...
true
17401730a54d41381d2b40fcc4cfe5d3c37214e7
Ruby
jtdavis247/BLOC
/spec/support/utilities.rb
UTF-8
161
2.578125
3
[]
no_license
def full_title(page_title) base_title = "Learn Game Development Now" if page_title.empty? base_title else "#{base_title} | #{page_title}" end end
true
bf2226005b6a44a1578f2e48081bdc8ee673143d
Ruby
burt/sentry
/lib/sentry/rails/extensions.rb
UTF-8
363
2.84375
3
[ "MIT" ]
permissive
class Class def superclass_count if @count.nil? @count, current = -1, self until (current = current.superclass).nil?; @count += 1; end end @count end end class Array def max_by_field(field) return [] if empty? max = max { |a, b| a.send(field) <=> b.send(field) } select { |i| i...
true
d49ad92cf2550f1cb92de302aec35e5533f5ec68
Ruby
wadinj/SSB-Tournament-Manager
/app/models/calendar.rb
UTF-8
3,712
2.75
3
[]
no_license
require 'icalendar/tzinfo' class Calendar class << self def full_calendar_events(current_user) tournaments = Tournament.for_calendar.includes(:players) tournaments.map do |tournament| full_calendar_event(tournament, current_user) end.to_json end def full_calendar_event(tournam...
true
62c1a08a493002188b3249f672cd774c4f283e31
Ruby
AndreiMotinga/terminal
/terminal.rb
UTF-8
322
3.140625
3
[]
no_license
require_relative "item" class Terminal attr_reader :pricing_info, :items def initialize(pricing_info) @pricing_info = pricing_info @items = Hash.new(0) end def scan(item) items[item.to_sym] += 1 end def total items.map { |i| Item.new(pricing_info, i).total } .reduce(:+) end en...
true
045fb06313440dc5bb6ddf05d14542042501f99e
Ruby
Sproodigy/help_for_job
/app/models/rave.rb
UTF-8
1,732
2.625
3
[]
no_license
class Rave < Prawn::Document include ActionView::Helpers::NumberHelper def print_rave font_families.update( "DejaVuSans" => { normal: "#{Rails.root}/app/assets/fonts/DejaVuSans.ttf", bold: "#{Rails.root}/app/assets/fonts/DejaVuSans-Bold.ttf", italic: "#{Rails.root}/app/assets/fonts/DejaVuSans...
true
69dfbf27c652ed574d45bafd6e595af0e5429fcd
Ruby
fffxc2/multitwitch
/chatbot.rb
UTF-8
3,503
2.671875
3
[]
no_license
SCRIPT_NAME="chatbot" SCRIPT_AUTHOR="fffxc2" SCRIPT_VERSION="0.0.2" SCRIPT_DESCRIPTION="Sets up a response to ! based commands. Primarily for use with live configured twitch channels to return a multitwitch link" require 'rubygems' require 'twitch-api' module Command def strip_leading self[1..-1] end def i...
true
86e9684e186542f5e18daf57e5ff30a122e933b3
Ruby
HenriqueSaKi/Curso-Automacao-Testes-Ruby
/Cucumber/CucumberTest/tests/features/step_definitions/cenario.rb
UTF-8
906
3.046875
3
[]
no_license
Dado('eu tenha {int} laranjas.') do |valor1| # Dado('eu tenha {float} laranjas.') do |float| @laranjas = valor1 # Write code here that turns the phrase above into concrete actions end Quando('eu como {int} laranjas.') do |valor2| # Quando('eu como {float} laranjas.') do |float| @comer = valor2 # Write c...
true
2c9f61ff0683dd08884d48a7b444bc4e5605a910
Ruby
renatolond/cake_monday_bot
/app/services/draw_candidate_service.rb
UTF-8
1,541
2.734375
3
[]
no_license
# frozen_string_literal: true require_relative "../persistence/setup" class TooFewCandidates < StandardError; end class DrawCandidateService def draw(number = 2) candidates = [] while candidates.size < number available_candidates = candidates_repository.available if available_candidates.to_a.em...
true
99380f173fb5698f5b72ef8b68acffb8b331335f
Ruby
aagooden/minedmindskata
/minedmindskata_function2.rb
UTF-8
425
3.53125
4
[]
no_license
def array_create() minds = (1..100).to_a return minds end def replace_nums() mindsarray = array_create() for x in (0...mindsarray.length) do num = mindsarray[x] if num % 3 == 0 && num % 5 == 0 mindsarray[x] = "mined minds" elsif num % 3 == 0 mindsarray[x] = "mined" elsif num % 5 == 0 mindsarray[x]...
true
c6ab77043322f325de4940919a61f2328555432e
Ruby
Wetshivictor2018/entrainement_pratique_ruby
/exercice14.rb
UTF-8
132
3.5625
4
[]
no_license
puts "Veuillez saisir votre numéro : " nbr = gets.chomp.to_i nbr.times do nbr = nbr -1 puts "-----" puts "numéro #{nbr}" end
true
1ba4a285b20b4464f80a5fa9732e49db3199bfb6
Ruby
eugenpirogoff/acli
/lib/acli/configuration.rb
UTF-8
1,086
2.625
3
[ "MIT" ]
permissive
require 'yaml' class Configuration def initialize(path) @path = path @config = YAML.load(default_config_string) end def load_from_file if File.exist?("#{path}/.aclirc") @config = YAML.load_file(File.expand_path("#{path}/.aclirc")) puts "config loaded from #{path}" elsif File.exist?("...
true
521a92d3fc91f62239ff1aaa019258def674cd8c
Ruby
cassar/skrol_basic
/lib/program/calculate_wss.rb
UTF-8
3,198
2.796875
3
[]
no_license
# Calculates the Word Similarity Scores (WSS) for each word in a given array # of words, word arrays should be given in phonetic form. def compile_wss_script(content_manager, wts_scores_obj) target_words, base_words = content_manager.phonetic_words tar_id_to_base_entry = derive_tar_id_to_base_entry(base_words, cont...
true
11c44e755bfcf010baa551b7a7bbe77e79c05e5d
Ruby
intenex/A02-Go-Fish-Practice-Assessment
/skeleton/spec/04_game_spec.rb
UTF-8
5,493
3.453125
3
[]
no_license
require '00_card' require '04_game' describe Game do describe '#initialize' do it 'starts with a deck' do game = Game.new expect(game.deck).to be_a(Deck) end it 'starts with a full deck' do game = Game.new expect(game.deck.count).to eq(52) end it 'shuffles the deck' do ...
true
edd275b1b05983ace526671f944294e1cb8cab33
Ruby
derekle/oo-tic-tac-toe
/lib/tic_tac_toe.rb
UTF-8
4,096
3.984375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe attr_accessor :turn_count, :current_player @@index @@winner = nil WIN_COMBINATIONS = [ [0,1,2], #top horizontal [3,4,5], #middle horizontal [6,7,8], #bottom horizontal [0,3,6], #left vertical [1,4,7], #middle vertical [2,5,8], #right vert...
true
1f7ef0f7f6fdd5ab793e0dfb94072b40d2affe22
Ruby
wardymate/codewars-kata
/fizzbuzz_array/lib/Fizzbuzz.rb
UTF-8
257
3.453125
3
[]
no_license
class Fizzbuzz def fizz_buzz_custom(string_1="Fizz", string_2="Buzz", num_1=3, num_2=5) (1..100).to_a.map do |num| num % (num_1*num_2)==0 ? string_1 + string_2 : (num % num_1==0 ? string_1 : (num % num_2==0 ? string_2 : num)) end end end
true
3b55575ff08438a79b1bee7a19b612809c67a8ce
Ruby
hardpixel/tableless
/test/tableless_test.rb
UTF-8
2,136
2.625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'test_helper' class Topic < ActiveRecord::Base include Tableless has_many :messages attribute :title, :string attribute :text, :string validates :title, presence: true accepts_nested_attributes_for :messages end class Message < ActiveRecord::Base include Table...
true
998373247ab18d4c9f3c0ffc3f6aebb773a712b1
Ruby
matkuscz/est
/nokogiriCssExample.rb
UTF-8
927
2.734375
3
[ "Unlicense" ]
permissive
require 'rubygems' require 'nokogiri' require 'fastercsv' doc = Nokogiri::HTML(File.open('people.html')) contacts = [] doc.css('div.contact, div.vcard').each do |vcard| vc = {} vc['Name'] = vcard.at_css('h3').text if email_link = vcard.at_css('a.email') vc['Email'] = email_link.text end vcard.css('...
true
5e125171532f2d74c550b32d15ffae01d764fae1
Ruby
CoderNight/tampa-coder-night-002
/005/spec/scrabble_board_spec.rb
UTF-8
1,147
3.421875
3
[]
no_license
require_relative '../lib/scrabble_board' describe ScrabbleBoard do subject do board = ScrabbleBoard.new board[0,0] = 1 board[1,0] = 3 board[0,1] = 2 board[1,1] = 4 board end it "can convert itself to an array" do subject.to_a.should == [[1,3],[2,4]] end it "has a specific widt...
true
1eaf0cc4e9d31ca482795bbc1f1d6781e909d19c
Ruby
jbyrnesshay/launchschool_enrolled
/lesson_5/Practice_Problems/1.rb
UTF-8
188
3.546875
4
[]
no_license
#How would you order this array of number strings by descending numeric value? arr = ['10', '11', '9', '7', '8'] test = arr.sort do |x, y| y.to_i <=> x.to_i end puts test.inspect
true
3ac5b11060d6de96a08c8ef311f637df5aee75af
Ruby
benhawker/sorting-algorithms-ruby
/lib/bubble_sort.rb
UTF-8
688
4.03125
4
[]
no_license
## array = [1,8,5,2,5,6] ##Bubble sort def bubble_sort(array) length = array.size loop do swapped = false 0.upto(length - 2) do |i| if array[i] > array[i+1] array[i], array[i+1] = array[i+1], array[i] swapped = true end end break if swapped == false end array end ...
true
2041e68adc8fabcb1a52e1cfe3d3cb5c8b40067b
Ruby
marcwright/WDI_ATL_1_Students
/exercise_bank/ruby_rails/ruby labs/codename.rb
UTF-8
1,082
3.671875
4
[]
no_license
continue = "y" while continue == 'y' do puts "Please enter your first name." fname = gets.chomp puts "Please enter your last name" lname = gets.chomp puts "Choose between Backwards, Scramble, or Code Name." answer = gets.chomp if answer == "Backwards" puts fname.reverse + " " + lname.reverse elsif answer == "Scra...
true
445dc45a6e1e7aa7f9f157b88cc79b0499b272ec
Ruby
fourwallsstudio/ruby_stuff
/heaps/heap_sort_spec.rb
UTF-8
404
3.03125
3
[]
no_license
require_relative 'heap_sort' describe '#heap_sort' do it 'sorts an array' do arr = [9, 8, 7, 6, 5, 4, 3, 2, 1] expect(arr.heap_sort!).to eq([1, 2, 3, 4, 5, 6, 7, 8, 9]) end it 'sorts an array into a valid max heap' do skip arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] prc = Proc.new { |a, b| -1 * (a <=>...
true
b9d74069f00544ece1b1cda927345ffaca7bfd6f
Ruby
MaxfieldLewin/margic
/zones/zone.rb
UTF-8
169
2.53125
3
[]
no_license
#an abstract superclass for game zones class Zone attr_reader :contained_objects def initialize(starting_state) @contained_objects = starting_state end end
true
4da5bac2cab0535a3e811ee005644ea7731fa213
Ruby
ancaciascaiu/phase-0-tracks
/ruby/vampires.rb
UTF-8
1,836
3.984375
4
[]
no_license
###set the number of interviews puts "How many employees will be processed?" empl_nr = gets.chomp empl_nr = empl_nr.to_i ###looping through the survey for i in 1..empl_nr do ###questionnaire = questions and input puts "What is your name?" name = gets.chomp puts "How old are you?" age = gets.chomp puts "What ye...
true
793de9d2b84d20df2b1fa1f7f4e8cc11b0e3686d
Ruby
DavidMejia025/ruby-intro
/challenges/OOP/guessing-game/my_solution.rb
UTF-8
535
3.78125
4
[]
no_license
class GuessingGame def initialize(answer) @answer = answer end def guess(guess) if guess == @answer @guess = :correct elsif guess< @answer @guess = :low else @guess = :high end end def solved? if @guess == :correct true else false end end en...
true
3df0b9b15c1ce54791f9fb0635359237403d290a
Ruby
compwron/radarTranslator
/lib/items.rb
UTF-8
1,673
3.1875
3
[]
no_license
require_relative 'item' require_relative 'parser' class Items include Enumerable attr_reader :items, :file_contents @@parser = Parser.new @@valid_category_names = ["Languages", "Tools", "Techniques", "Platforms"] def initialize data_dir @data_dir = data_dir @items = get_items @file_contents = ...
true
2683d507eeb117897b850c382e903051bc607f66
Ruby
KhIgorLe/Learning
/lesson_8/main.rb
UTF-8
9,011
3.53125
4
[]
no_license
require_relative 'train' require_relative 'passenger_train' require_relative 'cargo_train' require_relative 'passenger_wagon' require_relative 'freight_wagon' require_relative 'route' require_relative 'station' require_relative 'wagon' class Main TRAIN_TYPES = { 1 => PassengerTrain, 2 => CargoTrain }.freeze MAIN_...
true
b307a50e561cf73618050110ce634e2460d8d6d5
Ruby
mn113/codewars-solutions
/ruby/matheval.rb
UTF-8
2,453
3.40625
3
[]
no_license
def calc expression p expression parts = (expression.instance_of? Array) ? expression : split(expression) parts = handle_neg_brackets(parts) while parts.include?('(') do parts = resolve_brackets(parts) end parts = cancel_negatives(parts) parts = do_division(parts) parts = do_multiplication(parts) ...
true
4373a5ac39d68e37b5b788ac3fa22495c7395a5c
Ruby
wakt/counter
/app/models/order.rb
UTF-8
2,103
2.640625
3
[]
no_license
require 'net/http' require "uri" require 'json' class Order < ActiveRecord::Base # attr_accessible :title, :body def self.all # @customers = Net::HTTP.get(URI.parse( Counter::Application.config.simplyurl + 'customers.json')) Net::HTTP.get(URI.parse( Counter::Application.config.simplyurl + 'orders.json')) en...
true
9796ea0d7df4bf95a064d5ee69d8b6af2a850ea7
Ruby
udoschneider/deepsecurity
/lib/dsc/command.rb
UTF-8
17,671
2.671875
3
[ "MIT" ]
permissive
# @author Udo Schneider <Udo.Schneider@homeaddress.de> require "progressbar" require "csv" module Dsc # This class defines an superclass for all `dsc` commands. It defines several helper methods which either define # flags, options and commands or helpers to define them. # @abstract class Command # @abst...
true
824d43b6367792a6749b95226110195041d186c8
Ruby
KarthikJagadish/LearningRuby
/freeCodeCamp.org/Ruby/1Beginnings.rb
UTF-8
686
4.40625
4
[]
no_license
# 1. puts, print and printing a simple triangle puts "Karthik" print "Hello World" puts "!" puts " /|" puts " / |" puts " / |" puts "/___|" # 2. Variables - creating containers and storing values, accessing the containers whenever needed. Such containers are called variables character_name = "John" character_a...
true
5f27faeaadf928faccd1aa9384c79e1507cd57fd
Ruby
attinore/profile
/01-Ruby/02-Flow-Array/01-Can-you-vote/lib/vote.rb
UTF-8
91
2.765625
3
[]
no_license
def allowed_to_vote?(age) if age >= 18 return true else return false end end
true
892498233daf7166db83a82dbf6e0282d2fcd55f
Ruby
aliCamargo/corporate-expenses-tracker-api
/app/services/result_service.rb
UTF-8
536
2.921875
3
[]
no_license
class ResultService def initialize( success = false, parameters = {} ) @success = success @parameters = parameters end def set_status( success ) @success = success end def set_parameters( parameters ) @parameters = parameters end def success? @success end def error? !@suc...
true
4ec58e4128334a447af61b9386561aab788e470b
Ruby
dora1405/video-store-consumer-api
/app/models/customer.rb
UTF-8
348
2.578125
3
[]
no_license
class Customer < ApplicationRecord has_many :rentals has_many :movies, through: :rentals def movies_checked_out_count self.rentals.where(returned: false).length end def movie_names movies_list = self.movies array = [] movies_list.each do |movie| array << movie.title end return ...
true
3631625977cd1301b03691fd8c30b66445d57e51
Ruby
Torgian/Ruby_Exercises
/FinalExercises/exercise_six.rb
UTF-8
213
3.046875
3
[]
no_license
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3] p numbers.uniq #non-destructive #p numbers.uniq! <--destructive #What's the difference between an array and a hash? #Has has key value pairs, and references by key
true
4aa48193b41bf1b66bbd857022f650c6044c723d
Ruby
yukiabineko/backend
/app/controllers/shopping_phone_controller.rb
UTF-8
974
2.53125
3
[]
no_license
class ShoppingPhoneController < ApplicationController def create message = '失敗。' order = Order.find_by(name: params[:name]) order.stock -= params[:num].to_i order.save user = User.find( params[:id] ) if params time = receiving( params[:time] ) shoping = user.shoppin...
true
cc3fee1cdf82bd56744eb15eff6f068efcd54a8a
Ruby
shaiguitar/gem_velocity
/lib/gem_velocity/velocitators/aggregated_velocitator.rb
UTF-8
1,366
2.59375
3
[ "MIT" ]
permissive
class AggregatedVelocitator < BaseVelocitator # TODO can probably get rid of this attr_reader :aggregated_versions # the one with the wildcard attr_reader :version # all of the ones matched, aggregated_versions attr_reader :versions def initialize(gem_name, top_level_ver) @gem_name = gem_name ...
true
5f2f6f687eae8fb38abca9f2c4f8e508f90bca08
Ruby
nataliakikuchi/Ruby_SOLID
/DIP/dependency_inversion_principle/app/linkedin_api.rb
UTF-8
402
2.640625
3
[]
no_license
require 'logger' class LinkedinApi def initialize(overrides = {}) @logger = overrides.fetch(:logger) { Logger.new(STDOUT) } end def share_story(type, duration) if type == 'foto' && duration == 0 @logger.info("Arquivo de #{type} postado com sucesso. Esse story não tem duração definida.") else ...
true
7b7ba34e9e27eefe277e2499f9121ff4bc975793
Ruby
floger/md_emoji
/lib/md_emoji/render.rb
UTF-8
1,210
2.6875
3
[ "MIT" ]
permissive
module MdEmoji class Render < Redcarpet::Render::HTML def initialize(options={}) @options = options.merge(:no_intra_emphasis => true) super @options end def paragraph(text) text.gsub!("\n", "<br>\n") if @options[:hard_wrap] "<p>#{replace_emoji(text)}</p>\n" end def list_...
true