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
1f2423d326873785516e6176c02bfd661f528563
Ruby
gtkatakura-bysoft/reloader_gem
/lib/reloader_gem.rb
UTF-8
1,772
2.6875
3
[ "MIT" ]
permissive
# encoding: utf-8 require "reloader_gem/version" require "digest/md5" require "logger" class ReloaderGem def initialize(gem_name_path, time = 0.5) @logger = Logger.new(STDOUT) if gem_name_path.split("/").last == gem_name_path @gem_name = gem_name_path @gem_path = Gem::Specification.find_by_nam...
true
9091296bef509063fe3f49f34626c90049f68cfc
Ruby
cedricwider/katas
/spec/game_of_life/grid_spec.rb
UTF-8
1,776
3.609375
4
[]
no_license
require 'rspec' require_relative '../src/ib/game_of_life/src/grid.rb' require_relative '../src/cell.rb' describe Grid do let :grid do Grid.new(height: 10, width: 10) end it 'can be initialized with height and width' do # initialization is done using 'let' for simplicity. # what remains is the null ...
true
6cbd71967a7d1931f8283d2a53d2510f1d321fa0
Ruby
semahawk/harr
/src/lexer.rb
UTF-8
2,045
3.5625
4
[ "MIT" ]
permissive
class Lexer KEYWORDS = ["matey", "ship", "ends", "if", "else", "while", "true", "false", "nil"] def tokenize(code) # Cleanup code by remove extra line breaks code.chomp! # Current character position we're parsing i = 0 # Collection of all parsed tokens in the form [:TOKEN_TYPE, valu...
true
81261765b472b5a3fc0843d534626fd03f27eebe
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/scrabble-score/7c74d7b8b75f4b03a0245f17260e39ac.rb
UTF-8
671
3.78125
4
[]
no_license
class Scrabble LETTER_VALUES = { 1 => ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], 2 => ['D','G'], 3 => ['B','C','M','P'], 4 => ['F', 'H', 'V', 'W', 'Y'], 5 => ['K'], 8 => ['J', 'X'], 10 => ['Q', 'Z'], } class << self def score(word) self.new(word).score end end...
true
0f5a66e7104f547e7f0d765a30d244d997c6b823
Ruby
Minpeople/monte-cinema
/app/concepts/cinema_halls/representers/multiple.rb
UTF-8
384
2.5625
3
[]
no_license
# frozen_string_literal: true module CinemaHalls module Representers class Multiple def initialize(cinema_halls) @cinema_halls = cinema_halls end def call @cinema_halls.map do |cinema_hall| CinemaHalls::Representers::Single.new(cinema_hall).call end end ...
true
1b56b6b08363a74eb8ef8e3c6d0ad20248ed4873
Ruby
drjorgepolanco/mks
/software_engineering/data_structure_modeling_1/the_restaurant/the_restaurant_2.rb
UTF-8
1,917
3.96875
4
[]
no_license
module Meal def favorite(appetizer, entree, dessert) if vegetarian == false puts "#{@name}'s favorite meal is #{appetizer} for appetizer, #{entree} for entree and #{dessert} for dessert." else puts "#{@name}'s favorite meal, who is vegetarian is #{appetizer} for appetizer, #{entree} for entree and #{dessert}...
true
1d9b83705cf8c3f180ab8d8a06570df3f63353b0
Ruby
aenain/2d-geometry
/spec/integration/intersecting_vertical_lines_spec.rb
UTF-8
715
2.578125
3
[ "MIT" ]
permissive
require 'spec_helper' require 'intersectors/vertical_line_with_vertical_line' require 'intersecting_object' require 'models/vertical_line' RSpec.describe 'intersecting lines' do context 'with the same line' do it 'returns the line' do line_a = VerticalLine.new(1) line_b = VerticalLine.new(1) i...
true
e565db8eae8a5e391502392a136831445ff8b1b0
Ruby
dernathul/fizzbuzz_2020
/spec/fizz_buzz_spec.rb
UTF-8
138
2.796875
3
[]
no_license
require './lib/fizz_buzz.rb' describe 'fizz_buzz' do it 'return 1 if number is 1' do expect(fizz_buzz(1)).to eq 1 end end
true
c58804f7ff80546c462dd30d091e93fc723caf93
Ruby
marcwright/WDI_ATL_1_Instructors
/REPO - DC - Students/w02/d01/Parker/landlord/client.rb
UTF-8
929
3.859375
4
[]
no_license
# #ADD CLIENTS TO YOUR LIST # def list_client_name(client_name) # client_name.each_with_index do |client_name, index| # puts "Client #{index + 1}" # end # def add_client_name(client_name_array) # client_name = get_answer_to("What is the client's name?") # client_age = get_answer_to("What is the species?") # ...
true
a3b7e5a7238a6d6864f410ab250ad8329f791c85
Ruby
lolarodriguezp/rubyTPI
/app/models/evaluation.rb
UTF-8
1,172
2.609375
3
[]
no_license
class Evaluation < ApplicationRecord default_scope { order('date ASC') } validates :title, presence: true validates :date, presence: true validates :min_note, presence:true, numericality: {greater_than_or_equal_to: 0} validates :course_id, presence:true validate :validate_date belongs_to :co...
true
9a343a9a59661bd9504025863643db1ecdbcd19f
Ruby
DanielVartanov/geek-game
/server/network/server.rb
UTF-8
500
2.515625
3
[]
no_license
require "socket" require "bson" module GeekGame module Network class Server < Struct.new(:timeline, :host, :port) attr_accessor :socket def bind_to_port self.socket = TCPServer.new(host, port) end def wait_for_client @client = socket.accept end def push ...
true
6e9ac945adc88c5f32b396434eeddf3db90a1d1e
Ruby
Limnogirl90/Weather.MOO
/app/models/weather_datum.rb
UTF-8
1,601
2.828125
3
[]
no_license
class WeatherDatum < ActiveRecord::Base attachment :weather_html def self.weather_url_from_date( d ) year = d.year month = d.month day = d.day # iso = d.iso8601 url = "https://www.wunderground.com/history/airport/KELM/#{year}/#{month}/#{day}/DailyHistory.html" end def weather_data_date ...
true
bc51d01a8b3e9d4f9f220dd40a1b63faa738bb07
Ruby
tuanlv1206/pattern-design-in-ruby
/factorypattern.rb
UTF-8
641
3.59375
4
[]
no_license
class Shape def initialize(*arg) end def draw raise "not allowed here" end end class Triangle < Shape def draw "drawing triangle" end end class Square < Shape def draw "drawing square" end end class Circle < Shape def draw "drawing circle" end end class ShapeFactory def self.b...
true
d3a9cda5a1309bc8fd268f73ad04355d3e4004a8
Ruby
alemosie/the-bachelor-todo-001-prework-web
/lib/bachelor.rb
UTF-8
1,514
4
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def get_first_name_of_season_winner(data, season) name = "" data[season].each do |hash| # iterate over the season contestant array if hash["status"] == "Winner" name = hash["name"] end end name.split(" ").first end def get_contestant_name(data, occupation) # takes in the data hash and an occupa...
true
ef282d826f41f8dac9a364e38c34a6290e87903b
Ruby
jay-menorca/oop
/trains.rb
UTF-8
2,632
3.890625
4
[]
no_license
=begin Problem: The local commuter railroad services a number of towns in Kiwiland. Because of monetary concerns, all of the tracks are 'one-way.' That is, a route from Kaitaia to Invercargill does not imply the existence of a route from Invercargill to Kaitaia. In fact, even if both of these routes do happen to exist...
true
c8811f08f7ec5f9b6a9b4dd1530e8a82073a965b
Ruby
Abdul-Azeez/Basic-Ruby
/Vehicle-Subclass/lib/bikes.rb
UTF-8
210
2.984375
3
[]
no_license
require_relative 'vehicle' class Bikes < Vehicle def initialize(name, price, dealer) super(name, price) @dealer = dealer end def to_s "#{ super } and available with #{ @dealer }" end end
true
d9c363b334eeaf82f38d6ba44a3cc033d2127110
Ruby
alsanars/checkout_process
/lib/validations.rb
UTF-8
158
2.78125
3
[ "MIT" ]
permissive
module Validations def gt_than_zero?(value) raise 'Attribute is not a number' unless value.is_a?(Float) or value.is_a?(Integer) value > 0 end end
true
a3591481444617438102c2e4637fced67d6193f6
Ruby
yamanoie/cherry
/hash.rb
UTF-8
1,020
3.203125
3
[]
no_license
currencies = {"japan"=>"yen","us"=>"doller","india"=>"rupee"} currencies.each do |key,value| puts "#{key} : #{value}" end currencies.each do |key_value| key = key_value[0] value = key_value[1] puts "#{key}:#{value}" end currencies.delete("japan") p currencies currencies.delete("italy"){|key| "Not found:#{key}"}...
true
8c588b7cb98d940d9fe15e6b96cb6e23be9e20e0
Ruby
yoasyo25/master_mind
/end_game.rb
UTF-8
774
3.890625
4
[]
no_license
class EndGame def initialize(game) @game = game end def final_phase puts """ Congratulations! You guessed the secret code of '#{@game.shuffled.join}'q in #{@game.number_of_guesses} guesses over #{@game.time_lapsed} seconds. Do you want to (p)lay again or (q)uit? """ game...
true
05e5f2d3160dfbbfcf73bf83dea60c7ae51500d4
Ruby
nagata03/Ruby_Cherry
/lib/class_method.rb
UTF-8
787
4.1875
4
[]
no_license
class User def initialize(name) @name = name end # これはクラスメソッド(self.をつける) def self.create_users(names) names.map do |name| User.new(name) end end # これはインスタンスメソッド def hello # @nameの値はインスタンスによって異なる "Hello, I am #{@name}." end end alice ...
true
da5736e0ff0a2c92ac955cb4d2f47cbe70b875ef
Ruby
rubocoptero/BankAccountKata
/src/bank_account.rb
UTF-8
2,255
3.53125
4
[]
no_license
class Transactions include Enumerable def initialize @transactions = [] end def add_credit(amount, balance) credit = Transaction.create_credit(amount, balance) add(credit) end def add_debit(amount, balance) debit = Transaction.create_debit(amount, balance) add(debit) end def each...
true
37a2213df15bed838767716666cba07afc353161
Ruby
gizmore/activerecord-magic
/spec/event_container_spec_helper.rb
UTF-8
379
2.59375
3
[ "MIT" ]
permissive
class Player arm_events end class Party arm_events def initialize() @players = [] end def add_player(player) @players.push(player) end end class City arm_events def initialize() @parties = [] end def add_player(party) @parties.push(party) end end class Area < City arm...
true
5a2776448bdc2329ee8c7d06d9ddb4db18e927cd
Ruby
strand/rock-against-Spock
/2/features/step_definitions/rochambeau_steps.rb
UTF-8
748
3.0625
3
[]
no_license
def winning_throw(throw) counter = case throw when "rock" then "paper" when "paper" then "scissors" when "scissors" then "Spock" when "lizard" then "scissors" when "Spock" then "lizard" else "Please throw a real sign." end end Given ...
true
67d1566b5b6a1990d7a4bbe65836c5b4b00acb1f
Ruby
cfurrow/gifenc.rb
/gifenc.rb
UTF-8
2,074
2.9375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # requires ffmpeg 2.6+ # Creates a palette on the first pass by analyzing the movie # The second pass creates the gif, scaling it down. # From: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html#usage require 'optparse' options = {} class Options attr_accessor :input, :output, :start_tim...
true
c8468f63ea2b3010ee6ddd875b6eac8295ed9789
Ruby
lyntco/wdi_melb_homework
/gumballs/jam_creencia/week4/wk4_day3/sum.rb
UTF-8
472
4.3125
4
[]
no_license
#find out if each max up to X is divisible by 3 or 5. #if it is, put it in an array #add everything in the array require 'pry' def divisible (max, multiple1, multiple2) list = [] 1.upto(max) do |x| if x % multiple1 == 0 || x % multiple2 == 0 list << x end end sum = list.reduce(:+) if sum == nil put...
true
6f1c6a39c99206b31d2fb419cc22fb7fe2c8209d
Ruby
ECOtterstrom/RB101
/smallprob_easy4/easy4_ex2.rb
UTF-8
764
4.59375
5
[]
no_license
# easy4_ex2.rb What Century is That? # Write a method that takes a year as input and returns the century. The return # value should be a string that begins with the century number and ends with st, # nd, rd, or th. New centuries begin in years that end with 01. def century(year) century = year / 100 + 1 cent...
true
a7614e2626c85b9551026f6acb0e51fb7855bf9e
Ruby
stevieing/courtbooking
/app/models/permissions/base_permission.rb
UTF-8
5,584
2.953125
3
[]
no_license
module Permissions ## # BasePermission contains all of the necessary methods for building a permissions object. # Example behaviour: # # class ChildPermission < Permissions::BasePermission # def initialize(user) # allow [:controller1], [:action1, :action2] # allow_param [:class1], [:attribute1...
true
ddd4830e7cdd2921ce4737d8763a58761a619d09
Ruby
majorboy/program_study
/sample.rb
UTF-8
841
3.828125
4
[]
no_license
# for i in [1,2,3] do # p i # end # 1.upto(10) do |i| # p i # end # 10.downto(1) do |i| # p i # end # puts 1.class # puts "Hello world".class # puts 20.1.class # puts nil.class # puts [].class # true.class # String.class # animals = ['dog' , 'cat' , 'mouse'] # p animals # p animals[0] # ani...
true
68c030dedbcfe8a96adfdedfe9a456572519ab74
Ruby
DouglasAllen/code-Metaprogramming_Ruby
/raw-code/PART_II_Metaprogramming_in_Rails/gems/activesupport-2.3.2/lib/active_support/core_ext/string/behavior.rb
UTF-8
695
2.53125
3
[]
no_license
#--- # Excerpted from "Metaprogramming Ruby", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http:/...
true
3e3280d3184605d3d5eef7c40473f16285b86972
Ruby
bryanmytko/roster
/lib/wow_api/client.rb
UTF-8
807
2.6875
3
[]
no_license
require 'dotenv' require 'uri' module WowApi ENDPOINT = "https://us.api.battle.net/wow/" API_KEY = ENV["API_KEY"] class Client def initialize; end def character(name, realm, fields = "") request( :get, "character/#{realm}/#{name}", { fields: fields } ) end d...
true
cd86b007470895a686dcba7d9fdf62865031fea9
Ruby
durhamka/anagram-kata
/anagram_formatter.rb
UTF-8
120
2.984375
3
[]
no_license
module AnagramFormatter def self.print(anagrams) anagrams.each do |anagram| puts anagram end end end
true
7fade64e8dfbbd3c9a1c37c99c0b2221a692a1a2
Ruby
gaiottino/thick
/lib/thick/output_stream.rb
UTF-8
232
2.703125
3
[]
no_license
module Thick class OutputStream def initialize(stream) @stream = stream end def <<(s) @stream.print(s) end def method_missing(name, *args) @stream.send(name, *args) end end end
true
e140c8e878435cbb51b6b96e4003ee1b73996b90
Ruby
tbconroy/cassieq-client
/tasks/cassieq.rake
UTF-8
2,267
2.59375
3
[ "MIT" ]
permissive
require "yaml" require "curb" require "json" namespace :cassieq do desc "Start a CassieQ container in development mode" task :start_dev do start_cassieq end desc "Run RSpec test suite againts CassieQ dev container" task :test_client do start_cassieq { run_tests_and_quit } end end def start_cassie...
true
ab46e1bbed9def1f120a80655ce0b9465a284e92
Ruby
BeerInHand/bih
/lib/beerinhand/calculators/ibu.rb
UTF-8
1,332
2.953125
3
[]
no_license
module Beerinhand module Calculators class Ibu # http://rhbc.co/wiki/calculating-ibus attr_accessor :rager, :tinseth ByFormula = Struct.new(:rager, :tinseth) def initialize(params = {}) @rager = Rager.new(params) @tinseth = Tinseth.new(params) end def ibus ...
true
be5848fe2344adf56f68c9aa46cc47bf76440e2c
Ruby
thomasbaustert/periods
/lib/periods/modules/period.rb
UTF-8
9,822
3.546875
4
[ "MIT" ]
permissive
module Periods module Modules module Period def self.included(base) base.class_eval do include Comparable include InstanceMethods end end module InstanceMethods # Returns the start date of this period. # @return [Date] the start date of this...
true
551f4c5761adcdd1ce31754219eac45c4a779833
Ruby
hungntit/protobufdemo
/ruby/person.rb
UTF-8
380
3.203125
3
[]
no_license
require "json" class Person def initialize(name,old) @name = name @old = old end def to_s "In Person:\n #{@name}, #{@old}\n" end def to_json(*a) { "json_class" => self.class.name, "data" => {"name" => @name, "old" => @old } }.to_json(*a) end def self.json_creat...
true
a0f29168beb114e1aa95f7bcf0384d6c9945929e
Ruby
Eractus/practice-problems
/three_sum.rb
UTF-8
870
3.0625
3
[]
no_license
def three_sum(nums) total = nums.length sorted = nums.sort col = Hash.new(false) ans = [] # for i in 0..(total - 3) i = 0 while i < total - 2 # next if i > 0 && sorted[i] == sorted[i - 1] j = i + 1 k = total - 1 while j < k sum = sorted[i] + sorte...
true
9d8d5d72e364d2df6140c034e8cf27f95124a39a
Ruby
MaggieZhaoYale/figgy
/app/wayfinders/base_wayfinder.rb
UTF-8
6,358
2.828125
3
[ "Apache-2.0" ]
permissive
# frozen_string_literal: true # Wayfinders are classes which manage navigating relationships between IDs # stored on a Valkyrie::Resource to their associated Valkyrie::Resources. # # These wayfinders are most commonly accessed via # {Valkyrie::ResourceDecorator#wayfinder}, however they can also be instantiated # stand-...
true
c0ac3e4f896c065df32669e1f9937fa95a35f857
Ruby
chrisb87/skylight-ruby
/lib/skylight/util/uniform_sample.rb
UTF-8
880
3.171875
3
[]
no_license
module Skylight module Util class UniformSample include Enumerable attr_reader :size, :count def initialize(size) @size = size @count = 0 @values = [] end def clear @count = 0 @values.clear self end def length ...
true
70765da78d08614e4992e7d8c475dba1880b70ba
Ruby
m-kallstrom/phase-0-tracks
/ruby/santa.rb
UTF-8
3,090
4.125
4
[]
no_license
#METHODS #declare a Santa class class Santa #give its variables read and/or write access attr_reader :ethnicity, :age attr_accessor :gender, :reindeer_ranking #initialize with a message and declare some variables def initialize(gender, ethnicity) puts "Initializing Santa instance..." @gender = gen...
true
b5deb280cb27f26ec6e4204ca576d51d30f958c3
Ruby
dry-rb/dry-types
/spec/dry/types/constructor_spec.rb
UTF-8
10,513
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true RSpec.describe Dry::Types::Constructor do subject(:type) do Dry::Types::Constructor.new(Dry::Types["nominal.string"], fn: Kernel.method(:String)) end it_behaves_like Dry::Types::Nominal it_behaves_like "a constrained type" do let(:type) { Dry::Types["string"].constructor ...
true
618397209cd8cedb78e4c1f3e382a5c3d01cf552
Ruby
MauricioRibeiroA/doku
/lib/doku/grid.rb
UTF-8
9,842
3.34375
3
[ "MIT" ]
permissive
module Doku # This module is meant to be included in subclasses of {Puzzle} where the # squares are arranged in a grid. # # The {Puzzle} class contains only very abstract code, dealing with # the abstract concepts of {Puzzle.squares squares}, # {Puzzle.glyphs glyphs}, and {Puzzle.groups groups}. # The {Pu...
true
c873c9df49f23762ece884f4023153db06eed65e
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/phone-number/c92330abbf4f4b12a8cee83d771733ad.rb
UTF-8
501
3.21875
3
[]
no_license
class PhoneNumber attr_reader :number def initialize(phone) digits = phone.gsub(/[[:punct:][:space:]]/, '').match(/(\d{10}\d*)/) if !digits.nil? case digits[1].length when 10 @number = digits[1] when 11 @number = digits[1][1..-1] if digits[1].start_with?('1') ...
true
139c2cd710e8c53d9c17f13b8b1cd580f9f7f01e
Ruby
guilleiguaran/youmustdo
/lib/metadata.rb
UTF-8
1,639
2.640625
3
[]
no_license
require 'open-uri' require 'nokogiri' class Metadata def self.get(url) doc = Nokogiri::HTML(open(url, "User-Agent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)")) baseuri = URI.parse(url) response = Array.new(2,'') response[0] = doc.at('title').text des_data = doc.at("meta[name=descriptio...
true
d5805b435c76b48eb9cb6b0d3a88057eecf039de
Ruby
giancarlo/ruvim
/lib/ruvim/plugins/command.rb
UTF-8
624
2.578125
3
[]
no_license
# # Command Class - Ruvim # module Ruvim class Command private def evaluate(command) $ruvim.instance_eval(command) end public attr_accessor :prompt # app necessary to bind def initialize @prompt = ":" end # Gets command from user HAHAHA def input result = evaluate($ruvim.input(@prompt...
true
544dac985055ea553ac59fd3c915818befb8cb4d
Ruby
ruby-syntax-tree/syntax_tree
/lib/syntax_tree/visitor.rb
UTF-8
11,196
2.609375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module SyntaxTree # Visitor is a parent class that provides the ability to walk down the tree # and handle a subset of nodes. By defining your own subclass, you can # explicitly handle a node type by defining a visit_* method. class Visitor < BasicVisitor # Visit an ARef node....
true
ff894a6db6e964e293c1d967e02e640ea0c3f3f2
Ruby
MislavGunawardena/Back-End-Lesson01
/lesson_04/miscellaneous/test7.rb
UTF-8
411
3.546875
4
[]
no_license
hash = {a: 33, c: 12, e: 100, d: 50, b: 20} hash2 = {50 => 100, 25 => 1, 7 => 66, 88 => 20} puts hash.sort.to_s puts hash2.sort.to_s puts hash2.sort {|a, b| b <=> a}.to_s puts "-----" puts hash2.min.to_s puts hash2.max_by(2) {|k, v| k/v}.to_s puts hash2.min_by(2) {|k, v| k/v}.to_s puts hash2.max {|a,b| hash2[a] <=> h...
true
db9e4fcd821e97ad00b50d10a557f91a0a57b095
Ruby
TominagaRyuto/ruby
/type.rb
UTF-8
50
2.734375
3
[]
no_license
puts 5+3 puts "5+3" puts "5"+"3" puts 53 puts "53"
true
d599145f41299f97d827327670f2e5874d4ede91
Ruby
hqhy/CourseSelect-homework
/test/models/course_test.rb
UTF-8
1,389
2.703125
3
[ "MIT" ]
permissive
require 'test_helper' class CourseTest < ActiveSupport::TestCase # test "the truth" do # assert true # end def setup @course = Course.new(name: "Example Course", course_type: "Example Type", teaching_type: "Online", exam_type: "Offline", limit_num: 0, credit: 1, class_room: "222", course_week: "1", cour...
true
02346c30b244bd52c109225bd0b051f2fafb4bf3
Ruby
pharhadnadi/kyubits
/hackerrank/practice/temp/conv.rb
UTF-8
1,070
3.5
4
[]
no_license
def convert_temp(temp, **opts) scale_hsh = {'celsius' => :c, 'kelvin' => :k, 'fahrenheit' => :f} inp, out = scale_hsh[opts[:input_scale]], scale_hsh[opts[:output_scale]]|| :c puts case inp when :c case out when :k temp + 273.15 when :f (temp * 9.0 / 5)+ 32 end ...
true
6010225184c3361b705ea60857fd0a0ebf2d6426
Ruby
GSI/opal
/spec/filters/bugs/module.rb
UTF-8
789
2.546875
3
[ "MIT" ]
permissive
opal_filter "Module" do fails "A class definition has no class variables" fails "A class definition allows the declaration of class variables in the body" fails "A class definition allows the declaration of class variables in a class method" fails "A class definition allows the declaration of class variables in...
true
7a9e06490bb56c668de860d93a8e93a0f06e6ecc
Ruby
fractalis/progchallenges
/codewars/ruby/dragons_curve.rb
UTF-8
1,284
3.78125
4
[]
no_license
=begin The dragon's curve is a self-similar fractal which can be obtained by a recursive method. Starting with the string D0 = 'Fa', at each step simultaneously perform the following operations: replace 'a' with: 'aRbFR' replace 'b' with: 'LFaLb' For example (spaces added for more visibility) : 1st iteration: Fa -> ...
true
671786ddfe2290144071b77405e1aee3d74a31c9
Ruby
jchris/wide-finder-couchdb
/import_log.rb
UTF-8
747
2.703125
3
[]
no_license
require 'rubygems' require 'couchrest' couch = CouchRest.new("http://localhost:5984") db = couch.database('wide-finder') db.delete! rescue nil db = couch.create_db('wide-finder') # usage: ruby import_log.rb logfile.log puts "Each . corresponds to about 12 lines of logfile, or 1 new doc in CouchDB. The # of lines per...
true
2a24e13de23c23226325701b16193b8c7ac34b87
Ruby
curious/em-rtmp
/lib/em-rtmp/connection.rb
UTF-8
5,065
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require "em-rtmp/io_helpers" module EventMachine module RTMP class Connection < EventMachine::Connection include IOHelpers attr_accessor :state, :chunk_size, :channels, :pending_requests # Initialize the connection and setup our handshake # # Returns nothing def initialize ...
true
76bc93b1ae44883449507a905191f4b8b11345c9
Ruby
jdruk/reports
/projetossp/app/models/district.rb
UTF-8
999
2.6875
3
[]
no_license
class District < ActiveRecord::Base # Injeção de funções de auditória audited is_impressionable # Relacionamentos belongs_to :district has_many :districts # Distritos superiores def fathers_districts fathers_districts = Array.new current_district = self ...
true
efa3683af968f14f41d0266b02dc6b98fe4d5782
Ruby
basham/oncheckin-rails
/app/models/affiliation.rb
UTF-8
2,554
2.6875
3
[]
no_license
# == Schema Information # # Table name: affiliations # # id :integer not null, primary key # participant_id :integer # chapter_id :integer # recorded_attendance_count :integer default(0) # recorded_host_count :integer defau...
true
c0d93d35c8ce5393d2e58a5e64a69ec8379b9e12
Ruby
svs/misfit
/app/controllers/rule_books.rb
UTF-8
3,139
2.578125
3
[ "MIT" ]
permissive
class RuleBooks < Application # provides :xml, :yaml, :js def index @rule_books = RuleBook.all.paginate(:page =>params[:page],:per_page => 5) display @rule_books end def show(id) @rule_book = RuleBook.get(id) raise NotFound unless @rule_book display @rule_book end def new only_pro...
true
b4ffb2242554b72bbc5dbdd7df4cfef39fa63cd8
Ruby
tadachi2/emo_phrase
/lib/emo_phrase/tweet.rb
UTF-8
2,645
2.859375
3
[ "MIT" ]
permissive
# -*- encoding:utf-8 -*- # # EmoPhrase::Tweet # #====================================================================== require "twitter" #require "json" module EmoPhrase class Tweet attr_accessor :id, :consumer_key, :consumer_secret, :access_token, :access_token_secret, :cycle_limit TWEETS_NU...
true
954124e0f57385c2b56d2d59e07ffab11678cdf2
Ruby
tauinbox/coursera-stanford-algorithms
/c3-greedy-algorithms/m4-solution/final-exam-extra-analysis/final_exam_question_6.rb
UTF-8
4,581
3.796875
4
[]
no_license
# Schedule jobs in order of chosen criterion # 1 - No greedy rule used (unsorted order) # 2 - Sorting by d * p # 3 - Sorting by p # 4 - Sorting by d # We are given as input a set of n jobs, where job j has a processing time pj and a deadline dj. # Recall the definition of completion times Cj from the video lectures....
true
a822f47d530ce628b1266e132470b1f7f9992009
Ruby
salizzar/reel-example
/lib/producer.rb
UTF-8
1,358
2.578125
3
[ "Unlicense", "LicenseRef-scancode-public-domain" ]
permissive
# -*- encoding: UTF-8 -*- class Producer include Celluloid, Celluloid::Logger attr_reader :flights attr_accessor :terminate def initialize @flights = [] @terminate = false end def retrieve info("Trying to get all flights in Brazil. Thread #{Thread.current}") url = 'http://planefinder....
true
462b0413754b2d580e51561ce29ee5a2d9261607
Ruby
jweir/goalkeeper
/lib/goalkeeper/set.rb
UTF-8
1,700
3.609375
4
[ "MIT" ]
permissive
module Goalkeeper # Set is an Array of Goals to simplify tracking multiple goals. # Since Set is an array, you have all Array methods available. # # Create a new set # myset = Goalkeeper::Set.new # # Add Goals you want to check for completion # myset.add("job1").add("job2") # myset.size # #=...
true
e73762abbe6268c14ed4017e0935ab929aeff374
Ruby
evansenter/hubris
/source/test/test_helper.rb
UTF-8
524
2.53125
3
[]
no_license
require "rubygems" require "mocha" require "test/unit" require File.join(File.dirname(__FILE__), "..", "initializers", "runner.rb") class Test::Unit::TestCase private def assert_lex(string, *args) token_list = args.flatten.each_slice(2).inject([]) { |tokens, token_type| tokens << token(*token_type) } << eo...
true
f837a3db737495ade920bff50eb4d2f3746c1699
Ruby
jkr2255/jsrt.rb
/spec/jsrt/context_spec.rb
UTF-8
1,340
2.578125
3
[ "MIT" ]
permissive
require 'spec_helper' describe JSRT::Context do let(:context) { JSRT::Context.new } let(:context2) { JSRT::Context.new } it 'cannot be duplicated' do expect { context.dup }.to raise_error(TypeError) end it 'has #set_context method' do expect { context.set_context }.not_to raise_error end descr...
true
bb7a8941c28164e66211979abc6d772774aacd45
Ruby
payutp/snapback
/test/unit/user_test.rb
UTF-8
729
2.6875
3
[]
no_license
require 'test_helper' class UserTest < ActiveSupport::TestCase test "rating return on time" do user = User.new prev_rating = user.rating curr_date = DateTime.new(2013, 5, 1) return_date = DateTime.new(2013, 5, 2) user.update_rating(curr_date, return_date) assert user.rating == prev_rating end...
true
aa11ef27e87fc7fd0188c77d23af56023259b784
Ruby
machen2/ruby-music-library-cli-v-000
/lib/music_library_controller.rb
UTF-8
2,159
3.796875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class MusicLibraryController def initialize(path = "./db/mp3s") importer = MusicImporter.new(path) importer.import end def call input = "" while input != "exit" puts "Hello! Welcome to your Music Library!" puts "What would you like to do?" puts "You can (a) list songs, (b) lis...
true
f37cbe79bd5b2e854573d6870240c7352d9fc684
Ruby
XabAyca/HelJ
/app/helpers/projects_helper.rb
UTF-8
557
2.578125
3
[]
no_license
module ProjectsHelper def project_owner? @project = Project.find(params[:id]) if current_user.id != @project.owner.id redirect_to projects_path, notice: "Vous devez être le propriétaire du projet pour accèder à cette partie" end end #helper to handle sorting def sorting_as_label(arr, s...
true
f232cd7e521414aba7996abfac3a4bf09c78a867
Ruby
lubo4kaTarasenko/MA_blog
/lib/tasks/user.rake
UTF-8
832
2.578125
3
[]
no_license
require 'csv' require 'pry' namespace :user do desc 'USER_IMPORT' task import: :environment do path = ENV['path'] users = [] headers = nil CSV.foreach(path, headers: true, header_converters: :symbol) do |row| headers ||= row.headers users << row end users_attributes = users.map...
true
6f25b0460c8f8d601d00a3c1cf8341e8e944b9bc
Ruby
IAmTechieChic/ShoeStore-Test
/lib/shoe.rb
UTF-8
324
3.5
4
[]
no_license
class Shoe attr_accessor :name, :description, :image_path, :price def initialize(name, description, image_path, price) self.name = name self.description = description self.image_path = image_path self.price = price end def valid_price? if price > 0.00 return true else return false end end ...
true
ce6debf713737c8103d8786d13adcbdb32a2f5f5
Ruby
Manbo-/Erase
/lib/erase/methods.rb
UTF-8
270
2.859375
3
[ "MIT" ]
permissive
def Erase(strings, *patterns) opts = patterns.extract_options! method = opts[:once] ? :sub : :gsub patterns.inject(strings) do |s, pattern| s.send(method, pattern, "") end end def Erase!(strings, *patterns) strings.replace(Erase(strings, *patterns)) end
true
e85453e4f3fca26b5e56116893922dfee7af0a11
Ruby
jenselg/simple-discord-bot
/bot.rb
UTF-8
2,549
2.984375
3
[]
no_license
require 'discordrb' require 'rubygems' require 'nokogiri' require 'open-uri' @discord_token = '' @client_id = '' bot = Discordrb::Commands::CommandBot.new token: @discord_token, client_id: @client_id, prefix: '!' # Youtube Search bot.command :yt do |event, *words| combined_term = "" words.each do |word| comb...
true
d2389d8ba306048364dbd172c8fc69ca79d8a10f
Ruby
victoriak94/classmethodsandclassvariables
/part1.rb
UTF-8
1,187
3.953125
4
[]
no_license
class BankAccount @@accounts = [] @@interest_rate = 0.02 def initialize @balance = 0 end #Reader def balance return @balance end #Writer def balance=(balance) @balance = balance end def deposit(amount) @balance += amount end def withdraw(amount) @balance -= amount ...
true
c0c9917391df86da1d81f514ee12b7e58aebd2d6
Ruby
yuta-pharmacy2359/ruby_tutorial
/第2章/Sample2_11_1.rb
UTF-8
690
4.1875
4
[]
no_license
def greeting(country) if country == 'japan' 'こんにちは' else 'hello' end end #puts greeting (引数が少ないためエラー) puts greeting('japan') #puts greeting('japan', 'us', 'vietnam') (引数が多すぎるためエラー) def greeting2(country = 'japan') if country == 'japan' 'こんにちは' else 'hello' end end puts greeting2 puts greet...
true
566158f8c6ea6a470f365c0d6859bfceac878fee
Ruby
catawiki/aftership-sdk-ruby
/lib/aftership/v4/base.rb
UTF-8
2,513
2.515625
3
[ "MIT" ]
permissive
require 'httpclient' require 'json' module AfterShip module V4 class Base class AfterShipError < StandardError; end attr_reader :http_verb_method, :end_point, :query, :body def initialize(http_verb_method, end_point, query = nil, body = nil) @http_verb_method = http_verb_method ...
true
0003f7bc4cbcad6c1a6542d9082210b3b0859aad
Ruby
nukisashineko/my_program_warehouse
/ruby/older_making_items/gmail/read_koko_lately
UTF-8
335
2.5625
3
[]
no_license
#!/usr/bin/ruby # -*- coding : utf-8 -*- user = "<gmail user>" pass = "<gmail pass>" require './gmail_func' def usage puts "\ argment error ... \n\ Usage: #{File.basename $0}" exit end #main start usage unless ARGV.length ==0 Gmail.new(user,pass) do |gmail| email=read_lately_mail(gmail) read_mail(email)...
true
d65687fe1107692d4111ed46eb0396550a7f2519
Ruby
proton/space_invaders_detector
/lib/space_invaders_detector/image.rb
UTF-8
1,332
3.484375
3
[ "MIT" ]
permissive
module SpaceInvadersDetector class Image attr_reader :width, :height SPACE_SYMBOL = '-' OBJECT_SYMBOL = 'o' SYMBOL_VALUES = { SPACE_SYMBOL => 0, OBJECT_SYMBOL => 1 } def initialize(init_data = nil) case init_data when Array load_image init_data when String load_...
true
66565df7f7e305cd6d43b41d783db88fc4126cfa
Ruby
skawouter/project-euler-solutions
/problem7.rb
UTF-8
625
3.90625
4
[]
no_license
#problem_7 bis def isprime(number) count = number-2 while count > 1 if number % count == 0 return false end count -= 2 end return true end number = 1 arr = [] count = 4 arr.concat([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]) #remain...
true
fa66dd2214f5b9a3ef48665660e66ba4e4f5a410
Ruby
GCPix/w2d1_homework
/team_class.rb
UTF-8
533
3.25
3
[]
no_license
class SportsTeam attr_accessor :team_name, :players, :coach, :points def initialize(team_name, player_array, coach, total_points) @team_name = team_name @players = player_array @coach = coach @points = total_points end def add_player(player_name) @players.push(player_name) end def find_player...
true
b3f38cc01abbfeb97bf40f16dec06303901de072
Ruby
vbalazs/legendary-octo-waffle
/test/paginated_collector_test.rb
UTF-8
2,085
2.546875
3
[ "BSD-3-Clause" ]
permissive
# frozen_string_literal: true class TestPaginatedCollector < Minitest::Test def setup @client = Minitest::Mock.new @parser = Minitest::Mock.new @repo = PaginatedCollector.new(client: @client, parser: @parser) end def test_load_next_page_when_unsuccessful response = MtgApiResponse.new(success?: f...
true
22f5473ad0376dec0db0aefe51cedd02bede50fa
Ruby
dallasmarlow/school_zone
/lib/school_zone/integer.rb
UTF-8
235
2.5625
3
[]
no_license
class Integer def times_in interval, &block interval = SchoolZone::Interval.new *interval.flatten self.times do |i| interval.checkpoint = Time.now yield if block_given? interval.adjust i end end end
true
ad302f8098c43e8abb207586188688062c5600e7
Ruby
CodeCoreYVR/november_fundamentals
/break.rb
UTF-8
73
3.09375
3
[]
no_license
a = 0 while a < 50 break if a == 30 puts a a += 1 end puts "hey"
true
66082ba5cec884c55b5ccd1aa8d4bc6df6edb5c3
Ruby
amandeep1420/RB101
/RB101/Small Problems/E8r2/3_substrings.rb
UTF-8
709
4.21875
4
[]
no_license
=begin P - write a method that returns a list of all substrings of a string that start at the beginning of the original string. the return value should be arranged in order from shortest to longest substring - input: string - output: array - note: example strings are all lowercase w/ no symbols or nu...
true
72de0f8065950a361a1be89b61163a67b1dc6b00
Ruby
benaubin/graphql-model
/spec/graphql/model/base_spec.rb
UTF-8
1,254
2.78125
3
[ "MIT" ]
permissive
require "spec_helper" class Character < GraphQL::Model::Base attributes :name, :appears_in graphql_path "http://graphql-ruby-demo.herokuapp.com/queries" define_query :hero do def query(episode: :Episode) f = fragment super do hero(episode: episode) do _ f end end...
true
6f8c6fb9ca30969e97e5ed54f30ff169b2c056a6
Ruby
sul-dlss-labs/etd_structure_classifier
/etd_structure_classifier.rb
UTF-8
2,736
3.125
3
[ "Apache-2.0" ]
permissive
require 'nbayes' class EtdStructureClassifier def inspect "<EtdStructureClassifier id=\"##{object_id}\" persisted=\"#{persisted?}\">" end def persist! model.dump(persisted_model) self end def persisted? File.exists?(persisted_model) end def clear! File.delete(persisted_model) if p...
true
02b3fbfecdd8b0df59bedd38e4575317676613f5
Ruby
npatel007/Computer-Science-Notes
/Ruby/RubyLect3.progs/-_RubyLect3.progs/defblock.rb
UTF-8
170
2.84375
3
[]
no_license
########### # DEFBLOCK ## Copyright Mark Keane, All Rights Reserved, 2013 def add_two(no) no += 2 end p add_two(5) def add_two_b yield(10) end p add_two_b {|no| no + 2}
true
275ac4d8e92d564e1da7c49450bc49090129eea8
Ruby
julieharrow/ruby-practice
/chatWithGrandma.rb
UTF-8
1,068
3.875
4
[]
no_license
#Chat with grandma - unless you shout at her, she can't hear you. And even if she can hear you, she has limited responses about the good ol' days. If you want the conversation, you have to shout 'BYE' at least three times in a row. puts 'Chat with Grandma: ' byeCounter = 0 while byeCounter < 3 responseToGr...
true
7124277542aa5bee46d70147592fbead35bed358
Ruby
tenderlove/tree_diff
/test/test_merge.rb
UTF-8
1,475
2.640625
3
[ "MIT" ]
permissive
require "test/unit" require 'rubygems' require "tree_diff" class TestMerge < Test::Unit::TestCase def setup @html = <<-eohtml <html> <body> <table> <td> </table> </body> </html> eohtml @ndoc = TreeDiff::Unify.new('nokogiri').accept(Nokogiri::HTML(@html).root)...
true
21b420e0a6cefe80c6c95eab981dfa5a816af820
Ruby
amy-chinlai/ttt-game-status-ruby-intro-000
/lib/game_status.rb
UTF-8
764
3.6875
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Helper Method def position_taken?(board, index) !(board[index].nil? || board[index] == " ") end WIN_COMBINATIONS = [ [0, 1, 2], [0, 4, 8], [0, 3, 6], [3, 4, 5], [6, 4, 2], [1, 4, 7], [6, 7, 8], [2, 5, 8] ] def won?(board) winning_combination = WIN_COMBINATIONS.detect do |combination| board[c...
true
651ad9109f3a93f380da58a22fc8babe725c42ee
Ruby
PaulWallis42/lab_wk_battleships
/lib/board.rb
UTF-8
201
3.421875
3
[]
no_license
class Board attr_reader :content, :size def initialize(size) @content = [] @size = size end def add_cell(cell) @content << cell end def shoot @content[0].shoot end end
true
011888f9bc85d77ff44945617bd0f86ab86b6a08
Ruby
bohdanmykytey/Ruby
/uber.rb
UTF-8
862
3.78125
4
[]
no_license
=begin Being a new Uber user, you have $20 off your first ride. You want to make the most out of it and drive in the fanciest car you can afford, without spending any out-of-pocket money. There are 5 options, from the least to the most expensive: "UberX", "UberXL", "UberPlus", "UberBlack" and "UberSUV". ...
true
00df2c23e2f6cf7e7905c369104f90bf96ef0f82
Ruby
mohammadaliawan/ginni_rb120_rb129
/exercises/easy_2/02.rb
UTF-8
286
3.21875
3
[]
no_license
# Correct the program # Assume the Car class has complete implementation # Ensure that cars have access to #drive module Drivable # remove `self` to change drive from class to instance method def drive end end class Car include Drivable end bobs_car = Car.new bobs_car.drive
true
b6811d201afc124fb85526d6ba8ed1e9ec85f1d9
Ruby
mcquackers/Metis
/Week1/day3/locker.rb
UTF-8
539
3.515625
4
[]
no_license
class Locker def initialize @lockers = Array.new(100, "closed") end def gamestart (1..100).each do |student| (1..100).each do |locker| if locker%student == 0 toggle(locker-1) end end end @lockers.each_with_index {|state, locknum| puts "Locker \##{locknum+1} is...
true
9f34f36c083e62dfb6c575c7e1e469e68eb3fa04
Ruby
47primes/adherence
/lib/adherence/class.rb
UTF-8
3,939
3.171875
3
[ "MIT" ]
permissive
module Adherence class NotAdheredError < NotImplementedError; end module Class private def adheres_to(*mods) @adhered_modules = [] mods.each {|mod| adheres_to_module mod} class_eval do def self.method_added(method) @adhered_modules.each do |mod| if mod.ins...
true
82cb222423e63750f3da57ea184812247939d793
Ruby
Sorasky9/ruby-music-library-cli-onl01-seng-pt-032320
/lib/song.rb
UTF-8
1,129
3.828125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_accessor :name, :artist, :genre @@all = [] def initialize(name, artist = nil, genre = nil) @name = name if artist != nil self.artist = artist #This if statement here is saying if the artist is NOT nil, then artist has a name and self.artist is assigning the song to it's #associat...
true
4688add302dd5ac2045e296977415dd3d684a0e5
Ruby
iamjoshbinder/Waves
/lib/authentication.rb
UTF-8
1,879
2.546875
3
[]
no_license
module Authentication def self.included(controller) controller.send(:include, InstanceMethods) controller.extend(ClassMethods) end module ClassMethods def self.extended(controller) controller.helper_method :current_user, :signed_in?, :signed_out? controller.hide_action :current_user, :...
true
4591d5376f620383d3f0533d8d58b8249eca4f4b
Ruby
zachholcomb/credit_check
/lib/credit_card.rb
UTF-8
289
2.9375
3
[]
no_license
require './lib/credit_check' class CreditCard include CreditCheck attr_reader :number, :limit def initialize(number, limit) @number = number @limit = limit end def last_four @number[12..15] end def is_valid? split_card_number_into_array(@number) end end
true
69bbaab319f6caad5282b4426944694614219b74
Ruby
Zrp200/time2
/bin/time2
UTF-8
937
3.015625
3
[]
no_license
#!/usr/bin/env ruby require 'time2' include time2 BEGIN { case ARGV[0] when '--help' then ARGV[0] = '-h' when '--timer' then ARGV[0] = '-t' when '--clock' then ARGV[0] = 'c' when '--stopwatch' then ARGV[0] = '-s' when '--version then ARGV[0] = '-v' end } case ARGV[0] when '-v' puts "0.0.0.pre exit whe...
true
d7a994f0c811af7ff7383745627207ffe459ffe2
Ruby
maxluzuriaga/project_euler
/problem_24.rb
UTF-8
1,000
4.3125
4
[]
no_license
# A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: # 012 021 102 120 201 210 # Wh...
true
0cd0b11f167c39f3ce252adee3e19870aed4faf9
Ruby
Mange/organ
/lib/matching_file.rb
UTF-8
550
2.859375
3
[ "LicenseRef-scancode-public-domain" ]
permissive
# encoding: UTF-8 require 'fileutils' class MatchingFile attr_reader :name, :path def initialize(path, ui) @ui = ui @path = path @name = File.basename path end def move_to(destination_dir, new_name = @name) new_dir = File.expand_path destination_dir new_path = File.join new_dir, new_name ...
true
8864bad8d723e73effee079324e126b03a995b10
Ruby
Antonina23/rspec
/car.rb
UTF-8
533
3.6875
4
[ "MIT" ]
permissive
class Car # если написать это маленькими буквами - def range не будет считаться - будет писать - строка не может быть умножена на число MILES_PER_GALLON = 20 attr_reader :fuel def initialize @fuel = 0 end def add_fuel amount @fuel += amount end # как далеко мы сможем проехать: def range ...
true
7a0b4278de549d161af4a6bfeb6880cffadf6d51
Ruby
jeffmbellucci/Bart-App
/lib/text.rb
UTF-8
579
2.78125
3
[]
no_license
class Text def initialize(phone_number, message) @phone_number = phone_number @message = message @account_sid = ENV['TWILIO_ACCOUNT_SID'] @auth_token = ENV['TWILIO_AUTH_TOKEN'] @client = Twilio::REST::Client.new(@account_sid, @auth_token) @account = @client.account # set up a cl...
true