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
69a2abd3fa2c90f8ce30bcc5dbf9995674f65ec2
Ruby
bibbycodes/bank-tech-test
/lib/transaction.rb
UTF-8
206
2.640625
3
[]
no_license
# frozen_string_literal: true # Top level class class Transaction attr_reader :date, :amount, :type def initialize(date, amount, type) @date = date @amount = amount @type = type end end
true
33b90753bf784a203e7204e147ad1f7d8753c529
Ruby
AbdelrhmanAmin/Rails-first-project
/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.2.0/lib/mini_profiler/snapshots_transporter.rb
UTF-8
2,094
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true class ::Rack::MiniProfiler::SnapshotsTransporter @@transported_snapshots_count = 0 @@successful_http_requests_count = 0 @@failed_http_requests_count = 0 class << self def transported_snapshots_count @@transported_snapshots_count end def successful_http_requests_...
true
e5136ba94d8e8f3135b8d6adc49c10fb90597542
Ruby
joelzerr/rb_101
/lesson_5/practice_prob_9.rb
UTF-8
346
3.71875
4
[]
no_license
arr = [['b', 'c', 'a'], [2, 1, 3], ['blue', 'black', 'green']] arr.map do |a| a.sort.reverse end # Although my code worked, below is the LS solution that doesn't use the reverse method. # Instead it calls sort on the sub-array and changes the order of the a & b. # arr.map do |sub_arr| # sub_arr.sort do |a, b| # ...
true
9056d0434046e340358b6b6ad8b07144fdcb231e
Ruby
Billiam/redd
/lib/redd/client/unauthenticated/utilities.rb
UTF-8
3,097
2.984375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "redd/thing" require "redd/object/listing" require "redd/object/comment" require "redd/object/more_comments" require "redd/object/private_message" require "redd/object/submission" require "redd/object/subreddit" require "redd/object/user" require "redd/object/wiki_page" module Redd module Client class Un...
true
1ec2e79cf84a28b4ab87c7803dcdcbd5cdedceb2
Ruby
luca-montaigut/Archives_THP
/2.3_exo_ruby2/lib/02_password.rb
UTF-8
1,149
3.25
3
[]
no_license
def signup puts "Choississez un mot de passe :" print "> " gets.chomp end def login(password) enter = nil while password != enter puts "Saisissez le mot de passe pour entrer :" print "> " enter = gets.chomp if enter != password puts "Mauvais mot de passe !\n\n" end end end def ...
true
6ecdbf26f475dc5ae039c52703fbe73b0dd86373
Ruby
mabels/construqt
/core/lib/construqt/graph.rb
UTF-8
6,571
2.734375
3
[ "Apache-2.0" ]
permissive
require 'set' module Construqt class Graph class Visited def initialize(key) @key = key # @sessions = sessions end def used(session) session[@key] end def set_used(session) session[@key] = true end end class ...
true
acdf7ee401ecaacb2ed7f041769be4facd6a023b
Ruby
rpalo/advent-of-code-2017
/test/knot_hash_test.rb
UTF-8
1,339
3.125
3
[]
no_license
# frozen-string_literal: true require 'test_helper' require 'knot_hash' # Test cases for the knot hash class TestKnotHash < Minitest::Test # Part 1: Twist the lengths according to specified algorithm def test_small_knot knot = KnotHash.new(4) input_lengths = [3, 4, 1, 5] knot.twist(*input_lengths) ...
true
a79d1a19baca0a0113320b53a3518d98c2883f42
Ruby
broadinstitute/single_cell_portal_core
/app/models/concerns/parameterizable.rb
UTF-8
2,644
2.546875
3
[]
permissive
# handle converting ActiveModel attributes into a command line string # used in PAPI jobs via LifeSciencesApiClient and IngestJob module Parameterizable extend ActiveSupport::Concern # regular expression to validate GS url format GS_URL_REGEXP = %r{\Ags://} # regular expression to match GCR URI format # fas...
true
d7a5d7b1b074aabd190d895f5b82355c683269f6
Ruby
R34P3R44/makers-bnb
/lib/space.rb
UTF-8
1,715
3.15625
3
[]
no_license
require 'pg' require_relative 'connection' require_relative '../database_connection.rb' class Space attr_reader :id, :name, :description, :user_id, :price def initialize(id:, name:, description:, user_id:, price:) @name = name @id = id @description = description @user_id = user_id @price = pri...
true
8609b0ff842bad282cc18284d3d89ba15943bb59
Ruby
negativecode/vines-services
/lib/vines/services/storage.rb
UTF-8
797
2.765625
3
[ "MIT" ]
permissive
# encoding: UTF-8 module Vines module Services class Storage include Vines::Log @@nicks = {} # Register a nickname that can be used in the config file to specify this # storage implementation. def self.register(name) @@nicks[name.to_sym] = self end def self.fr...
true
97b5ec918462d549bad6820da108fd08e7abd79f
Ruby
darthj/fall_class
/testing.rb
UTF-8
479
3.640625
4
[]
no_license
array = [4, "jim", "carol", 5] array[2] array.pop array.unshift('bob') array.shift array.length array.delete('jim') array.reverse array.each do |x| puts x end corbin = {} corbin = Hash.new() #array = [] #array = Array.new() corbin['name'] = "Corbin" puts corbin class Student attr_accessor :name, :age, :...
true
e2b6e6c2b39978fc6c79956260ff906c6b34eac8
Ruby
NARKOZ/gitlab
/lib/gitlab/client/markdown.rb
UTF-8
1,012
2.65625
3
[ "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true class Gitlab::Client # Defines methods related to markdown. # @see https://docs.gitlab.com/ce/api/markdown.html module Markdown # Render an arbitrary Markdown document # # @example # Gitlab.markdown('Hello world! :tada:') # Gitlab.markdown('Hello world! :tada...
true
6a87f962c528d1b632021a16ebfc21f842fc515d
Ruby
juliana06/book_ruby_intro
/Exercises/User_Input/8.rb
UTF-8
658
4.0625
4
[]
no_license
numerator = nil denominator = nil def valid_number?(number_string) number_string.to_i.to_s == number_string end loop do puts "Please enter the numerator:" numerator = gets.chomp if valid_number?(numerator) break else puts "Invalid input. Only integers are allowed." end end loop do puts "Ple...
true
6b3d3274520b97f33796ceb403168c22a97b5e81
Ruby
jamesrnelson/daily-practice
/test/longest_string_test.rb
UTF-8
798
3.359375
3
[]
no_license
require_relative 'test_helper' require './lib/longest_string' class LongestStringTest < Minitest::Test def test_it_works string = LongestString.new a = 'xyaabbbccccdefww' b = 'xxxxyyyyabklmopq' expected = 'abcdefklmopqwxy' actual = string.longest(a, b) assert_equal expected, actual end ...
true
8a4f5d6b2b11c805c737777605de44045e8a19b2
Ruby
moutainhigh/chelaike
/prime-server/app/models/car_state_history.rb
UTF-8
2,780
2.5625
3
[]
no_license
# == Schema Information # # Table name: car_state_histories # 车辆状态修改历史 # # id :integer not null, primary key # 车辆状态修改历史 # car_id :integer # 车辆ID # previous_state :string # 上一个状态 # state ...
true
b0552ea4921cf843b50d28a85064425f11cbae2b
Ruby
HartasCuerdas/MADinfo
/process_xml.rb
UTF-8
1,029
2.625
3
[]
no_license
load 'in_groups.rb' require 'date' def process_xml(data, month) data_size = data.count group_qty = data_size/FIELDS groups = data.in_groups(FIELDS) madvideos = groups[0] youtube_playlists = groups[1] dates = groups[2] titles = groups[3] puts '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' ...
true
f293b7b0b43f679dd1ba5657f5296ade637a8f6c
Ruby
gabrielgrover/Ruby_scripts
/Code_wars/lib/Trees/test/node_test.rb
UTF-8
1,374
3.015625
3
[]
no_license
require 'minitest/autorun' require "GraphModule.rb" class NodeTest < MiniTest::Test include GraphModule def setup @NODE_A = GraphModule::Node.new 1 @NODE_B = GraphModule::Node.new 2 end def test_initialize_children_elements_must_be_Nodes skip assert_raises TypeError do GraphModule::No...
true
b6e48f3c51ce228a9c67170668d7bc40e530e004
Ruby
PhilippePerret/Icare_AD_2018
/_lib/modules_common/my_sql/Methodes_MySQL.rb
UTF-8
4,826
2.984375
3
[]
no_license
# encoding: UTF-8 =begin Méthodes pour les objets (instances) des bases de données. @usage Placer `include MethodesMySQL' dans la classe de l'objet @requis La classe doit définir la méthode-propriété `table' qui retourne l'instance BdD::Table de la classe. =end module MethodesMySQL # Test de l'exis...
true
18de6afc9ea5c5230711d4f07450a31a06ec4c73
Ruby
rafatkatta/noon
/lib/noon/neen.rb
UTF-8
2,525
2.953125
3
[ "MIT" ]
permissive
require 'securerandom' require 'digest' require 'time' require 'bigdecimal' class Noon::Neen attr_reader :neen @base_value = 1 @additional_value= 1 def initialize(base_value = 1, additional_value= 1) @produce= Noon::Neen.produce @base_value = base_value if base_value >= 1 @additional_valu...
true
bf51a831783585d150f04a45c55df552ece6c610
Ruby
chbndrhnns/runner
/test/server/stdout_logger_spy_test.rb
UTF-8
720
2.53125
3
[ "BSD-2-Clause" ]
permissive
# frozen_string_literal: true require_relative '../test_base' class StdoutLoggerSpyTest < TestBase def self.id58_prefix '60e' end # - - - - - - - - - - - - - - - - - test 'dF7', %w( log(s) is a no-op when s is empty ) do assert_equal '', log('') end # - - - - - - - - - - - - - - - - - test '...
true
3d682c0993d920dfaab895d30e187a36005693c9
Ruby
jbodah/fruby
/fruby.rb
UTF-8
1,639
2.875
3
[]
no_license
require 'ruby2ruby' require 'ruby_parser' module Fruby module Self def self.method_missing(sym, actual_receiver, *args, &block) actual_receiver.public_send(sym, *args, &block) end end class Compiler # @returns [String] ruby code def self.compile(str) pipelines = str.split(/(?<!\|\>)\...
true
53981f3480c0e8000fdc6aaec7244eb71cf1fe4c
Ruby
davidbella/is_a_square
/lib/is_a_square.rb
UTF-8
964
3.328125
3
[]
no_license
require_relative 'distance' class IsASquare class << self def valid?(shape) four_sided_shape?(shape) && all_sides_equal_length?(shape) && all_diagonals_equal_length?(shape) end private def four_sided_shape?(shape) shape.points.count == 4 end def all_sides_equal_length?(s...
true
b73142f8fe07a846afcd98b15daff1f1b2567c67
Ruby
Yulatax/studing-ruby
/Lesson8/Screencast/screencast.rb
UTF-8
1,656
3.40625
3
[]
no_license
# frozen_string_literal: true class Foo def bar(key) hash = { a: 1, b: 2 } value = hash[key] value ||= 0 end def long_method sleep(3) end def memoryzation @m ||= long_method end end class User attr_accessor :name def has_name? !!name end def has_not_name? !has_name?...
true
e441e344dca4de453eb7421a737901580f506cc2
Ruby
pioneertrack/morning_katas
/searcher/spec.rb
UTF-8
450
3.03125
3
[]
no_license
require './array.rb' describe Array do describe '#binary_search' do it 'should search for an item in an array and return its index' do input = [0,1,2,3,4,5,10,18] expect(input.binary_search(0, input.length-1, 10)).to eq(6) end it 'should search for an item in an array and return its index' ...
true
c1608343d7aa32f9a2e7711f9475199a78d6bc9b
Ruby
d2bit/marsroverkata
/lib/navigator.rb
UTF-8
959
3.65625
4
[]
no_license
require './lib/point.rb' class Navigator N = 0 E = 1 S = 2 W = 3 DIRECTIONS = { 'N' => N, 'E' => E, 'S' => S, 'W' => W } MOVES = [[0, 1], [1, 0], [0, -1], [-1, 0]] def initialize(map, position, heading) @map = map @position = position @heading = heading end def current_position @pos...
true
4e0e39b09dc7797e7bca6d2d23fef64ef583fd72
Ruby
carvil/classify.it
/lib/page.rb
UTF-8
629
2.84375
3
[]
no_license
require 'uri' require 'faraday' class Page attr_accessor :url, :uri, :conn def initialize(url) @url = url end def self.fetch_page(url) page = Page.new(url) if page.valid? page.download end end def valid? %w( http https ).include?(uri.scheme) if uri end def uri @uri ||...
true
686497735a4a744b9f90fb7e8a67dc77898d8071
Ruby
marcandre/backports
/lib/backports/2.5.0/dir/children.rb
UTF-8
287
2.5625
3
[ "MIT" ]
permissive
class Dir Backports::EXCLUDED_CHILDREN = ['.', '..'].freeze unless Backports.const_defined?('EXCLUDED_CHILDREN') def self.children(*args) entries(*args) - Backports::EXCLUDED_CHILDREN end def children self.class.children(path) end end unless Dir.respond_to? :children
true
7bcfd5a862642e7697265f98b8910d511bf7f84e
Ruby
Ishotihadus/mikunyan
/lib/mikunyan/object_value.rb
UTF-8
2,732
3.28125
3
[ "Zlib", "MIT" ]
permissive
# frozen_string_literal: true module Mikunyan # Class for representing decoded object # @attr [String] name object name # @attr [String] type object type name # @attr [Hash<String,Mikunyan::ObjectValue>] attr # @attr [Object] value object # @attr [Symbol] endian endianness # @attr [Boolean] is_struct c...
true
cb9ce9a81d092b70e17da072ba1b21e854fc2372
Ruby
LeanKhan/learn_ruby
/05_book_titles/book.rb
UTF-8
647
3.734375
4
[]
no_license
class Book # TODO: Check out another way to make instance setters... # attr_accessor(:title) def initialize # Words that shouldn't be capitalized @dontCapitalize = ["the", "and", "an", "a", "in", "of"] end def title @title end def title= title words = title.split ...
true
b8598ea10868ac28bcbb2bb3c7e0c11a0ea9641a
Ruby
SirFlickka/XRBP
/lib/xrbp/crypto/account.rb
UTF-8
2,699
2.953125
3
[ "MIT" ]
permissive
require 'base58' module XRBP module Crypto # Generate a new XRPL account. # # @param key [Symbol, Hash] key type to generate or key itself (optional) # @return [Hash] account details containing id and pub/priv key pair def self.account(key=nil) pub = nil account_id = nil if key ...
true
8699a04659ae1a225a47696e8644d8ca8550d20f
Ruby
jamesjiang13/aA_Homework
/W3D4/map.rb
UTF-8
545
3.578125
4
[]
no_license
require 'byebug' class Map attr_reader :arr def initialize @arr = [] end def set(key, value) @arr.each { |pair| pair[1] = value if pair[0] == key } @arr << [key,value] end def get(key) # debugger @arr.each { |pair| return pair[1] if pair[0] == key } ...
true
5c6f82b4f0f9be19e59c1c53f74917a4e49bd6c5
Ruby
gltaborda/ruby_the_odin_project
/connect_four/lib/board.rb
UTF-8
2,084
3.625
4
[]
no_license
class Board attr_reader :array, :available_positions, :full_column def initialize @array = [Array.new(7,"_"),Array.new(7,"_"),Array.new(7,"_"),Array.new(7,"_"),Array.new(7,"_"),Array.new(7,"_")] @available_positions = 42 @full_column = Array.new(7,false) end def full? available_positions == 0 ...
true
250c9da17e8082cb2bb618c35d981c46df7d4a0e
Ruby
luvemil/worm-downloader
/parse_md.rb
UTF-8
1,977
3.171875
3
[]
no_license
require 'nokogiri' require './worm' ARTICLE_TAG="div.entry-content" TITLE_TAG = "h1.entry-title" html_file = ARGV[0] doc = Nokogiri::HTML IO.read html_file root = doc.css ARTICLE_TAG def show_me node strings = "" node.children.each do |child| strings += convert(child) end return strings end def show_t...
true
c6ee700f6a2100e57b019010203f257a92262eb9
Ruby
fooheads/boxy
/lib/boxy/dsl.rb
UTF-8
1,069
2.78125
3
[ "MIT" ]
permissive
require 'open-uri' require 'uri' require_relative 'command' module Boxy class Dsl def self.interpret(url) Dsl.new(url).send(:interpret) end private def initialize(url) @url = URI.parse(url.to_s) @commands = [] end def interpret instance_eval(open(@url.to_s).read) ...
true
e73babc528b7bdc93a95ad493f26d61984e94d67
Ruby
mohammadsultani/Ruby-Exercises
/exercise 24.rb
UTF-8
163
3.328125
3
[]
no_license
def squares_of_evens(array) square_evens = array.select { |x| x%2==0 }.map { |x| x * x } print square_evens end squares_of_evens([-5,-2,0,8,1,3,4,8])
true
ae9af50aee1dfd96b52a6c857fffd3bd9dd9a769
Ruby
Tkam13/atcoder-problems
/abc168/b.rb
UTF-8
88
3.21875
3
[]
no_license
k = gets.to_i s = gets.chomp if s.size <= k puts s else puts s.slice(0,k) + "..." end
true
4460882253ddb401a8959edb12767c939e58610a
Ruby
peel3r/bank_account_kata
/lib/statement.rb
UTF-8
577
3.40625
3
[]
no_license
class Statement attr_reader :transactions def initialize transactions = [] @transactions = transactions end def add transaction @transactions << transaction end def print output = "date || credit || debit || balance ||\n" @transactions.reverse.each { |t| output += format_line(t) } output...
true
b224d56359d9e4b751edff9fb13526ac4e7861b3
Ruby
Kmbsamaurice/odin-project-basic-ruby-projects
/bubble-sort.rb
UTF-8
566
3.84375
4
[]
no_license
def swap!(arr, a, b) arr[a], arr[b] = arr[b], arr[a] arr end def bubble_sort(arr) if arr.length == 1 p arr else iter = arr.length - 2 for i in 0..iter do swapped = false for j in 0..iter do if arr[j] > arr[j+1] swap!(ar...
true
9c2add75f22bdc3c79f3cd044b07b41bd1f1ba9b
Ruby
arthurvfain/ar-practice-student-grading-tracker
/app/models/student_exam.rb
UTF-8
377
2.90625
3
[]
no_license
class StudentExam < ActiveRecord::Base belongs_to :student belongs_to :exam def print_details puts "#{student.name} took the #{exam.subject} exam receiving a score of #{self.grade}" end def questions_correct_ratio puts "#{(grade*0.01*exam.total_questions).to_i} questions correct ou...
true
b9f821e5badb6cbc7e85ba794f9a0f988b7daab7
Ruby
aslanval/FIT5H_EuP
/Rails/Projekte/books/app/helpers/books_helper.rb
UTF-8
178
2.84375
3
[]
no_license
module BooksHelper def average(book) if book.likes.count > 0 i = 0 book.likes.each do |f| i = i+f.quality end e = i/book.likes.count else 0 end end end
true
ccd5b311979cd6cbce5ab5e9f21f6c68646682fb
Ruby
manojmj92/bitmap-solve
/lib/errors.rb
UTF-8
1,042
3.328125
3
[]
no_license
class FileError < StandardError def initialize(msg = "The file is invalid or does not exist") super end end class InvalidCommand < StandardError def initialize(command, all_commands) super("Invalid command #{command} provided. Available commands are: #{all_commands.join(",").inspect}") ...
true
4ca1ba97f9f969dc2b1378ebde6c62b62d0de95c
Ruby
dnagir/allowy
/spec/access_control_spec.rb
UTF-8
1,808
2.671875
3
[ "MIT" ]
permissive
require 'spec_helper' module Allowy describe "checking permissions" do let(:access) { SampleAccess.new(123) } subject { access } describe "#context as an arbitrary object" do subject { access.context } its(:to_s) { should == '123' } its(:zero?) { should == false } i...
true
e200da40c798dd2397fd1313ec8bd6859eb5bf91
Ruby
Hanmac/rpg_gamedata
/lib/battler_trait.rb
UTF-8
377
2.6875
3
[]
no_license
require_relative "battler" require_relative "trait" module Game class Battler attr_accessor :traits override("trait") do def initialize(*) super @traits = [] end end def available_traits traits.select {|t| t.rpg.requirement.check(self) } end def add_trait(key) @trai...
true
bae9b814fc50ae740ba087488efb18bbaa6b128a
Ruby
CountCulture/twfy_local_parser
/lib/tasks/council_scraper.rake
UTF-8
2,737
2.625
3
[]
no_license
desc "Quick and dirty scraper to get basic info about councils from eGR page" task :scrape_egr_for_councils => :environment do BASE_URL = "http://www.brent.gov.uk" require 'hpricot' require 'open-uri' puts "Please enter eGR url to be scraped for councils: " url = $stdin.gets.chomp puts "Please enter global...
true
782087df34609bf51f850fb9d8df8994310983dd
Ruby
Westacular/popclipextensions
/Code.popclipext/code.rb
UTF-8
454
2.71875
3
[]
no_license
#!/usr/bin/ruby input = ENV['POPCLIP_TEXT'] lines = input.split("\n", -1) if lines.length > 1 if lines[-1].empty? lines.pop trailingnewline = true else trailingnewline = false end output = "" lines.each {|line| output += "\t#{line}\n" } if trailingnewline print output else print output.sub(/\n\z/...
true
d7972c55604b0c46aa1281824101b9b63848d6ba
Ruby
wvulibraries/databases
/lib/core_extensions/false_class/int.rb
UTF-8
369
2.640625
3
[ "MIT" ]
permissive
# extends the core ruby language module CoreExtensions # extends the false class module FalseClass # integer module Integer # returns false as a 0 implicilty # @author David J. Davis # @return [Integer] 0 def to_i 0 end end end end # include this in the core clas...
true
20dd3a95d93e4ec542c0d4e2cffabd67f5d28fe3
Ruby
darrynza/yawast
/lib/shared/uri.rb
UTF-8
1,256
2.8125
3
[ "BSD-3-Clause" ]
permissive
# frozen_string_literal: true require 'ipaddress' module Yawast module Shared class Uri def self.extract_uri(url) # this might be buggy - actually, I know it is... url = 'http://' + url unless url.include?('http://') || url.include?('https://') # make sure the path is at least a s...
true
e006a6e7e173948a1c7929c357d361b66daf349e
Ruby
fizwidget/binarydump
/binarydump.rb
UTF-8
133
2.515625
3
[]
no_license
#!/usr/bin/env ruby puts ARGF.each_byte .map { |b| "%08b" % b } .each_slice(4) .map { |l| l.join(" ") }
true
fdbf98bc6587c2756569f96787ccea5ddfa4826b
Ruby
AlexGZhang2014/ruby_practice
/lib/ruby_practice/movie.rb
UTF-8
194
2.9375
3
[ "MIT" ]
permissive
class Movie attr_accessor :name, :link @@movies = [] def initialize(name, link = nil) @name = name @link = link @@movies << self end def self.all @@movies end end
true
11dfa5a1a087ef2ced2201ce0db48fe054a9417c
Ruby
kapilchoudhary/reminder-schedules
/app/models/event.rb
UTF-8
879
2.796875
3
[]
no_license
class Event < ApplicationRecord belongs_to :user validates_presence_of :title, :description, :month_day, :month_direction, :time enum month_direction: %i[start_of_month end_of_month] def scheduled?(event_time) event_time >= (scheduled_datetime - 30.minutes) && event_time <= scheduled_datetime end de...
true
77e53377b772a698782f06b71f1da135dcf2c7a1
Ruby
ismasan/simple_roles
/lib/simple_roles/role.rb
UTF-8
811
2.84375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module SimpleRoles # A role holds actions # class Role attr_reader :actions def initialize @actions = {} end def can(action_name, &blk) @actions[action_name.to_sym] = Action.new(action_name, &blk) end def can?(*args) parent_object = args.shift ac...
true
3414f687912619f1350d8e9d75637826eca804fd
Ruby
DanielYankiver/nyc04-seng-ft-071320
/07-intro-to-oo-in-ruby/run.rb
UTF-8
1,022
4.15625
4
[]
no_license
require 'pry' # creating a new class: class Animal end # creating new Animal instances: simba = Animal.new #this is an animal instance saved to a variable Animal.new #this is also an animal instance! # creating a new class with two behaviors: class Dog def bark puts "woof" end def sleeping ...
true
6a3a40674edf750479a916e90ccc769660805385
Ruby
KaminKevCrew/Jumpstart_Lectures
/old_lectures/even_sum.rb
UTF-8
263
4.125
4
[]
no_license
# define a method that takes an array and returns the sum of all even entries. def even_sum(arr) sum = 0 idx = 0 while idx < arr.length if arr[idx].even? sum += arr[idx] end idx += 1 end return sum end p even_sum([6, 5, 3, 4]) #=> 10
true
33020b6d7feca90a3ac132684d0e0966719b5994
Ruby
TheIronYard--Orlando/ROR--2015--SPRING
/Notes/Solved Problems/football/app/models/team.rb
UTF-8
957
2.609375
3
[ "CC0-1.0" ]
permissive
class Team < ActiveRecord::Base belongs_to :city has_many :home_games, class_name: "Game", foreign_key: :home_team_id has_many :away_games, class_name: "Game", foreign_key: :away_team_id has_one :coach validates :name, uniqueness: true validates :conference, :division, :name, presence: true def self.rank...
true
0b8e4d7064da58bcf2884442bb33a9f8136176a3
Ruby
jhliberty/appworld
/spec/models/user_spec.rb
UTF-8
1,892
2.578125
3
[]
no_license
require 'spec_helper' describe User do before(:each) do @attr = { :username => "exampleuser", :email => "example@user.com", :password => "password", :password_confirmation => "password" } end it "should create a new instance given valid attributes" do User.create!(@...
true
de20616145cd6d9cefd2cab18941bb6b69ae16f3
Ruby
vibraniumforge/flatiron-bnb-methods-seattle-web-080519
/app/models/concerns/reservable.rb
UTF-8
631
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
module Reservable extend ActiveSupport::Concern def openings(start_date, end_date) listings.merge(Listing.available(start_date, end_date)) end def ratio_reservations_to_listings if listings.count > 0 reservations.count.to_f / listings.count.to_f end end # class_metho...
true
81906d4dd171b2fd79b5dc19760a87d8b6f95fd6
Ruby
jennyhoring/Calculator
/example.rb
UTF-8
212
3.046875
3
[]
no_license
def answer_phone(caller, receiver) puts "Hello" + caller + "this is " + receiver end answer_phone(" Max," ,"Jenny") def color(favorite_color) puts "my favorite color is" + favorite_color end color(" green")
true
68eb80fd36d6b415b1ff6fcf5019d487e47bab38
Ruby
paskuvan/challenge12
/ex13.rb
UTF-8
323
3.359375
3
[]
no_license
fs_17 = %w[alumno1, alumno2, alumno3, alumno4, alumno5, alumno6] print fs_17, "\n" print "########\n" fs_17.map { |n| print "#{n} " if n.length <5} print "########\n" fs_17_up = fs_17.map(&:upcase) print fs_17_up,"\n" def array_str_length(array) a = [] array.each { |i| a << i.length} print a end array_str_length(fs_...
true
30924c1bbe41a76b772c49f7f5f4899447f86166
Ruby
Firose/RubyTraining
/array.rb
UTF-8
1,921
3.59375
4
[]
no_license
toy = ["cindrella","dora"] p toy a =["note","book",20,21] # bracket sysem p a b =[["pen","book"],["hi","hello"]] p b #short hand s = %w[firose iqbal] p s fruits = ["mango","apple","orange"] p fruits[fruits.length - 2] # fetch method fruits.fetch(1, "apple") #access with range object sl = [1,2,34,4] p sl[1..3] # by va...
true
23ce58a4c8efcd3e739611730a4e1c60178f42c0
Ruby
Onionator/more_albums
/lib/album.rb
UTF-8
1,989
3.40625
3
[]
no_license
require ('./lib/song') class Album attr_accessor :id, :name, :artist, :year, :genre @@albums = {} @@total_rows = 0 @@sold_albums = {} def self.all @@albums.values end def self.all_sold @@sold_albums end def self.clear @@albums = {} @@total_rows = 0 end def self.find(id)...
true
4a2711791c0d88445b15e2dfc9f65e9f866c4e1b
Ruby
soulnafein/code-katas
/ruby/tic-tac-toe/lib/tic_tac_toe.rb
UTF-8
906
3.796875
4
[]
no_license
require 'grid' require 'coordinate' class TicTacToe def initialize @current_player = "Player 1" end def self.new_game() TicTacToe.new end def show_grid(grid) puts grid.render end def display_message(message) puts message end def start grid = Grid.new show_grid(grid) wh...
true
99909505bbd4932953e63f45d89793a9e4b75f4b
Ruby
yunyangye/Outpatient_pre1980
/sourceFolder/measures/SetWaterHeaterEfficiency/measure.rb
UTF-8
4,528
2.703125
3
[]
no_license
# see the URL below for information on how to write OpenStudio measures # http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/ # start the measure class SetWaterHeaterEfficiency < OpenStudio::Ruleset::ModelUserScript # human readable name def name return "Set Water Heater Effic...
true
0c43d21a3b6ea24719f49c00f11febb4b6f7a8eb
Ruby
MS-87/ruby_code
/Learn Ruby the Hard Way/Exercises/class_inheritance.rb
UTF-8
1,957
3.859375
4
[]
no_license
class Parent def override() puts "PARENT override()" end def implicit() puts "PARENT implicit()" end def altered() puts "PARENT altered()" end end class Child < Parent def override() puts "CHILD override()" end def altered() puts "CHILD, BEFORE PARENT al...
true
b1e02d3cb735044ca7cdd67f2b19bec0c6f288b0
Ruby
brunz36/ironnews-image
/db/seeds.rb
UTF-8
487
2.53125
3
[]
no_license
require 'open-uri' require 'nokogiri' user_1 = User.create(name: "Patrick Miller", email: "pjmiller823@gmail.com", password: "password", password_confirmation: "password") user_2 = User.create(name: "Bruno Ribeiro", email: "brunz36@gmail.com", password: "test", password_confirmation: "test") (1..2).each do |page| N...
true
b9d2d6d2626130aeb353c77609a9ed3cd4ac976b
Ruby
lmsilvera/ObjectCannon-Game
/app/models/object_cannon_game.rb
UTF-8
1,239
3.203125
3
[]
no_license
class ObjectCannonGame < ActiveRecord::Base belongs_to :player belongs_to :game before_save :set_attributes private def set_attributes self.total_attributes = GenerateRandom.generate_attribute end end class GenerateRandom def self.generate_attribute (rand(5) + solve_chance.to_i).to_i end ...
true
6dbea9fbb4ca60d532f05279fac6ebdef85d150b
Ruby
fortuneonyeka/my_telegram_bot
/lib/motivation.rb
UTF-8
377
3.125
3
[ "MIT" ]
permissive
require_relative './helper_method' class Motivation attr_reader :morning_motivation private def initialize @morning_motivation = [ 'Love for all, hate for none', 'Every momment is a fresh beginning ', 'Whatever you do, do it well', 'What we think,we become' ] end public def good_motivatio...
true
e6857c6ac50bbb67b1c7961a2d23cbf68b657d85
Ruby
alisha/dialect
/dialect.rb
UTF-8
7,891
3
3
[]
no_license
require 'sinatra' require 'twilio-ruby' require 'json' require './classes' # Twilio Credentials TWILIO_PHONE_NUM = '+13392013680' ACCOUNT_SID = '' AUTH_TOKEN = '' # Sessions are unique for each phone number that texts the app enable :sessions # load data into classes (specified in classes.rb) def load_data(data) c...
true
e8b21c8a8b47d6654ee9df9010ac9713ce1cc645
Ruby
yabikutakumi/rubylesson
/sinatra-tutorial1/scope.rb
UTF-8
1,447
3.546875
4
[]
no_license
a = 1 b = 2 puts '=====' puts '# at first part' puts '=====' puts "a is defined => #{a}" if defined?(a) puts "b is defined => #{b}" if defined?(b) puts "c is defined => #{c}" if defined?(c) puts "d is defined => #{d}" if defined?(d) puts "e is defined => #{e}" if defined?(e) puts "f is defined => #{f}" if defined?(f) ...
true
437d81ad885552288f241f81d921a0a3e2c05fae
Ruby
oloomoses/my_enumerable_methods
/enumerable.rb
UTF-8
2,076
3.25
3
[]
no_license
module Enumerable def my_each return enum_for unless block_given? i = 0 array = self while i < size yield array[i] if is_a?(Array) yield to_a[i] if is_a?(Range) yield to_a[i] if is_a?(Hash) i += 1 end array end def my_each_with_index return to_enum(:my_each_wi...
true
810db9a941d36376707703d8fb2b15eb01668283
Ruby
conman246/connor_clark_ajax
/app/controllers/index.rb
UTF-8
761
2.640625
3
[]
no_license
get '/' do erb :index end # TODO: convert this route to use AJAX post '/rolls' do # If the user passes-in a "value", let's use it. Otherwise, we'll generate a random one. # See: roll_if_value_is_nil method in the Roll model. puts params value = params[:value] ? params[:value].to_i : nil puts '##########...
true
666bea6433db3d7c21f90c4d8e8e0b6175832c2f
Ruby
T-monius/ruby_small_problems
/easy_5/letter_counter_2.rb
UTF-8
998
4.53125
5
[]
no_license
# letter_counter_2.rb # Modify the word_sizes method from the previous exercise to exclude # non-letters when determining word size. For instance, the length of # "it's" is 3, not 4. # Understanding: # When to modify word strings? # Can iterate over array # Or, can remove non-letters before splitting string # Al...
true
99e6e24604a6a3e740fb9a97f055d737f655b951
Ruby
Thristhart/fluxx-base
/test/test_library.rb
UTF-8
2,447
2.71875
3
[]
no_license
require 'helper' require 'fluxx/library' require 'fluxx/card' describe Fluxx::Library do before do # Save the internal library hash before clearing it @saved_library = Fluxx::Library.cards.dup Fluxx::Library.clear! end after do # And set it again later Fluxx::Library.cards = @saved_library ...
true
aaa0115bf17a40f87ca60a98a90c3090a959c0c0
Ruby
Stephanie-Chou/interview_questions
/maxsumnxnmatrix.rb
UTF-8
203
3.125
3
[]
no_license
# Given an NxN matrix of positive and negative integers, write code to find the submatrix # with the largest possible sum. def maxSum(matrix) end arr = [[1, 4,-2] [3,-1, 0] [2, 5, 1]]
true
c145a288a25d7eaf55223ecdd4bb38bb03913530
Ruby
gemcfadyen/Apprenticeship-RubyRackWebTicTacToe
/spec/game_parameters_spec.rb
UTF-8
1,026
2.65625
3
[]
no_license
require 'board_adapter' require 'game_parameters' require 'player_options' RSpec.describe GameParameters do it 'extracts player option' do game_parameters = GameParameters.new({}, {'player_type' => '1'}, BoardAdapter.new) expect(game_parameters.player_option).to eq PlayerOptions::HUMAN_VS_HUMAN end it...
true
4218f36cf3fe2b2c2757aa69a246d041e0c2c87e
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/gigasecond/1676493bcdfb42f98f06c85d32161b8a.rb
UTF-8
173
2.84375
3
[]
no_license
class Gigasecond attr_reader :date class << self def from(date) new(date) end end def initialize(date) @date = date + (10**9 / 86400) end end
true
4670b1f2c5a68e45aef5388ba295eabe669f6505
Ruby
oeloeloel/tweetcarts
/cascading-squares/readable.rb
UTF-8
1,624
3.15625
3
[ "MIT" ]
permissive
def tick args # set the background colour args.outputs.background_color = [210, 260, 255] # setup things that happen once if args.tick_count.zero? # counts frames. This could have been done with # args.tick_count but the tweetcart code sets and # increments a variable to be extra short args.s...
true
5357dec053b0993a66eb84fa4ff13378ac63c162
Ruby
RebeccaKleinberg/practice-project-euler
/1.rb
UTF-8
399
4.6875
5
[ "MIT" ]
permissive
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. def sum_of_mults(num) ary = [] num.times do |num| if num % 3 == 0 || num % 5 == 0 ary << num end num -= 1 ...
true
2c37e617f89100285ec686afa88c84c354cb8339
Ruby
watashi/AlgoSolution
/codeforces/ac/2/231/B.rb
UTF-8
222
2.765625
3
[]
no_license
n, d, m = gets.split.map(&:to_i) y = n / 2 x = n - y d -= x - y a = Array.new(n) do |i| t = i.odd? == (d > 0) ? 0 : [d.abs, m - 1].min if d > 0 d -= t else d += t end t + 1 end puts d == 0 ? a * ' ' : -1
true
f13a57c1a88e0f414aace285450426e7a8f12ded
Ruby
vsakaria/audiogasm
/app/models/song_provider.rb
UTF-8
1,343
2.515625
3
[]
no_license
class SongProvider ECHONEST_API_KEY = ENV['ECHONEST_API_KEY'] RDIO_KEY = ENV['RDIO_KEY'] RDIO_SECRET = ENV['RDIO_SECRET'] @rdio_api = RdioApi.new(:consumer_key => RDIO_KEY, :consumer_secret => RDIO_SECRET) def self.get_track_embed_url(artist_id, count =1) artist = SongProvider.get_rdio_artist_id(art...
true
12b0d6f96b45f94dbbf3f3b3dfbffcaa0fa66bc0
Ruby
Torgian/Ruby_Exercises
/ChapterFour/exercise_3.rb
UTF-8
489
4.59375
5
[]
no_license
#The case statement was my original answer for exercise 3 #For exercise 5, I simply changed it to a function def number_range num case num when 0..50 puts "The number is less than 50." when 51..100 puts "The number is less than 100, but above 50." else if num < 0 puts "The number is a...
true
3e968ca729d1cd07b04b636dfb709bb87a2ff6c7
Ruby
cdcarter/statister
/bracketing.rb
UTF-8
2,685
3.078125
3
[]
no_license
require 'rubygems' require 'couchrest' require 'enumerator' require 'pp' require 'json' =begin This is a basic script for creating whole brackets worth of rounds for a statister db. teams: {"type":"team","name":"State College A", "players": ["Graham","Monica","David"]} ( TODO: alternative players: [{name:Graham,grad...
true
b03abfa2633682c30894c4a8e3426a7a08556249
Ruby
aneeshjk25/myapp
/app/services/yahoo_quotes.rb
UTF-8
1,426
3.0625
3
[]
no_license
class YahooQuotes include Utilities attr_reader :quotes,:day_quote,:top,:bottom @@quote_collection = {} def initialize(company) remote_url = 'http://chartapi.finance.yahoo.com/instrument/1.0/'+company.yahoo_symbol+'/chartdata;type=quote;range=1d/json/' @data = getJson(remote_url,true) @quotes = extract_till_...
true
994db01f8fcfee3f0eeb856faf5203825005d6d9
Ruby
halostatue/minitar
/lib/archive/tar/minitar/input.rb
UTF-8
7,608
3.078125
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
# coding: utf-8 require "archive/tar/minitar/reader" module Archive::Tar::Minitar # Wraps a Archive::Tar::Minitar::Reader with convenience methods and wrapped # stream management; Input only works with data streams that can be rewound. class Input include Enumerable # With no associated block, +Input.o...
true
14c331e7712e5300bea3472345261d021314f0a5
Ruby
horisakis/pro_ruby_intro
/02/2.05/2.5.1/boolean_value.rb
UTF-8
244
2.921875
3
[]
no_license
def find_data nil end data = find_data # 他言語の書き方 if data != nil 'データあります' else 'データありません' end # ruby特有の書き方 if data 'データあります' else 'データありません' end
true
dee9983d4195600ccd788b51fa46b95ffcb676e2
Ruby
oscarmolivera/code_farm
/Ruby/CodeWars/Collection Ruby 8 Kyu/CW-NumberofPeopleintheBus.rb
UTF-8
2,279
3.53125
4
[]
no_license
=begin Number of People in the Bus There is a bus moving in the city, and it takes and drop some people in each bus stop. You are provided with a list (or array) of integer arrays (or tuples). Each integer array has two items which represent number of people get into bus (The first item) and number of people get of...
true
92f767b2d63057d77069d3c610f0524f20beffc7
Ruby
spacetimeltd/ws-update
/pasture/postproc.scratch.rb
UTF-8
3,258
2.6875
3
[]
no_license
#if target['options'] #code = target['code'] #opts = target['options'] #code.gsub! /(^\w*?);/, '\1old;' #code.gsub! /\((\w*?)\)/, '(\1old)' #code.gsub!(/=(\w*?)(&|$)/, '=\1old\2') #opts.gsub! /\((\w*?)\)/, '(\1old)' #else ...
true
f2091af9e8527c2159ee5df9a8bf3ad9425dcdfa
Ruby
danhealy/dragonruby-ui-sample
/app/lib/zif/components/two_stage_button.rb
UTF-8
1,175
2.84375
3
[ "MIT", "CC0-1.0" ]
permissive
module Zif # Define a set of sprites for both the pressed state and the normal state # Use #toggle_pressed to switch states # Override the height methods to center the label # #resize and #redraw should occur in subclass initialize class TwoStageButton < ComplexSprite attr_accessor :normal, :pressed, :is_...
true
f28520950c040b95907a4b7a027a6986a9515742
Ruby
sureshpathipati/locus
/features/step_definitions/book_api_steps.rb
UTF-8
1,537
2.71875
3
[]
no_license
Given('I choose {string} api') do |string| @end_point = EndPoint.module_eval("GET#{string}") end When /^I hit the endpoint$/ do @api_response = RestWrapper.get_call(url: @end_point, headers: @headers) end Then /^I should see only "(.*?)" books returned in the response$/ do |books_count| expect(@api_response[:da...
true
cd9354705f36b3ae22572602cf95dde3618e34e4
Ruby
Tachoramirez/PythonPracticas
/Ruby/circunferencia.rb
UTF-8
660
4
4
[]
no_license
#Clase demuestra la herencia en Ruby load "punto.rb" class Circunferencia < Punto def initialize(vRadio) @radio = vRadio end #Métodos get y set para radio def getRadio() return @radio end def setRadio(vRadio) @radio = vRadio end #Método que calcule el área de l...
true
e2fb2e8de5ac42daafda47c67543bfd2b863c256
Ruby
ilya89forrails/MKDEV_RUBY
/spec/scraper_spec.rb
UTF-8
737
2.515625
3
[]
no_license
require 'rspec' require 'date' require 'webmock/rspec' require 'vcr' require "open-uri" require "nokogiri" require "json" require_relative '../lib/TopMDB/movie.rb' require_relative '../lib/TopMDB/my_movie.rb' require_relative '../lib/TopMDB/movies_list.rb' require_relative '../lib/TopMDB/my_movies_list.rb' require_re...
true
c2b90b326ade7c073c889aa07123683f23abaff8
Ruby
VagnerOliveira1/ruby
/arvore.rb
UTF-8
2,477
4.03125
4
[]
no_license
#Implementação de uma Classe Árvore #Implemente uma classe chamada Arvore. #1. Ela deve ter idade, altura e várias frutas e ser inicializada com todos esses #atributos com valor 0. #2. Ela deve ter um método passar_um_ano, que faz ela ficar mais velha. Quando o #tempo passa ela fica maior e produz frutas. #3. Ela morre...
true
8445911e9ad8391c3eeae3778f02df8c9c7f3ede
Ruby
AlvaroMaceda/calculadora-judicial
/spec/lib/holidays_importer_spec.rb
UTF-8
3,098
2.515625
3
[]
no_license
require 'rails_helper' describe HolidaysImporter do let(:importer) { HolidaysImporter.new } before(:each) do create(:territory, kind: :country, code: 'CT_ESP') create(:territory, kind: :autonomous_community, code: 'AC00001') create(:territory, kind: :municipality, code: 'ES26036') ...
true
5379eab91ae80d8dda5e2ff2c23e1bac976a8115
Ruby
Eden-Eltume/101
/101_Exercises/Small_Problems/Easy_2/ex1.rb
UTF-8
113
3.5
4
[]
no_license
def age_generator(name='Teddy') age = rand(20..200) puts "#{name} is #{age} years old." end age_generator()
true
8f90b8f4b80f83d96f3c68bc188a24ed86c52752
Ruby
suzshiro1024/statistics_visualizer
/src/make_graph.rb
UTF-8
878
3.03125
3
[]
no_license
require 'rubygems' require 'gruff' require_relative './data_reading.rb' print ("select mode(Pitcher => 0, Batter => 1):") control = gets.to_i # select mode graph = Gruff::Net.new # make new net graph data = openfile(control) if(control == 0) # Pitcher Mode graph.title = "Pitchig Stats" graph.labels = { ...
true
f3a480fbb5d4753ff5285386c3a915ea9040e1a7
Ruby
bakku/peacock
/lib/git/base.rb
UTF-8
490
2.578125
3
[ "MIT" ]
permissive
module Git class Base def self.command_with_output(command = '', opts = '') output_stream = base_command(command, opts) output_as_string = output_stream.readlines.join output_stream.close output_as_string end def self.command(command = '', opts = '') base_command(comm...
true
7d68dc9c85fdad786ba52b1503aa5159b55ad0f3
Ruby
DavidMcKenzie218/rio_olympics_project
/models/athlete.rb
UTF-8
1,801
3.28125
3
[]
no_license
require_relative '../db/sql_runner.rb' require 'pg' class Athlete attr_reader :name, :id, :nation_id, :event_id, :event_time, :medal def initialize(options) @name = options['name'] @id = options['id'].to_i @nation_id = options['nation_id'].to_i @event_id = options['event_id'].to_i @event_time...
true
00ec7e5c138e1b253dd556f0e95d5a568d706200
Ruby
greglockwood/CrusadeMT
/test/unit/enrolment_test.rb
UTF-8
1,433
2.65625
3
[]
no_license
require 'test_helper' class EnrolmentTest < ActiveSupport::TestCase # relationships test "enrolment has a degree property" do enrolment = create assert(enrolment.respond_to?('degree'), "enrolment does not have a degree property (has the relationship been set?)") begin enrolment.degree rescue ...
true
c5e91ad6aff93881434577e3ce60af98ed1a0a26
Ruby
s1250189-Inoue/defective-project
/src/01_type/change_zero_last_bits.rb
UTF-8
102
2.71875
3
[]
no_license
def change_zero_last_bits(bits, num_of_bits) bits.to_s(2).to_i.round(-num_of_bits).to_s.to_i(2) end
true
86a7a75af6494b751bf5f551a5974a79f72caf50
Ruby
dlobba/ruby_bioinformatics
/parsing_partII/parsing2.rb
UTF-8
7,186
3.21875
3
[]
no_license
#! /usr/bin/ruby require 'test/unit/assertions' include Test::Unit::Assertions # Take a file, get all the lines until matching termination_pattern. # We are searching for // in particular, which are the termination characters # for the cds. # TODO: make the method general for any String object, and not for file objec...
true
334154930c83d5975f01f2b5a227f6927f557d8a
Ruby
GrinnellLocalFood/localfoods
/app/models/cart_item.rb
UTF-8
1,467
2.71875
3
[]
no_license
class CartItem < ActiveRecord::Base belongs_to :cart belongs_to :item validates :cart, :presence => true validates :item, :presence => true validates :quantity, :numericality => { :only_integer => true, :message => I18n.t('validation.must_be_int'), :greater_than => -1 } validate :quantity_greater_than_minor...
true