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
4d154ebf26e79a66771692291e3c4ff0a050f5ea
Ruby
Waynexiee/My_leetcode
/spiral_matrix.rb
UTF-8
1,049
3.65625
4
[]
no_license
def spiral_order(matrix) return [] if matrix.empty? || matrix[0].empty? ceiling = 0 botton = matrix.size - 1 left = 0 right = matrix[0].size - 1 i = 0 j = 0 res = [] while left <= right && ceiling <= botton break if j > right while j <= right res << matrix[i][j] break unless j + 1...
true
18c268a5893c44839ccfccee851ceb8f26eca2f6
Ruby
sweinstein27/operators-v-000
/lib/operations.rb
UTF-8
129
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def unsafe?(speed) speed.between?(40,60) ? false : true end def not_safe?(speed) speed.between?(40,60) ? false : true end
true
19961167969bd8233ecd1eee428df3bd1d6f7992
Ruby
AddisonDean/PuttPutt
/objects/gauge.rb
UTF-8
577
2.9375
3
[ "MIT" ]
permissive
class Gauge def initialize(x, y) @x, @y = x, y @image = Gosu::Image.new('resources/images/gauge/gauge_00.png') end def determine_power(power_level) power_level = ((power_level / 10) / 1.67).round(0) if power_level < 10 power_level = "0#{power_level}" end pic_name...
true
3dbd4469037a745927aadea910f690358de289f2
Ruby
sporkmonger/addressable
/benchmark/unicode_normalize.rb
UTF-8
1,338
2.609375
3
[ "Apache-2.0" ]
permissive
# /usr/bin/env ruby # frozen_string_literal: true. require "benchmark" require_relative "../lib/addressable/idna/pure.rb" require "idn" value = "fiᆵリ宠퐱卄.com" expected = "fiᆵリ宠퐱卄.com" N = 100_000 fail "ruby does not match" unless expected == value.unicode_normalize(:nfkc) fail "libidn does not match" unless expected =...
true
10f51b065151e4afec98f93d7994983fd5b9799f
Ruby
jkim10132/procore_rails_tutorial
/01_Ruby_FizzBuzz/spec/fizz_buzz_spec.rb
UTF-8
1,541
3.734375
4
[]
no_license
require_relative "../lib/fizz_buzz.rb" describe "fizzbuzz_helper()" do it 'returns "Fizz" when the number is divisible by 3' do fizz_3 = fizzbuzz_helper(3) expect(fizz_3).to eq("Fizz") end it 'returns "Buzz" when the number is divisible by 5' do fizz_5 = fizzbuzz_helper(5) expect(fizz_5).to eq("Bu...
true
65495799fdd7633278f503dbc7bd6eecf7a142f2
Ruby
bmordan/photogrid
/lib/db.rb
UTF-8
2,236
3.03125
3
[]
no_license
require "sqlite3" require_relative "./gallery" require_relative "./search" class DB include Search def initialize @db = SQLite3::Database.new ("./db") @db.execute "CREATE TABLE IF NOT EXISTS galleries(id INTEGER PRIMARY KEY, title TEXT);" @db.execute "CREATE TABLE IF NOT EXISTS keywords(id INTEGER PRI...
true
fd8fbccede45d9b17016188e6f1e9156c461f63f
Ruby
noku/university
/PAD/Lab#2/tcp_server.rb
UTF-8
1,462
3.140625
3
[]
no_license
class TcpServer BLOCK_SIZE = 1024 attr_reader :host, :port, :tcp_server, :data, :neighbors def initialize host, port, data, neighbors @host = host @port = port @data = data @neighbors = neighbors @tcp_server = TCPServer.open(host, port.to_i) end def listener loop do Thread.star...
true
78b07da9f23568ca660132f3c65d078a77b245dc
Ruby
amb8l/tictactoe-ruby-core
/spec/tictactoe/game_engine_spec.rb
UTF-8
1,603
2.796875
3
[]
no_license
require 'tictactoe/mock_game_ui' require 'tictactoe/game_engine' require 'tictactoe/mock_player' module TicTacToe RSpec.describe GameEngine do before(:each) do @ui = MockGameUI.new @engine = GameEngine.new(@ui) end it "ends a game when the game is won" do p1 = MockPlayer.new('X', 1, 2,...
true
c58fcf38886fbbaabfb609cbba1b0f61b08ddb0f
Ruby
prrrnd/rails_language_select
/lib/rails_language_select/data_source.rb
UTF-8
446
2.53125
3
[ "MIT" ]
permissive
module RailsLanguageSelect DATA_SOURCE = {} DATA_SOURCE[:default] = lambda do |code_or_name = nil| languages = I18nData.languages(I18n.locale.to_s) if code_or_name.nil? languages.keys else if (language = languages[code_or_name.to_s.upcase]) code = code_or_name elsif (code = I1...
true
a6bee69373d407a41fa3f5e1662e5f886d4f8630
Ruby
practicingruby/compleat-testing
/lib/compleat/testing.rb
UTF-8
1,826
2.828125
3
[]
no_license
module Compleat module Testing extend self def targets @targets ||= [] end def each_test_case targets.each do |test_class| test_class.instance_methods.grep(/^test_/).each do |test_method| yield test_class, test_method end end end def run_tests ...
true
89049593dbcdd2293bd4faf0affd4cc90129f191
Ruby
OpenBEL/bel_parser
/lib/bel_parser/language/version2_0/relationships/has_members.rb
UTF-8
1,847
3
3
[ "Apache-2.0" ]
permissive
require_relative '../../version2_0' require_relative '../../relationship' module BELParser module Language module Version2_0 module Relationships # HasMembers: +A hasMembers (B, C, D)+ - The hasMembers # relationship is a special form which enables the assignment of # multiple mem...
true
41c759ec702bc25f25544ef85a3b72ce0cd9e688
Ruby
wangjoc/betsy
/test/models/order_item_test.rb
UTF-8
4,535
2.59375
3
[]
no_license
require "test_helper" describe OrderItem do let (:new_order) { Order.new( buyer_name: "Huang Shaotian", email_address: "troublingrain@glory.com", mail_address: "City Blue Rain", zip_code: "33333", cc_num: "************1111", cc_exp: 1230, cc_cvv: "***", ) } let ...
true
b29086a467416af867020002244c254ad200a489
Ruby
mame/ruby-minisat
/examples/lonely7.rb
UTF-8
6,379
3.203125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # ruby-minisat example -- lonely7.rb require "minisat" require File.dirname($0) + "/compat18" if RUBY_VERSION < "1.9.0" ############################################################################### class Digit def initialize @vars = (0..9).map { $solver.new_var } $solver << vars ...
true
dddaedece9a96355471318c3114a25d0bd22e8e1
Ruby
bigtiger/let-it-be
/lib/let_it_be.rb
UTF-8
422
2.515625
3
[ "WTFPL" ]
permissive
module LetItBe extend self def let(name, &block) define_method name do @__resources__ ||= {} @__resources__[name] ||= if block_given? instance_eval(&block) else __class_for__(name).find(params["#{name}_id"] || params['id']) end end helper_method name hid...
true
3db76dd1ce8ddb15dbf93b27a438c622464dedd1
Ruby
twyststar/Ruby_palindrome
/lib/palindrome.rb
UTF-8
207
3.171875
3
[]
no_license
class String define_method(:palindrome?) do word = self word.gsub!(/\s+/, '') word.downcase!() if word == word.reverse() "That's a palindrome" else "Nope" end end end
true
ae50ad90a80a7ad3ccc13ac1150ac2ed9c027c58
Ruby
jyoder/ultra-robo-blasters
/src/level/space/gun.rb
UTF-8
957
2.921875
3
[ "Unlicense" ]
permissive
require 'geometry/rectangle' require 'physics/body' require 'timing/timer' module Level module Space class Gun attr_reader :fired def self.make(sound) Gun.new(Timing::Timer.new(0, 0.1), nil, sound) end def initialize(timer, fired, sound) @timer = timer @fired = ...
true
948cc65472b0ad4c66fa8cae4f182503d6b15549
Ruby
dry-rb/dry-core
/spec/dry/core/constants_spec.rb
UTF-8
3,491
2.828125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true require "dry/core/constants" RSpec.describe Dry::Core::Constants do before do class ClassWithConstants include Dry::Core::Constants def empty_array EMPTY_ARRAY end def empty_hash EMPTY_HASH end def empty_set EMPTY_SET ...
true
0ac9531a8534c692e802010ae82171e67078e779
Ruby
robertjlooby/Tic-Tac-Toe
/tests/player_tests.rb
UTF-8
2,270
3.28125
3
[]
no_license
require 'test/unit' require 'stringio' require_relative '../src/player' require_relative '../src/board' class PlayerTests < Test::Unit::TestCase def setup @reader = MockReader.new @writer = MockWriter.new @p1 = Player.new(:X) @p2 = Player.new(:O) end def test_player_initiali...
true
b18e2525e88e886795fd7eeeabaa6b82016a36ef
Ruby
lpile/backend_prework
/day_3/ex30.rb
UTF-8
892
4.25
4
[]
no_license
people = 10 cars = 25 trucks = 25 # if there is more cars than people then output "take cars" if cars > people puts "We should take the cars." # if not, check if cars is least than people then output "don't take cars" elsif cars < people puts "We should not take the cars." # else then cars = people then output "ca...
true
8609eaabe6fc77840f80364120cdd14482ba1604
Ruby
silverhammermba/scripts
/stpeter.rb
UTF-8
8,276
2.890625
3
[]
no_license
#!/usr/bin/env ruby # if you want to get into heaven, you need to go through this guy require 'find' require 'taglib' require 'set' require 'fileutils' # for suggesting existing artist/album names def edit_distance(s, t) m = s.length n = t.length return m if n == 0 return n if m == 0 d = Array.new(m+1) {Arr...
true
c5bbb7fc99ccbd0f5dbb0801f7549f39497de8ed
Ruby
EpicDream/shopelia
/lib/parsers/descriptions/amazon/formatter.rb
UTF-8
6,726
2.578125
3
[]
no_license
# -*- encoding : utf-8 -*- module Descriptions module Amazon class KeyCleaner SKIP = /commentaires? client|Politique de retour|Votre avis/ def self.clean key return nil if key =~ SKIP || key.blank? key end end class ContentCleaner SKIP = /commentair...
true
ed22687fbf0fc92c83729c8bf59cc5b510fbc13d
Ruby
Rim-777/CuteExchange
/spec/cute_exchange/money_spec.rb
UTF-8
5,602
3.171875
3
[ "MIT" ]
permissive
require 'spec_helper' RSpec.describe Money do let(:fifty_eur) {Money.new(50, 'EUR')} let(:fifty_five_dollars_fifty_cent) {Money.new(55.5, 'USD')} before do Money.conversion_rates('EUR', 'USD' => 1.11, 'RUB' => 70) end describe '.conversion_rates' do it 'assigns right values' do expect(Money.b...
true
923fa5cb3cb09ed33bce39acfb23e8551aecac9b
Ruby
elainapolson/oo-animal-sorter-web-0615-public
/lib/animal_sorter.rb
UTF-8
923
4.25
4
[]
no_license
# Build a class AnimalSorter # Make sure there are two constants that AnimalSorter knows about, # SEA_ANIMALS and LAND_ANIMALS # AnimalSorter should be able to accept an array of animals on # initialization. # Define a to_a method to account for the species in the test suite. # Return an array that contains two a...
true
adad844ca412397e4542d590634e3dd8e5f12bc8
Ruby
KoKumagai/idioms-in-Ruby
/nil_guards2.rb
UTF-8
141
2.78125
3
[]
no_license
params = {} # nil guards Array(params[:items]).each do |item| # ... end # equivalent to (params[:items] || []).each do |item| # ... end
true
d7d1a84a7b2400c2979c9d5cc5b094ccba2c8b44
Ruby
StanTarnev/Week-2-Weekend-Homowork
/specs/song_spec.rb
UTF-8
432
2.796875
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require_relative("../Guest.rb") require_relative("../Room.rb") require_relative("../Song.rb") class TestSong < MiniTest::Test def setup() @song1 = Song.new("Jesus Built My Hotrod") @song2 = Song.new("O Fortuna") @song3 = Song.new("Jump Around") @so...
true
ca15c5ac547a977099d0f0c36a1f89dd7d2b48c6
Ruby
revjatto/stock-trader
/app/models/stock.rb
UTF-8
623
2.921875
3
[]
no_license
class Stock < ActiveRecord::Base def self.find_by_ticker(ticker_symbol) where(ticker: ticker_symbol).first end def self.new_from_lookup(ticker_symbol) looked_up_stock = StockQuote::Stock.quote(ticker_symbol) return nil unless looked_up_stock.name new_stock = new(ticker: looked_up_stock.symbol, name: looked_up_stock.na...
true
b07714bb1e1fc146e182e34c8fc210fde30bb427
Ruby
rezaf/DataStructures_and_Algorithms
/int_hash_set.rb
UTF-8
1,053
3.359375
3
[]
no_license
class IntHashSet DEFAULT_SIZE = 8 MAX_LOAD = 1.00 attr_reader :count def initialize self.buckets = Array.new(DEFAULT_SIZE) { [] } self.count = 0 end def include?(value) bucket_for(value).include?(value) end def insert(value) return false if include?(value) self.resize! if (count...
true
5222b3399d3931a0e4ac931a8d5d41308dbe731d
Ruby
DarkWater666/ruby_test
/task9.rb
UTF-8
198
3.078125
3
[]
no_license
class String def palindrome? return false if size == 0 self.downcase!.gsub! /\W+/, '' self == reverse end end module Enumerable def palindrome? to_a == to_a.reverse end end
true
69ba3b496766f93dbb08538972a9e6652ff80b5f
Ruby
alestar/Ruby-Code
/Rock Paper Siccors/public/lib/dessert.rb
UTF-8
443
3.34375
3
[]
no_license
class Dessert def initialize(name, calories) @name=name @calories=calories end attr_accessor :name,:calories def healthy? calories < 200 end def delicious? return true end end class JellyBean < Dessert def initialize(flavor) @flavor=flavor @calories=5 @name= flavor...
true
c7f592ee24e494db5b5e9f84eb0b6a8c4fab42f0
Ruby
smcommits/CodeAnalyzer
/lib/helpers/parser.rb
UTF-8
1,044
2.546875
3
[ "MIT" ]
permissive
class SourceHandler attr_reader :buffer, :ast, :tokens, :diagnostics def initialize(buffer, ast, tokens, diagnostics, comments) @buffer = buffer @ast = ast @comments = comments @tokens = tokens @diagnostics = diagnostics end end class ParseCode def initialize_parser parser = Parser::Cu...
true
ebde51c9cc6c2afb04fa993953ee6e506903e686
Ruby
bartezic/discounts_dictionary_wrong
/spec/lib/word_combinations/dictionary_spec.rb
UTF-8
825
2.65625
3
[]
no_license
require 'spec_helper' require 'word_combinations/dictionary' describe WordCombinations::Dictionary do before do @dictionary = WordCombinations::Dictionary.new @dictionary.add_dictionary_entries(%w(aa aab abc bce a)) end describe 'words prefixes' do def prefixes(word) @dictionary.prefixes_for(w...
true
cd7fd64f52275fe432e0f60575e99e91e8cb1519
Ruby
iteloo/tautology
/tautology/app/models/term.rb
UTF-8
481
3.4375
3
[ "MIT" ]
permissive
class Term def initialize(words_array) @words = words_array @string = @words.join ' ' end def is_singular? if @string.pluralize == @string return false else return true end end def is_plural? return !self.is_singular? end def opposite_pluralization if self.is_singular? ...
true
c0517d9f38923c49ad199f38566d598c181427ce
Ruby
patjab/OO-mini-project-dumbo-web-051418
/app/models/User.rb
UTF-8
1,937
3.828125
4
[]
no_license
# USER # Build the following methods on the User class # ### User.all should return all of the user instances ### User#recipes should return all of the recipes this user has recipe cards for ### User#add_recipe_card should accept a recipe instance as an argument, as well as a date and rating, and create a new recipe ca...
true
809980b6113254f4c2d103ccc9aac0dcef7b3e07
Ruby
stuart32/fxrates
/lib/fxrates.rb
UTF-8
2,225
3.359375
3
[]
no_license
require 'bundler/setup' require "fxrates/version" require 'open_uri_redirections' require 'crack' require 'crack/xml' require 'date' require 'json' class ExchangeRate #Stores fx data from ECB to db/rates.json def getRates response = Crack::XML.parse(File.read(open("http://www.ecb.europa.eu/stats/eurofxref/eurofxr...
true
f14c1e4e931b42d8852997d63d3cfb2c57d71d46
Ruby
m1neral/ororo-search-app
/app/services/logging/add_log.rb
UTF-8
531
2.5625
3
[]
no_license
module Logging class AddLog attr_reader :params, :results_count, :is_client_log def initialize(params, results_count, is_client_log: false) @params = params @results_count = results_count @is_client_log = is_client_log end def perform log = {} if is_client_log l...
true
c8f1b63ea785507e1605cc97f2d6daef0dfa7558
Ruby
mrchenliang/math-game
/player.rb
UTF-8
154
2.625
3
[]
no_license
module MathGame class Player attr_accessor :lives def initialize @lives = 3 end def wrong @lives -= 1 end end end
true
1d26ced4afe6b52a5f5ef247351fad74a55d0201
Ruby
fatum/vips
/lib/vips/divider.rb
UTF-8
3,442
3
3
[ "MIT" ]
permissive
# -*- encoding : utf-8 -*- require 'vips/dom/element' require 'vips/block/element' require 'vips/block/pool' module Vips class Divider PDOC = 10 ROUNDS = 50 PAGE_SIZE = 1024 * 768 attr_accessor :dom, :signals, :current_signal, :block_pool def self.divided @@divided end def initia...
true
7ec653b13d86e94d85fc1de725cee18b6ea03704
Ruby
jstorimer/sprout
/lib/sprout/stream.rb
UTF-8
776
2.75
3
[ "MIT" ]
permissive
require 'events' module Sprout class Stream attr_accessor :io def initialize(io) @io = io @write_buffer = "" end include Events::Emitter CHUNK_SIZE = 8 * 1024 def handle_read begin data = io.read_nonblock(CHUNK_SIZE) emit(:data, data) rescue IO::Wait...
true
c6e6ab1a7e10cfec4323244308aa286968bf5083
Ruby
whtouche/wdi_2_ruby_lab_rspec_geometry
/spec/rectangle_spec.rb
UTF-8
629
3.21875
3
[]
no_license
require_relative '../lib/rectangle' describe Rectangle do let(:rectangle) { Rectangle.new(7, 5) } # Before every test, assign a local variable called rectangle whose value is the return value of the block describe 'attributes' do it 'has a length and width' do expect(rectangle.length).to eq 7 expe...
true
250ed6372f2884a339c92aeda00d6cd84ca9f313
Ruby
noto81/Homeworks
/W4D3/Simon_skeleton/lib/simon.rb
UTF-8
1,268
3.609375
4
[]
no_license
class Simon COLORS = %w(red blue green yellow) attr_accessor :sequence_length, :game_over, :seq def initialize @seq = [] @sequence_length = 1 @game_over = false end def play until @game_over take_turn end game_over_message reset_game end def take_turn ...
true
f8b2ed68600f45f1f1304049af6e61097d6e0d3e
Ruby
bingxie/code-questions
/lib/leetcode/124_binary-tree-maximum-path-sum.rb
UTF-8
656
3.453125
3
[ "MIT" ]
permissive
# class TreeNode # attr_accessor :val, :left, :right # def initialize(val) # @val = val # @left, @right = nil, nil # end # end # @param {TreeNode} root # @return {Integer} def max_path_sum(root) @max = -Float::INFINITY max_path_recursive(root) @max end def max_path_recursive(node) ...
true
f9ab6975f40d88fe9633e67374f257e0fd6a2655
Ruby
neeruram1/weather-bop
/app/models/user.rb
UTF-8
600
2.578125
3
[]
no_license
class User < ApplicationRecord def self.update_or_create(auth) user = User.find_by(spotify_id: auth['info']['id']) || User.new user.attributes = { spotify_id: auth['info']['id'], name: auth['info']['display_name'], access_token: auth['credentials']['token'], refresh_token: auth['crede...
true
6b47263a78756b7762a8c6fa908c1aee415b7c75
Ruby
jystewart/grand-rapids-wifi
/vendor/plugins/ym4r_mapstraction/lib/mapstraction_plugin/mapstraction.rb
UTF-8
9,725
2.515625
3
[ "MIT" ]
permissive
module Ym4r module MapstractionPlugin #Map types of the map class MapType ROAD = Variable.new("Mapstraction.ROAD") SATELLITE = Variable.new("Mapstraction.SATELLITE") HYBRID = Variable.new("Mapstraction.HYBRID") end #Represents a Mapstracted map. class Mapstraction ...
true
29f2e5d92442ac2c062138364973b13264d45a8d
Ruby
ctoa/monitoring-scripts
/puppet/check_puppet.rb
UTF-8
4,121
2.625
3
[]
no_license
#!/usr/bin/ruby # A simple nagios check that should be run as root # perhaps under the mcollective NRPE plugin and # can check when the last run was done of puppet. # It can also check fail counts and skip machines # that are not enabled # # The script will use the puppet last_run-summar.yaml # file to determine when ...
true
3329b0500665cb07ba2004bb26c3190397cdca54
Ruby
dmaes/monitoring-plugins
/check_oom-killer.rb
UTF-8
2,496
2.71875
3
[ "Apache-2.0" ]
permissive
#! /usr/bin/env ruby # ----------------------- # Author: Andreas Paul (xorpaul) <xorpaul@gmail.com> # striped down to only contain oom killer check by # Yornik Heyl<yornik@yornik.nl> from https://github.com/xorpaul/check_linux/blob/master/check_linux.rb # Date: 2013-12-02 10:57 # Version: 0.1.2 # -------------------...
true
37cf89bbf461cefd59511fc46a9af2d49fb00cef
Ruby
flapjack/flapjack
/lib/flapjack/cli/purge.rb
UTF-8
2,441
2.53125
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'hiredis' require 'flapjack/configuration' module Flapjack module CLI class Purge def initialize(global_options, options) @global_options = global_options @options = options if @global_options[:'force-utf8'] Encoding.default_external = 'UTF-8...
true
d38353d8d75fb7f9e273ccd12645e4e407cce639
Ruby
iknow/phraseapp_updater
/lib/phraseapp_updater/differ.rb
UTF-8
5,385
2.765625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'set' require 'hashdiff' require 'deep_merge' class PhraseAppUpdater class Differ SEPARATOR = '~~~' using IndexBy def initialize(verbose: false) @verbose = verbose end # Resolution strategy is that primary always wins in the event of a conflict d...
true
45f592074ab6b21182356332b3610c6e3bc720ea
Ruby
kh45/Algorithms
/Codewars/find_the_outlier.rb
UTF-8
926
4.1875
4
[]
no_license
# You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" N. #...
true
085210b1c698517211e9d283c5257d0c228bcf46
Ruby
tnandate/ruby_toy
/spec/factory_method/id_card_spec.rb
UTF-8
416
2.5625
3
[]
no_license
require './spec/spec_helper' require './lib/factory_method/id_card' RSpec.describe IdCard do before do @id_card = IdCard.new("John") end describe '#use' do it 'return use message' do expect{ @id_card.use }.to output("use John's card.\n").to_stdout end end describe '#get_owner' do it '...
true
ff7d11be68e69cd931c0d25cb910cb7604ebacf8
Ruby
ping-n/Fast-track-Gem
/lib/Class.rb
UTF-8
499
3.28125
3
[ "MIT" ]
permissive
# frozen_string_literal: true class Employee attr_accessor :first_name, :last_name, :age, :gender def initialize(f_name, l_name, age, gender) @first_name = f_name @last_name = l_name @age = age @gender = gender end def to_a [@first_name, @last_name, @age, @gender] end end class Shift ...
true
2cbc31795af95b7136ceb8362eb804a3be98b62f
Ruby
edelgado/code-challenge-parsing-and-sorting
/lib/registrar/importers/comma_importer.rb
UTF-8
340
2.546875
3
[]
no_license
module Registrar class CommaImporter < Importer def self.mapping(row) { first_name: row[1], middle_initial: nil, last_name: row[0], campus: row[2], date_of_birth: row[4], favorite_color: row[3] } end def self.delimiter ',...
true
597c7ac221afd7d56e4e6122771513e464bb6615
Ruby
wjue/Empo
/models.rb
UTF-8
4,970
3.3125
3
[]
no_license
# encoding: utf-8 # Auhtor WANG Jue aka wjue, Copyright 2014. wjue@outlook.com # License GPL v2 # =============================================================================================== # The primary goal of this project is to create an application that assist Chinese classical poem # learner to practice the ...
true
c67f1633afabcf7b1c7d07f553f4595245624be9
Ruby
8geonirt/github-contributions
/app/models/github/github_repository.rb
UTF-8
429
2.515625
3
[]
no_license
# frozen_string_literal: true module Github # Class that stores a Github Repository returned by the Github Graphql Server class GithubRepository attr_reader :name_with_owner, :url, :created_at, :updated_at def initialize(repository) @name_with_owner = repository.name_with_owner @url = reposito...
true
106a9ac8396c260a154a38e8970cde7c005611ce
Ruby
HLuning/Launch-School-Core-Curriculum
/RB101_Programming_Foundations/small_problems/retirement.rb
UTF-8
432
4.0625
4
[]
no_license
# age puts "What's your age? " age = gets.to_i # age of retirement puts "At what age would you like to retire? " age_retirement = gets.to_i # current year current_year = Time.now.year # working years left years_left = age_retirement - age # year of retirement year_retirement = current_year + years_left puts "It's ...
true
b1107f0ae7e7c0b49bfa4ef8aa9278d4af1f80c2
Ruby
lwlsns/claim-additional-payments-for-teaching
/app/models/payroll/payment_csv_row.rb
UTF-8
2,787
2.640625
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
# frozen_string_literal: true require "delegate" require "csv" require "excel_utils" module Payroll class PaymentCsvRow < SimpleDelegator DATE_FORMAT = "%Y%m%d" UNITED_KINGDOM = "United Kingdom" BASIC_RATE_TAX_CODE = "BR" CUMULATIVE_TAX_BASIS = "0" NOT_EMPLOYEES_ONLY_JOB = "3" NI_CATEGORY_FO...
true
7fac01a4f8eeac262dc22b5a0118e8f176c93ea9
Ruby
trvslhlt/TextDig
/ContactsGateway.rb
UTF-8
2,342
3.0625
3
[]
no_license
#!/usr/bin/ruby require 'sqlite3' require_relative './MessagesGateway' class ContactsGateway FIRST = "First" LAST = "Last" CONTACT_ID = "ContactID" attr_accessor :contacts def initialize(source_db_url) @contacts = self.get_contacts(source_db_url) end def get_contacts(source_db_url) begin db = SQLite3...
true
15feea50856de5d0d0468c888c5d6cb80c3c14be
Ruby
jamesreck/lesson_2
/lesson_2/rock_paper_scissors.rb
UTF-8
2,442
3.875
4
[]
no_license
# Ask the user to choose rock, paper or scissors # The computer will then choose. # The program will decide who won and display the winner # The program will ask if the user wants to play again COMBATANTS = %w(rock paper scissors lizard spock) VALID_CHOICES = %w(rock r paper p scissors sc lizard l spock sp) SCISSORS_...
true
450953e8974a0a00c636a16890a39d8c28f2137e
Ruby
emanon001/atcoder-ruby
/abc036/c/main.rb
UTF-8
277
2.890625
3
[]
no_license
N = gets.to_i a_list = N.times.map.with_index { |i| [gets.to_i, i] } sorted = a_list.sort_by { |a, _| a } b_list = Array.new(N) max = -1 current = nil sorted.each do |(a, i)| if a != current current = a max += 1 end b_list[i] = max end b_list.each { |b| puts b }
true
9fba748a688c6df52b729b54fae4c8318e8661d7
Ruby
ministryofjustice/laa-apply-for-legal-aid
/spec/mock_objects/mock_queued_job.rb
UTF-8
170
2.5625
3
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
class MockQueuedJob attr_reader :item, :score def initialize(klass, at) @item = { "queue" => "default", "wrapped" => klass.to_s } @score = at.to_i end end
true
1ec8b5999018db4d0f68fc7536bde3e530b47a75
Ruby
costagavras/week_3-multiclass
/product.rb
UTF-8
983
4.1875
4
[]
no_license
# Each product has a name, base price, and tax rate. There should also be a method to calculate and return the product's total price based on the base price # and tax rate. class Product def initialize(name, base_price, quantity, category) @name = name @base_price = base_price @quantity = quantity # ...
true
bcf510a85e998c5a1112b81ba5fcf33e14589e80
Ruby
jimjeffers/EquipmentBookingSystem
/app/models/category.rb
UTF-8
1,863
2.546875
3
[]
no_license
class Category < ActiveRecord::Base # Plugins has_guid :name # Relationships has_many :categories has_many :items belongs_to :category # Validations validates_presence_of :name validates_uniqueness_of :name # Scopes default_scope :order => 'position ASC, created_at DESC' named_scope :ro...
true
746f9d0869c11b2311784a21836eff39597f60ca
Ruby
remind101/request_signing
/lib/request_signing/ssm.rb
UTF-8
3,168
2.5625
3
[ "MIT" ]
permissive
require "aws-sdk-ssm" require "request_signing" module RequestSigning module KeyStores # AWS SSM-backed key store implementation # @see RequestSigning::Signer # @see RequestSigning::Verifier # @see http://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html class ...
true
928b958d54e1688dcc19cc93afcbb9810269c895
Ruby
ShomaFujii/furima-34532
/app/models/purchaser_address.rb
UTF-8
1,041
2.609375
3
[]
no_license
class PurchaserAddress include ActiveModel::Model attr_accessor :zip_code, :prefecture_id, :city, :street_number, :building, :phone_number,:user_id,:item_id,:token with_options presence: true do validates :user_id validates :item_id validates :city validates :street_number validates :token ...
true
b49625f5d3cd7d3cef43c38f6706d1e740ceca75
Ruby
Gothu/fremar
/spec/models/user_spec.rb
UTF-8
6,358
2.734375
3
[]
no_license
require 'rails_helper' describe User do describe '#create' do it "全て入力すると登録できる" do user = create(:user) expect(user).to be_valid end it "nicknameが空だと登録できない" do user = build(:user, nickname: "") user.valid? expect(user.errors[:nickname]).to include("can't be blank") end...
true
b657457a1fde00f3d0d7318d23dfd8b82949c07e
Ruby
Aprekek/DegreezeRuby
/spec/input_target_temperature_spec.rb
UTF-8
2,090
3.03125
3
[]
no_license
require_relative '../src/scenarious/input_target_temperature' require_relative '../src/io_adapter' require_relative '../src/scenarious/convert_temperature' RSpec.describe States::InputTargetTemperature do type_of_degrees = 'k', temperature_amount = '34.0' state = States::InputTargetTemperature...
true
5492d43d951c502abde52da2c81f323e1609bb1b
Ruby
jaycdave88/Hisser
/spec/model_spec.rb
UTF-8
1,666
2.6875
3
[]
no_license
require_relative "./spec_helper" describe User do #tests that the model has attributes it { should respond_to(:first_name) } it { should respond_to(:last_name) } it { should respond_to(:snake_name) } it { should respond_to(:email) } it { should respond_to(:password) } it { should respond_to(:avatar) } ...
true
b872d1e8de400d7c2898736a9574cafc088611ad
Ruby
mako1997/Ruby_sample
/02_08.rb
UTF-8
312
2.859375
3
[]
no_license
programming_languages = %w(ruby php python javascript) # コードを追加 programming_languages.map! { |item| item.capitalize } upper_case_programming_languages = programming_languages.map { |item| item.upcase } # 以下は変更しないで下さい p programming_languages p upper_case_programming_languages
true
bfff5148d9317b9456cf27ce230d592b403d0520
Ruby
adwinsky/skyscraper
/spec/skyscraper/skyscraper/path_spec.rb
UTF-8
3,713
2.65625
3
[ "MIT" ]
permissive
require "spec_helper" describe Skyscraper::Path do describe "when path is REMOTE" do before(:each) do @path = Skyscraper::Path.factory("http://google.com/index.php?q=e") end it "local? method should returns false" do @path.local?.should == false end it "remote? method should returns...
true
990cbb123ee2a88680785b57be94594e85be2575
Ruby
james-wallace-nz/ls_rb109
/lesson_4/additional_practice.rb
UTF-8
4,199
4.5625
5
[]
no_license
# 1. # Given the array below flintstones = ["Fred", "Barney", "Wilma", "Betty", "Pebbles", "BamBam"] # Turn this array into a hash where the names are the keys and the values are the positions in the array. hash = {} flintstones.each_with_index do |name, index| hash[name] = index end p hash # 2. # Add up all ...
true
93df3cae3abc4be72669555a4186f3e9a869e856
Ruby
jhh/net-denon-gem
/lib/net/denon/state.rb
UTF-8
2,973
2.984375
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
require 'net/denon/constants' require 'net/denon/loggable' module Net ; module Denon class State include Constants include Loggable attr_reader :master_volume attr_reader :master_volume_max attr_reader :input_source attr_reader :channel_volume attr_reader :record_sou...
true
022eb39ecd861693401c845290d1256610cde9db
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/triangle/9e871778d02d4cacb7333a1cd839144c.rb
UTF-8
414
3.40625
3
[]
no_license
class Triangle def initialize(side1, side2, side3) @a = side1 @b = side2 @c = side3 end def kind raise TriangleError if [@a, @b, @c].min <= 0 x, y, z = [@a, @b, @c].sort raise TriangleError if x + y <= z return :scalene if @a != @b && @b != @c && @a != @c return :equilateral...
true
97d635783c25c93e367f7d0939abe7e2b154c405
Ruby
sul-dlss/content_management_scripts
/add_donor_tag.rb
UTF-8
1,605
2.796875
3
[]
no_license
# Spotlight workaround to use the otherwise unused "Donor tags" field as a specialized facet # Usage: ruby add_donor_tag.rb input_dir/ output_dir/ mapfile.txt ## input_dir contains MODS files with "druid:" prefix in filename ## mapfile.txt is two tab-delimited columns: first column is druid, second column is term to ad...
true
c7591c35e5b988eaad199374c6e9d315d99da26f
Ruby
nehagrg/rubys1
/practice/p3.rb
UTF-8
231
3.046875
3
[]
no_license
puts "enter n number" n=gets n=n.to_i for i in 1..n for j in 1..n-i print " " end for k in 1..i print "#{k}" end for m in 1..i if m<i h=i while h>1 do print "#{h-1}" h=h-1 end break end end puts end
true
97ea87bfd8c11ffa9ee2b3b59ba92fa894fa3ab8
Ruby
jeremyjaybaker/blockcypher-ethereum
/lib/blockcypher/ethereum/api.rb
UTF-8
1,296
2.546875
3
[ "MIT" ]
permissive
module Blockcypher module Ethereum class API include APIState # The primary class through which most API interaction will occur through. # Each instance of this class has initializers for all defined API objects # which can then call the various actions associated with those objects. ...
true
c5feb2335688e2e21f022679ad5923061f50360d
Ruby
versality/GildedRose-challenge
/lib/gilded_rose/item_collection.rb
UTF-8
273
2.609375
3
[]
no_license
module GildedRose class ItemCollection def initialize(items) @items = items end def update_quality @items.each do |item| item_behavior = ItemBehavior::ItemBehavior.new(item) item_behavior.update_quality end end end end
true
1ef07defa86133c8b35b275d8861ce9e84af0ac2
Ruby
j-eaves/params-game
/app/controllers/input_parameters_controller.rb
UTF-8
2,447
2.78125
3
[]
no_license
class InputParametersController < ApplicationController #Ruby logic should always be here - none in the view page def parameter_input #/test_page (page) #p params[:name] @param_value = params[:name].upcase if @name[0]=='A' @message = "Hey your name starts with an A!" end render 'query_...
true
97fddaa04d0d33c9765044f1a48a2be9ae9b9986
Ruby
lei7dover/NotesAPI
/app/models/note.rb
UTF-8
375
2.703125
3
[]
no_license
class Note < ActiveRecord::Base has_and_belongs_to_many :tags validates_presence_of :title, :body belongs_to :user def tag_names=(tags) tags.split(",").collect{|t| t.strip}.each do |tag| this_tag=Tag.find_or_create_by(name: Tag.clean_name(tag)) self.tags << this_tag end end def tag_names ...
true
5d9706afaf08a3120bccaea614718d2aa4d477b2
Ruby
Camsbury/caesar-cipher-ruby
/cipher.rb
UTF-8
827
3.359375
3
[]
no_license
def caesar_cipher(statement,num) statement=statement.split("") for index in 0..statement.length-1 do if statement[index] =~ /[A-Z]/ if statement[index].ord+num>90 add=num%26 if add>(90-statement[index].ord) add=add+statement[index].ord-90 statement[index]=(64+add).chr else statement[in...
true
6fc2fc8ef8738ef63be5f4c4854c5268407129f6
Ruby
barkingiguana/compound
/lib/barking_iguana/compound/host_manager.rb
UTF-8
1,839
2.546875
3
[]
no_license
module BarkingIguana module Compound class HostManager attr_accessor :hosts private :hosts= attr_accessor :implementation private :implementation=, :implementation include BarkingIguana::Logging::Helper include BarkingIguana::Benchmark def initialize hosts = [], implem...
true
301294bf72764906f418e901ff948eb961661c6e
Ruby
keisuke07/RubyStudy2016
/submit/ishigaki/RubyQ13-20161008/post_initial.rb
UTF-8
1,195
2.96875
3
[]
no_license
require 'sqlite3' require 'csv' class Post_initial CSV_COLUMN = {code: 2, pref_kana: 3, city_kana: 4, addr_kana: 5, pref: 6, city: 7, addr: 8} def initialize(dbfile) @dbfile = dbfile end def create(zipfile) begin return if File.exist?(@dbfile) SQLite3::Database.open(@dbfile) do |db| db....
true
ab4dd5fe6bc661950fdabb5cad370d85fdc757e1
Ruby
Samthedriver/pokemon-scraper-dc-web-082718
/lib/pokemon.rb
UTF-8
685
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Pokemon attr_accessor :id, :name, :type, :db def initialize(hash) @id = hash[:id] @name = hash[:name] @type = hash[:type] @db = hash[:db] end def self.save(name, type, db) db.execute("INSERT INTO pokemon (name, type) VALUES (?, ?)", name, type) end def self.find(id, db) poke...
true
ebd8343cabe4daa6a42129c55bfce31f99034aa7
Ruby
vmendi/ListenAndRepeat
/IdxLeecher/main.rb
UTF-8
1,263
3.4375
3
[]
no_license
require 'net/http' require 'uri' require 'CGI' class Main def run_all_letters words = [] 97.upto(122) { |chr_idx| char = chr_idx.chr.upcase puts "Fetching #{char}..." char_uri = URI.parse("http://education.yahoo.com/reference/dictionary/entry_index?letter=#{char}") char_web_page ...
true
5678d161fef61ed0088c1f926c4b51a1102dff12
Ruby
cshomaker/skillcrush-ruby
/blog.rb
UTF-8
895
3.625
4
[]
no_license
class Page attr_accessor :title, :blog_posts, :total_posts, :created_date, :author, :content def initialize @blog_posts = {} @total_posts = 0 end def show_posts return @blog_posts.sort_by {@created_date} end end class Blog_post < Page attr_accessor :title, :blog_posts, :total_posts, :creat...
true
cc79699b74ee3a994cfd6c2dd470ef6ac1891f1e
Ruby
dcadizm/Ruby_learning
/Comparator.rb
UTF-8
798
4.03125
4
[]
no_license
############################################################# =begin Objetivo Encontrar el minimo de tres numeros Tareas 1.- preguntar los 3 numeros al usuario 2.- llamar a la clase comparadora 3.- presentar el resultado del proceso =end ############################################################# # 1.- R...
true
0799d0bfd2a64bff0e4101c9b74660641897be3c
Ruby
humawork/wardrobe
/lib/wardrobe/plugins/merge.rb
UTF-8
1,133
2.53125
3
[ "MIT" ]
permissive
module Wardrobe module Plugins module Merge extend Wardrobe::Plugin module MergeRefinements refine Object do def merge(other) other.dup end def deep_merge(other) merge(other) end end refine Hash do def d...
true
e670161b92e58e2461fe6241a6f9fc0b348fa76b
Ruby
JackHowa/phase-0-tracks
/ruby/secret_agents-input.rb
UTF-8
859
3.875
4
[]
no_license
puts "Would you like to encrypt or decrypt a message?" crypt_choice = gets.chomp puts "What should I input into the encrypter/decrypter machine?" input = gets.chomp puts "What is the caesar shift for the message? (1 for +1)" shift = gets.to_i if crypt_choice == "decrypt" shift = -(shift) end def decrypt(inp...
true
ed8419a659f65ab67b0404bb0b5d94ac642f9a3a
Ruby
jlaw90/truegrit
/blob.rb
UTF-8
448
2.703125
3
[]
no_license
require_relative 'util' module TrueGrit class Blob attr_reader :data def initialize(content,source=nil) @data = Util.crlf(content) @source = source end def self.from_file(path) return Blob.new(File.readlink(path), path) if File.symlink?(path) Blob.new(File.binread(path), pat...
true
9e61b7ceef4a844ca403573197579beb6a2f1cb9
Ruby
learn-co-students/nyc-web-students-042219
/10-activerecord/db/migrate/20190503143114_create_squirrels.rb
UTF-8
565
2.953125
3
[]
no_license
class CreateSquirrels < ActiveRecord::Migration[5.2] def change create_table :squirrels do |t| t.string :name t.string :fur_color t.integer :height t.string :disposition end end end # rake db:migrate # CreateSquirrels.new.change # # def change(table_name) # # does some stuff # ...
true
7b99814d6d2d98d86b0e5c53846fb9adf3e1d905
Ruby
cebartling/certification-exam-quizzer-rails
/lib/seeds/exam_questions/exam_questions_seed.rb
UTF-8
1,257
2.703125
3
[ "MIT" ]
permissive
require 'csv' module Seeds module ExamQuestions class ExamQuestionsSeed def self.execute puts 'START: Seeding exam_questions table' csv_text = File.read(Rails.root.join('lib', 'seeds', 'exam_questions', 'exam_questions.csv')) csv = CSV.parse(csv_text, :headers => true, :encoding =>...
true
5a2b6faa2672fa7d80db08883944bc203b548b58
Ruby
godsent/trap
/lib/trap/concerns/eventable.rb
UTF-8
623
2.515625
3
[]
no_license
module Trap::Concerns::Eventable def on(event, object, method, *args) @listeners[event] ||= [] @listeners[event] << [object, method, args].flatten end def emit(event) (@listeners[event] || []).each { |a| a[0].send a[1], *a[2 .. -1] } end private def init_variables super @listeners = {...
true
95c5f1e1b8c5ae857348e95de0ebe5333e825325
Ruby
pixelastic/tedtalks-audio-list
/lib/helper_path.rb
UTF-8
1,467
3.265625
3
[]
no_license
require 'uri' # Convenience methods for dealing with filepaths module HelperPath # Sanitize a filename so it can be written on disk without any risk. # Removes all special chars. # Args: # - filepath (String): Original filepath # Returns: # - String: Sanitized filepath def self.sanitize(filename) ...
true
d499040b31aa009a4a9997b8ce15be9bfd72e339
Ruby
melzreal/key-for-min-value-v-000
/key_for_min.rb
UTF-8
230
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def key_for_min_value(name_hash) min = nil min_k = nil name_hash.each do |key, value| if min ==nil min = value min_k = key elsif min > value min = value min_k = key end end min_k end
true
2a25f832b1f2efe90e17c07cc62f774ff40b67f8
Ruby
jacksonlmp/Conta_Bancaria_Exercicio
/principal.rb
UTF-8
616
3.484375
3
[]
no_license
#principal.rb require "./classes/conta_bancaria" require "./classes/conta_com_taxa" conta_jack = ContaComtaxa.new "jack", 100 conta_pessoa2 = ContaBancaria.new "pessoa2", 200 conta_jack.transferir conta_pessoa2, 50 p "Conta JACK" p conta_jack.saldo p "Conta Pessoa" p conta_pessoa2.saldo #Caso de teste de conta se...
true
de99df7bc0927826f06b302c4dbf10aa527fcf21
Ruby
karthickpdy/CP
/Codemonk/Searching/rip.rb
UTF-8
150
3.25
3
[]
no_license
t = gets.to_i t.times do s = gets.chomp puts s =~ /21.*/ || s.to_i % 21 == 0 ? "The streak is broken!" : "The streak lives still in our heart!" end
true
c2decba2a0cf1d2277e73749c701f3e47e2ac8b5
Ruby
digideskio/racing_on_rails
/app/models/category.rb
UTF-8
1,918
2.59375
3
[ "Ruby", "MIT" ]
permissive
# Senior Men, Pro/1/2, Novice Masters 45+ # # Categories are just a simple hierarchy of names # # Categories are basically labels and there is no complex hierarchy. In other words, Senior Men Pro/1/2 and # Pro/1/2 are two distinct categories. They are not combinations of Pro and Senior and Men and Cat 1 # # +friendly_p...
true
3f019cfd21224041d0658d7e9af6f170d2fc2361
Ruby
jirokun/shizuku
/sample/create_data.rb
UTF-8
1,612
2.90625
3
[]
no_license
require 'faker' Faker::Config.locale = :ja puts "making data..." open('create_table.sql', 'w') do |f| f.puts <<EOT drop table if exists transactions; drop table if exists users; create table users ( id varchar(10) primary key, sei varchar(20), mei varchar(20), age int, specialty varchar(5), employment varchar(...
true
67e43d859e04c0024cc172b3e56e0f6fd69a687b
Ruby
escoffon/fl-framework
/lib/fl/framework/service/nested.rb
UTF-8
8,909
2.796875
3
[ "MIT" ]
permissive
module Fl::Framework::Service # Base class for service objects that are "nested" inside others. # This class implements functionality used by objects that map to nested resources, like for example # comments associated with a commentable. class Nested < Base # Initializer. # # @param owner_class [C...
true
055e5ec3d08493602461799af33c9849076b3f9f
Ruby
Heightened/backend
/model/Race.class.rb
UTF-8
974
3.21875
3
[]
no_license
# Character Race # # @author Tim van Dalen class Race < StatModifyingProperty end # Collection of defined [Race]s module Races # @returns [Race] A totally neutral race that does nothing def self.Neutral Races::get "neutral" end # Gets a race # # @param [String] race alias of the Race you want ...
true
0b23445159c818c3b15d107a1b89fdf13e2da79f
Ruby
charrednewth/Succubus-Rhapsodia-ENG
/Scripts - manually insert these/018 - RPG-Ability(素質・設定用).rb
SHIFT_JIS
30,067
2.640625
3
[]
no_license
#============================================================================== # RPG::Ability #------------------------------------------------------------------------------ # @f̏B$data_ability[id]QƉ”\B #============================================================================== module RPG #---------------------...
true
7ea0c51f11f2326979086659500eb78f069572b2
Ruby
Mfbeeck/votersim
/lib/test_voter2.rb
UTF-8
2,044
3.828125
4
[]
no_license
class Politician attr_accessor :name, :party def initialize(name, party) @name = name @party = party end end # This version uses a "Campaign" class to hold the pieces. class Campaign # Instead of having separate runner code, the user prompts # are coded into the class. def display_main_menu ...
true