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
272bf5151d962ae1e0b670f248c39951467a2b61
Ruby
gensym/traveling-santa
/traveling_santa.rb
UTF-8
1,373
3.578125
4
[]
no_license
require 'csv' require 'haversine' require 'byebug' def destinations CSV.read('nice-kid-cities.csv', headers: true).map(&:to_h).map do |i| { city: i["City"], state: i["State"], lat: i["Latitude"].to_f, lon: i["Longitude"].to_f } end end def miles_between(loc1, loc2) Haversine.dis...
true
cec12b8852de3c42081e3df415325993934763f3
Ruby
lugray/advent_of_code
/2019/day15.rb
UTF-8
1,445
3.171875
3
[]
no_license
#!/usr/bin/env ruby require_relative 'day' require_relative 'intcode' require 'io/console' class Found < StandardError; end class Robot def initialize(input) @intcode = Intcode.new(input.split(',').map(&:to_i)) @x = 0 @y = 0 end def go(dir) case dir when 1 @y += 1 when 2 @y...
true
315061f8bea3128ad53917f0c7c6d5e232b5e796
Ruby
vanekpe8/MI-RUB-Homeworks
/Uloha5/lib/InputLoader.rb
UTF-8
1,694
3.546875
4
[]
no_license
require_relative 'Instances.rb' module MinimalCoverageProblem #This class is responsible for creating InputInstances. The input is loaded from a file. class InputLoader #Creates new instance of InputLoader. "file" is a text file which contains input data. def initialize(file) raise "Invalid file type...
true
868c8cd3016d06b718aa54b9cf7b66131e1c0b3d
Ruby
ledewitt/sandbox
/ruby_chin_ups/2_TODO/todo2.rb
UTF-8
703
3.421875
3
[]
no_license
list = [ ] checked = [ ] puts "Enter an action (a = add, c = check off, q=quit): " while input = gets.strip if input == "a" puts "Enter a list item: " list << gets.strip elsif input == "c" puts list puts "Type an item to checkoff: " checkoff = gets.strip checked << checkoff list.delete...
true
eda03cf20c2c787a23ed1cc6bfa7dd59c71c5fb4
Ruby
CassandraCH/Nurikabe
/Affichage/Fenetre.rb
UTF-8
5,482
2.90625
3
[]
no_license
require 'gtk3' require_relative '../Parametres/Parametre.rb' require_relative '../Parametres/Langue.rb' require_relative '../Sauvegarde/Sauvegardes.rb' require_relative '../Sauvegarde/SauvegardeGrille.rb' require_relative '../Sauvegarde/StockageGrille.rb' ## # Classe abstraite qui gere l'interface # DESIGN PATTERN SIN...
true
284a4a006e92223722612d3ea8ebd4e747c23e63
Ruby
Virtuoel/DiscordBot
/modules/multimedia/avatar.rb
UTF-8
459
2.5625
3
[ "MIT" ]
permissive
$bot.command(:avatar, min_args: 0, description: "Get the URL of a user's avatar", usage: "avatar <username|mention|\"server\">") do |event, *args| ret = event.user.avatar_url if(args.length > 0) if(args[0] == "server") Discordrb::API.icon_url(event.channel.server.id, event.channel.server.icon_id) else user...
true
394014ed76a3ab39ffa7d3759518ab2e727bac14
Ruby
vojto/active_harmony
/lib/active_harmony/synchronizer.rb
UTF-8
4,199
2.578125
3
[ "MIT" ]
permissive
# encoding: utf-8 module ActiveHarmony class Synchronizer attr_accessor :factory, :service, :configuration ## # Initializes new Service Synchronizer to do some # synchronizing magic. def initialize @contexts = {} @configuration = SynchronizerConfiguration.new end ## ...
true
dbd59b34d8d06f7d78ebfb303ad8dfccada07db5
Ruby
pwnall/coninference
/app/models/concerns/push_receiver.rb
UTF-8
1,207
2.53125
3
[]
no_license
require 'base64' require 'net/http' require 'net/https' require 'openssl' require 'uri' module PushReceiver extend ActiveSupport::Concern included do # The endpoint URL for pushing notifications to this device. validates :push_url, length: { in: 1..256, allow_nil: true } end # Server signature for th...
true
4ca19a5fd26027996d68f102653328a7eb8765f3
Ruby
jstricklin89/module-one-final-project-guidelines-houston-web-082718
/lib/user.rb
UTF-8
2,040
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class User < ActiveRecord::Base has_many :favorites has_many :beers, through: :favorites has_many :styles, through: :beers has_many :breweries, through: :beers has_many :categories, through: :beers def add_favorite(id) Favorite.create(user_id: self.id, beer_id: id) end def delete_favorite(id) ...
true
67bbcc43ff5ef80f887bcdc86d873779f1463005
Ruby
labzunova/3-semesterBMSTU
/LR7/7.2/test.rb
UTF-8
654
3.078125
3
[]
no_license
# frozen_string_literal: true require 'minitest/autorun' require_relative 'circle' require_relative 'sphere' # testing circle and sphere class TestMath < Minitest::Test def setup; end def test_first sphere = Sphere.new(1, -1, 2) assert(sphere.is_a?(Circle)) end def test_second circle = Circle.ne...
true
4dc2f3985a307deee08f2fbec3ef968d148f8e2b
Ruby
btazi/rbnd-survivr-part2
/lib/game.rb
UTF-8
523
3.25
3
[]
no_license
class Game attr_reader :tribes, :immune def initialize *tribes @tribes = tribes end def add_tribe(tribe) @tribes.push(tribe) end def immunity_challenge @tribes.sample end def individual_immunity_challenge @tribes.first.members.sample end def clear_tribes @tribes = [] end def merge(name) me...
true
04cb8eef7d84f3e0e81cbac9eebc598070d9d614
Ruby
jtb6179/active-record-associations-methods-dumbo-web-120919
/app/models/song.rb
UTF-8
882
2.71875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song < ActiveRecord::Base belongs_to :artist belongs_to :genre def get_genre_name #binding.pry gen_instance = Genre.all.find do |gen| gen.id == self.genre_id end gen_instance.name end def drake_made_this # when this method is called it should assign the song's artist to Drak...
true
1a6ad8351c18a91a91025185f9ade938e2b52fa1
Ruby
Xetelar/RoR_study
/homework_5/train.rb
UTF-8
1,915
3.390625
3
[]
no_license
require_relative 'instance_counter.rb' require_relative 'company_accessor.rb' class Train include CompanyAccessor include InstanceCounter attr_reader :speed, :cars @@trains = {} NUMBER_FORMAT = /^([a-z]|\d){3}-?([a-z]|\d){2}$/i TYPE_FORMAT = /^(cargo|passenger)$/i def self.find(number) @@trains[n...
true
7e7c024da43fe08fb24fb9cc493d85c3d6acf7a3
Ruby
MikhailProekt/thinknetica
/lesson1/ex2.rb
UTF-8
233
3.46875
3
[]
no_license
puts "Введите основание треугольника a:" a = gets.chomp.to_f puts "Введите высоту треугольника h:" h = gets.chomp.to_f puts "Площадь треугольника: #{(a * h)/2}"
true
eb2f45549b96579fd05a1e2c20e70244721ec1f8
Ruby
sensu-plugins/sensu-plugins-network-checks
/bin/check-ports.rb
UTF-8
2,687
2.703125
3
[ "MIT" ]
permissive
#! /usr/bin/env ruby # frozen_string_literal: true # # check-ports # # DESCRIPTION: # Connect to a TCP/UDP port on one or more ports, to see if open. Don't use nmap since it's overkill. # # OUTPUT: # plain text # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: sensu-plugin # # USAGE: # # Ports are comma separa...
true
b009aacb435021c85acb4a2a43a5f023de27c1b5
Ruby
Xabier-Casan-Abia/oo-relationships-practice-london-web-career-040119
/app/models/bakery/bakery.rb
UTF-8
879
3.421875
3
[]
no_license
class Bakery attr_reader :name @@all = [] def initialize(name) @name = name @@all << self end def self.all @@all end def desserts Dessert.all.select {|dessert| dessert.bakery == self} # - should return an array of desserts the bakery makes end def ingredients desserts.map { ...
true
7e4c070aae7bf77479b01d26f22966e829a1e9d4
Ruby
wymerkd/Anagrams
/lib/anagram_logic.rb
UTF-8
1,739
3.890625
4
[ "MIT" ]
permissive
class Anagram attr_accessor(:first_word, :second_word) def initialize(first_word, second_word) @first_word = first_word.tr(' ~!@#$%^&*()_\+{}|:<>?[]\;,./-','').downcase().split('').sort() @second_word = second_word.tr(' ~!@#$%^&*()_\+{}|:<>?[]\;,./-','').downcase().split('').sort() end #Checks if both...
true
458cfbaa4cb71cf38395d848045f9638e5806f67
Ruby
dalspok/exercises
/small_problems/easy_1/3.rb
UTF-8
582
4.0625
4
[]
no_license
# def digit_list(num) # arr = [] # while num > 0 # arr.unshift(num % 10) # num /= 10 # end # arr # end # def digit_list(num) # num.to_s.chars.map{|i| i.to_i} # end # def digit_list(num) # arr = [] # num.to_s.each_char{ |i| arr << i.to_i } # arr # end def digit_list(num) string = num.to_s ...
true
8b523b73faae63b2e94cbdb633546cc0aa81b44b
Ruby
compsciacademy/fulltime-program-2021-Q2
/Week04/Day17/homework_review/order_item.rb
UTF-8
689
3.109375
3
[]
no_license
class OrderItem attr_reader :name, :price, :order def initialize(order, name, price) @order, @name, @price = order, name, price @order.add_item(self) end def save File.open('order_items', 'a') do |file| file.write("#{@order.order_number}, #{@name}, #{@price}\n") ...
true
08e0779b3cdd52d0772514a395ab1f8990ff7735
Ruby
Atul9/rubylearning56
/1_week/3c_text_formatting.rb
UTF-8
4,844
3.140625
3
[]
no_license
=begin This one has been out there for a little while, it is a common problem with writing reports, etc. What the challenge is write a program that provides the following output, with the following sample of use. The output is shown first, I will make some notes about it to pay attention to below: Times Table to 9 =...
true
b27e7e91f1d8f7b7e19479285c4893a88c232569
Ruby
AlexLOvch/rpn_calc
/spec/caclulators/rpn_calculator_spec.rb
UTF-8
1,652
2.734375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'spec_helper' module RpnCalc RSpec.describe Calculators::RpnCalculator do describe '#process' do context 'when options are empty' do subject(:calculator) { described_class.new } it 'should return stack with right calculated result' do expect...
true
0d5952419d42eac946dcd133316f8242477d097d
Ruby
guitsaru/json_paths
/lib/json_paths.rb
UTF-8
1,033
3.15625
3
[ "MIT" ]
permissive
require "json_paths/version" require 'json' class JsonPaths include Enumerable attr_reader :json attr_reader :paths def initialize(json) @json = json @paths = json_to_paths end def each paths.each end def json_to_paths parsed_json = JSON.parse(json) paths = [] parsed_json....
true
c3149ae0204a96b8f877564d52d4f4d36d50393f
Ruby
evheny0/bsuir-labs
/model/lab3/queue.rb
UTF-8
339
2.921875
3
[]
no_license
require './block.rb' module Blocks CAPACITY = 1 class Queue < Block def add_request return false if state == CAPACITY @state += 1 unless @next_block.add_request true end def pop_pending_request return 0 if @state == 0 @state += @prev_block.pop_pending_request - 1 1...
true
4f546f93e29ff0ffad69671333398366871d1e4d
Ruby
Marin-b/amandla-old
/app/components/category/icon.rb
UTF-8
650
2.515625
3
[]
no_license
# frozen_string_literal: true class Category::Icon < ViewComponent::Base attr_reader :category, :options def initialize(category, options = { classes: 'fa-lg'} ) @category = category @options = options end def icon_class case(category.name) when 'Bar' return 'fas fa-glass-martini-alt' ...
true
ebccefc04471e236fbe3b12c759a200aec8f762d
Ruby
kitofr/pentago
/lib/pentago/square.rb
UTF-8
947
3.765625
4
[]
no_license
class Square attr_reader :square def initialize(square = 3.times.collect{ %w{. . .} }) @square = square end def place(x,y,who) return false unless @square[y][x] == '.' @square[y][x] = who end def rotate(direction) other = self.clone other.rotate! direction other end def rotate!(direction) ...
true
d94530871f80d8cee3ae8c2cc896cbc0d12804b8
Ruby
andrewkomarov/Loco-OO-XML-parser
/class/output.rb
UTF-8
1,266
3.046875
3
[]
no_license
class Output def initialize(results) @results = results end def to_console @results.each do |r| i=0 print "\nID: #{r.id} | Train Changes: #{r.connections.length-1} | #{r.connections.length} connections:\n" print "=======================================================================\n...
true
2316847abb276306c42b42153180bce2d81d3189
Ruby
guorui9016/ruby
/task39.rb
UTF-8
171
3.046875
3
[]
no_license
# read data from 1 file and display data only written in odd number of lines file = File.open('file3', 'r') until file.eof? p file.readline.chomp file.readline end
true
a66fe70b69ca045cd15045ad2a763d1563a4ca2e
Ruby
DSJR1284/anime_films
/lib/anime_films/films.rb
UTF-8
729
3.5625
4
[ "MIT" ]
permissive
class Films #Takes infomation from the API and initalizes it. attr_accessor :title, :description, :release_date #Makes data accessable to other class. (Reader/Writer Methods) @@all = [] #Class varaible to store the new instances of films. def initialize(title, description, release_date) #th...
true
fec0f13d7f82c4267ccee7990a6b3f397b790871
Ruby
bluz71/jumpstart_tuts_ruby
/event_manager/lib/event_manager.rb
UTF-8
1,800
3.046875
3
[]
no_license
# The Sunlight gem will need to be installed. # % gem install sunlight-congress require 'csv' require 'erb' require 'fileutils' require 'sunlight/congress' STDERR.puts "event_attendees.csv does not exist" unless File.exist?("event_attendees.csv") STDERR.puts "form_letter.erb does not exist" unless File.exist?("form_l...
true
8cce744c305d53efb3e94d549374fb4b8a4cbcde
Ruby
deezy136/ruby-enumerables-introduction-to-map-and-reduce-lab-online-web-prework
/lib/my_code.rb
UTF-8
2,506
3.578125
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# My Code here.... def map_to_negativize(source_array) # source_array.map { |x| x *= -1} final_array = [] counter = 0 while counter < source_array.size do final_array.push(source_array[counter] * - 1) counter +=1 end final_array end #############################################...
true
ab169edb557764cc534badadb88bac61531bc931
Ruby
vladplotnikov/Bootcamp_Notes
/week2/day2/labs/user_info.rb
UTF-8
1,057
4.1875
4
[]
no_license
# Ask the user for the following information: first name, last name and age. # # Then ask them for cities they've visited (they can keep entering until they type "done"). # # Store all the entered data in a hash and then loop through the hash and display results. personal_info = Hash.new(0) puts "What is your First N...
true
5116a0a98bb71d9b8f0b6a8efb50d7860f3b20d6
Ruby
richrace/Mars-Rover-First-Attempt
/util.rb
UTF-8
1,947
4.15625
4
[]
no_license
# Module used instead of class so can use it as Mixin. # Module contains utility methods and constants for the # text module Util # Following constants are used for the Text North/South/ # East/West (N,S,E,W) from inputs. NORTH = "N" SOUTH = "S" EAST = "E" WEST = "W" # Following constants used for movement o...
true
a456031dc9fb9b2bb75d3d7bd2a00c4b925e6e79
Ruby
tfunk2/hayk-assessment-the-bachelor
/lib/bachelor.rb
UTF-8
2,703
3.8125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def get_first_name_of_season_winner(data, season) contestants = data[season] season_winner = contestants.find do |contestant| contestant["status"] == "Winner" end season_winner["name"].split.first end def get_contestant_name(data, occupation) contestants_array = data.values.flatten cont...
true
fe5f91df790ca170ceedda684fe77071171d8c80
Ruby
bruce/rubinius
/kernel/common/objectspace.rb
UTF-8
1,432
2.796875
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module ObjectSpace def self._id2ref(id) ary = [] if find_object([:object_id, Integer(id)], ary) > 0 return ary.first end return nil end # @todo rewrite each_object # Tryes to handle as much as it can. def self.each_object(what=nil, &block) return to_enum :each_object, what unless...
true
b7d316a1f4cec5e9fb55e83517686a02c9f849cf
Ruby
deLeon/sample_app
/app/helpers/application_helper.rb
UTF-8
2,026
2.765625
3
[]
no_license
module ApplicationHelper def logo logo = image_tag("logo.png", :alt => "Sample App", :class => "round") end def title base_title = "Ruby on Rails Tutorial Sample App" if @title.nil? base_title else "#{base_title} | #{@title}" end end ## Exercise 11.5.1 def warn_if_char_cou...
true
36466815c734472a93609f910cc98d327de4f528
Ruby
bkoski/s3-publisher
/lib/s3-publisher.rb
UTF-8
5,362
2.75
3
[ "MIT" ]
permissive
require 'zlib' require 'thread' require 'pathname' require 'aws-sdk' require 'mime-types' # You can either use the block syntax, or: # * instantiate a class # * queue data to be published with push # * call run to actually upload the data to S3 class S3Publisher attr_reader :bucket_name, :base_path, :logger, :wo...
true
1191be3742344b11a7327d1b8c5184eab9c79e59
Ruby
Ralphasaurus/rb101
/small_problems/easy9/problem_8.rb
UTF-8
1,177
4.25
4
[]
no_license
# Create a method that takes two integers as arguments. The first argument is a count, # and the second is the first number of a sequence that your method will create. The # method should return an Array that contains the same number of elements as the count # argument, while the values of each element will be multiple...
true
92164c03ccbc70ece7c9a89ad6a3ca4539c0dcc7
Ruby
danielhofmann600/2018_3AHIF_SYP_Fahrgemeinschaft
/project/app/controllers/v1/user_controller.rb
UTF-8
863
2.515625
3
[]
no_license
require 'json' module V1 class UserController < ApplicationController def cors_set_access_control_headers headers['Access-Control-Allow-Origin'] = '*' headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' headers['Access-Control-Allow-Headers'] = '*' end def index # GET users = ...
true
448365ee1b3751c012b73dc9b588da8052bec8e3
Ruby
kalyanghosh/Ruby-Ruby_On_Rails
/hashes.rb
UTF-8
257
3.421875
3
[]
no_license
class Hashes end other_hash={'WB'=>"West Bengal",'AP'=>"Andra Pradesh"} puts other_hash.length puts other_hash.empty? puts other_hash.has_key?('WB') puts other_hash.has_key?('D') puts other_hash['WB'] puts other_hash.values puts other_hash.keys
true
ade4983d37a3a11faee3ecc9eabab6aa98948430
Ruby
Adyen/adyen-ruby-api-library
/lib/adyen/services/service.rb
UTF-8
1,120
2.734375
3
[ "MIT" ]
permissive
module Adyen class Service attr_accessor :service, :version # add snake case to camel case converter to String # to convert rubinic method names to Adyen API methods # # i.e. snake_case -> snakeCase # note that the first letter is not capitalized as normal def self.action_for_method_name(...
true
7202665c8d95f045a793a153e264b21f483d84d0
Ruby
rchavarria/twitterise
/lib/twitterise.rb
UTF-8
868
2.859375
3
[ "MIT" ]
permissive
require_relative "suggestor" require_relative "twitter_client" require_relative "../repository/repository" class Twitterise def initialize @repository = Repository.new @twitter_client = TwitterClient.new @suggestor = Suggestor.new( :repository => repository, :twitter_client => tw...
true
184470d427e74e53f9c23fe4f47dcd201af8eebf
Ruby
adhrinae/exercism
/ruby/hamming/hamming.rb
UTF-8
257
3.125
3
[]
no_license
module BookKeeping VERSION = 3 end class Hamming def self.compute(strand1, strand2) raise ArgumentError unless strand1.length == strand2.length strand1.chars.zip(strand2.chars).reject do |pair| pair[0] == pair[1] end.count end end
true
072023a7b41116dcd07689509fbff7c286d772e1
Ruby
upmysport/adyen_engine
/app/models/recurring_payment_details.rb
UTF-8
920
2.65625
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# An ActiveRecord model representing one payment detail returned by # Adyen::API.list_recurring_details so that the details can be locally # cached in the database. # Currently, this only represents card details, with no inheritance to # accommodate ELV or bank details. class RecurringPaymentDetails < ActiveRecord::Bas...
true
19269e46e25125f0a4cef4564615fbf8ac822dc7
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/633117351b8746f99df36e53354c5270.rb
UTF-8
379
3.75
4
[]
no_license
class Bob def hey(phrase) phrase.strip! unless phrase == nil if phrase == nil or phrase.empty? message = 'Fine. Be that way!' elsif phrase.upcase == phrase message = 'Woah, chill out!' elsif phrase[-1] == '?' message = 'Sure.' else ...
true
f49d6c924b00277f7f604d40530871914ce1bfe1
Ruby
bdurand/fast_serializer
/lib/fast_serializer/serializer.rb
UTF-8
16,870
2.984375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module FastSerializer # Models can include this module to define themselves as serializers. A serializer is used to wrap # an object and output a hash version of that object suitable for serialization to JSON or other formats. # # To define what fields to serialize on the wrapped ...
true
2cbb6dc4e9252d0c88354a8155f8d938c35c8324
Ruby
learn-co-students/dumbo-web-060319
/24-events/test.rb
UTF-8
50
2.546875
3
[]
no_license
def potato "🥔" end p potato p potato()
true
35111d5a01d44e4b91e23c61baff6524cbff690f
Ruby
TIY-ATL-ROR-2015-Sep/blahg
/lib/blahg.rb
UTF-8
2,201
3.4375
3
[ "MIT" ]
permissive
require "blahg/version" require "blahg/init_db" require "blahg/post" require "blahg/tag" require "blahg/post_tag" require "blahg/importer" require "date" require "thor" require "pry" ## Subcommands to add? # # * Show a given page of posts. (DONE) # * Add a new post. (DONE) # * Edit post tags. # * Find posts in a...
true
241899f466dfb863853930c27c5a1359ec62acb6
Ruby
Sinrock/Projectrack
/app/controllers/users_controller.rb
UTF-8
1,908
2.546875
3
[ "MIT" ]
permissive
# frozen_string_literal: true # Users class UsersController < ApplicationController get '/login' do if logged_in flash[:message] = "You're already logged in silly goose!" redirect '/' else erb :'users/login' end end post '/login' do user = User.find_by(email: params[:email]) ...
true
74924045e2bad93f03cf5e4672353fc38441131f
Ruby
CodeMonkeySteve/dht
/lib/dht/poller.rb
UTF-8
1,307
2.640625
3
[ "MIT" ]
permissive
require 'dht/node' require 'em/timers' require 'ruby-debug' include DHT class Poller RefreshPeerAfter = 1.minutes RefreshValueAfter = 1.day attr_accessor :node def initialize( node ) @node = node end def start EM.next_tick { poller } self end protected def poller Fiber.new do ...
true
521215e9950d5a7e3fd0afcf31539ff2e8ac661e
Ruby
0robustus1/ontology-united
/spec/ontology-united/stack_spec.rb
UTF-8
2,801
2.734375
3
[ "MIT" ]
permissive
require 'spec_helper' describe OntologyUnited::Stack do let(:instance) do class Klass include OntologyUnited::Stack end Klass.new end context '.stack' do it 'should be empty per default' do expect(instance.stack).to be_empty end it 'should contain a pushed element' do ...
true
e922163db400f88477e88435533658d4523c15dd
Ruby
ebanh/ttt-with-ai-project-v-000
/bin/tictactoe
UTF-8
1,778
3.875
4
[]
no_license
#!/usr/bin/env ruby require_relative '../config/environment' def welcome @number_of_players = nil until @number_of_players == "0" || @number_of_players == "1" || @number_of_players == "2" || @number_of_players == "wargames" puts "How many players will play?" @number_of_players = gets.strip end end def ...
true
3a4da85274b31cf323d8416e468dc219dde8658e
Ruby
delightech/rails-example
/app/presenters/staff_member_presenter.rb
UTF-8
1,031
2.890625
3
[]
no_license
class StaffMemberPresenter < ModelPresenter # suspended?メソッドをStaffMemberPresenterオブジェクトに持たせ、objectオブジェクトに委譲する # StaffMemberPresenter#suspended?を呼ぶと、object#suspended?が呼ばれる delegate :suspended?, to: :object # 職員の停止フラグのOn/Offを表現する記号を返す # On: BALLOT BOX WITH CHECK(U+2611) # Off: BALLOT BOX(U+2610) def suspend...
true
33bba6d6a52c075b00ec687c9147421ede91fec6
Ruby
CoderAcademy-MEL/ruby-inheritance
/feature_request.rb
UTF-8
601
3.15625
3
[]
no_license
require_relative 'task' class FeatureRequest < Task attr_accessor :content, :difficulty def initialize(name, content, difficulty, description = '') @content = content @difficulty = difficulty super(name, description) end def to_s "#{super}, content: #{content}" end end # feature = FeatureR...
true
28cd27a5f023346beb40354bfdd46a3f79f998a2
Ruby
chef/chef_secrets
/bin/veil-ingest-secret
UTF-8
1,194
2.515625
3
[ "Apache-2.0" ]
permissive
#!/usr/bin/env ruby require 'veil' require 'json' require 'optparse' options = { debug: false } OptionParser.new do |opts| opts.banner = <<EOF Usage: veil-ingest-secret [options] [SECTION.]NAME Manually add secrets to a secrets provider. This is configured via environment variables: * PROVIDER=chef-secrets-file...
true
d64b91c43f1c8cf3d0fcef3ecbf0cb505537a0a6
Ruby
mrzeppa/TestowanieAplikacjiRuby
/spec/resistor_color_duo_spec.rb
UTF-8
933
2.71875
3
[]
no_license
require 'resistor_color_duo' RSpec.describe ResistorColorDuo do describe ".value" do it "check for brown and black" do num = ResistorColorDuo.value(["brown", "black"]) expect(num).to eq 10 end it "check for blue and grey" do num = Resistor...
true
61eea971e16324ab1db0c1aed5a17ecc4a77a79d
Ruby
romaGrigalashvili1/ruby-playground
/day3/roma_day3.rb
UTF-8
1,926
4.46875
4
[]
no_license
array=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] #1 array.each do |num| puts num end puts "_______________________" #2 array.each do |num1| puts num1 if num1>5 end puts array puts "_______________________" #3 new_array = array.select do |number| number % 2 != 0 end puts new_array puts "_______________________" arr2=[]...
true
262d3b131791556bb26b11a7fd82a53d5a9b66fe
Ruby
hermesalexis/ruby
/fizz_buzz_opp.rb
UTF-8
1,050
4.625
5
[]
no_license
#Fizzbuzz =begin Si un número es divisible por 3 debe devolver "Fizz" Si un número es divisible por 5 debe devolver "buzz" Si un número es divisible por 3 y por 5 debe devolver Fiz y buzz =end def assert(truthiness) raise "Tú codigo tiene errores" unless truthiness end class Fizzbuzz def initializ...
true
ebd61ff0aff4ec875c47eea15dc654cba916b9ce
Ruby
venki1995/DSA_Linked_Lists
/test.rb
UTF-8
732
3.703125
4
[]
no_license
require_relative "Linked_List" list = LinkedList.new puts "List demo" puts "---------" list.append("t") puts("Append test: #{list}") list.append(4) list.append(1) list.append("g") list.append("test") puts("Append test: #{list}") list.prepend("start") puts("Prepend test: #{list}") puts("List size: #{list.size()}") puts...
true
e355d47d36d3200995de4bdd56cdc87d0997480d
Ruby
itspriddle/dotfiles
/bin/gfm
UTF-8
685
2.640625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # Usage: # gfm <files> # # Examples: # # $ gfm README.markdown # $ echo "# Test" | gfm # $ echo "# Test" | gfm - README.markdown # $ gfm # # Test # ^d if %w(-h --help).include? ARGV.first File.read(__FILE__).lines[1..-1].each do |line| if line =~ /\A#/ puts line[2..-1] ...
true
65b2f23fde2abdc03c7737cbcb27df611f069e29
Ruby
marcosfsoares/QA_NINJA
/A180/code4testers/7_hashes.rb
UTF-8
304
3
3
[]
no_license
marcos = {nome: "Marcos", email: "marcos.fsoares@gmail.com", legal: true} puts marcos.class puts marcos puts marcos[:nome] puts marcos[:email] puts marcos[:legal] pedro = {nome: "Pedro", email: "pedro@gmail.com", legal: true} pessoas = [marcos, pedro] puts pessoas[0][:nome] puts pessoas[1][:email] puts "pessoas: #{...
true
0c2922c82aa91a1e99fea261b59e3d0cd8fc370d
Ruby
magdabm/ruby-exercises
/02_homework/_08_common_elements.rb
UTF-8
948
4.03125
4
[]
no_license
# Napisz funkcję, która jako argumenty przyjmuje dwie tablice i zwraca tablicę z elemantami wspólnymi podanych tablic. Np: # common_elements([1, 2, 3, 4, 5], [4, 5, 6]) #=> [4, 5] # common_elements(['a', 'b', 'c', 'd'], ['c','d', 'e']) #=> ['c', 'd'] # common_elements([14, 'apple', 1227, 'cat'], ['cat', 166, 541, 1227]...
true
c250052d091f3b203bf4f6a6d4a85fe54dcf1ea5
Ruby
cpfergus1/adopt_dont_shop
/spec/features/pets/pets_spec.rb
UTF-8
3,686
2.515625
3
[]
no_license
require 'rails_helper' RSpec.describe 'As a visitor' do before(:each) do @shelter = Shelter.create(name: 'Shelter 1', address: 'address', city: 'city', state: 'state', zip: '8') @pet = @shelter.pets.create(image: 'image', name: 'Johnny', description: 'description', a...
true
58a40465bdb02c1a8c8c483fe09c7ed82577746d
Ruby
ChalkyBrush/learn_ruby
/09_array_extensions/array_extensions.rb
UTF-8
173
3.46875
3
[]
no_license
class Array def sum if self ==[] return 0 else return self.inject(:+) end end def square self.map {|x| x **2} end def square! self.map! {|x| x **2} end end
true
6a169b92306713817a255f0a9715cb0f641dda93
Ruby
mklavuhn/debugging-with-pry-online-web-sp-000
/lib/pry_debugging.rb
UTF-8
52
3.140625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def plus_two(num) value = num + 2 return value end
true
5a78d39ec9358e7a1085203faf87dff0f9194bda
Ruby
SamWegs/RB101
/lesson_4/additional_practice_5.rb
UTF-8
192
3.140625
3
[]
no_license
flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) flintstones.each_with_index do |name, index| p index if name.include?("Be") end # p flintstones.index { |name| name[0, 2] == "Be" }
true
074bfbe7d3c0ae9439f432935c1b37553325891b
Ruby
dbohorquez8/rewards-rampage
/app/models/reward.rb
UTF-8
838
2.53125
3
[]
no_license
class Reward < ApplicationRecord include AASM belongs_to :reward_page belongs_to :participant, optional: true validates :name, presence: true validates :photo, presence: true validates :points, presence: true, numericality: true validates :reward_page_id, presence: true aasm column: 'status' do s...
true
c35832b08a7c5907c848f0e51580bd53f8ea9139
Ruby
Vilelab/Treinadev
/smallest_divisible_number2.rb
UTF-8
355
3.171875
3
[]
no_license
class Number def smallest_divisible(min, max) #cria um array array_numbers = (min..max).to_a #reduce aplica a operação definida entre parenteses sobre o array cumulativamente #lcm encontra o menor multiplo comum entre dois numeros inteiros #não entendi o porque do 1... result = array_numbers.reduce(1,...
true
7b1b4f2f1a999780b7c10512fddd67d760f6b508
Ruby
tweinacker57/store_item.rb
/store_item.rb
UTF-8
1,079
3.9375
4
[]
no_license
# car1 = {:make => "Ford", :model => "GT", :price => 120000} # p "The #{car1[:make]} #{car1[:model]} is $#{car1[:price]}" # car2 = {:make => "Aston Martin", :model => "Vanquish", :price => 250000} # p "The #{car2[:make]} #{car2[:model]} is $#{car2[:price]}" # car3 = {make: "Tesla", model: "Model S", price: 100000} # ...
true
96c27d57734f067458b6c580f2cfae2ba4303ed5
Ruby
d4rky-pl/gilgamesz
/app/services/adventure_validator.rb
UTF-8
1,814
2.65625
3
[]
no_license
class AdventureValidator class NameTaken < StandardError; end class InvalidPassage < StandardError; end class InvalidGameType < StandardError; end class InvalidItem < StandardError; end def initialize(adventure, json) @adventure = adventure @json = JSON.parse(json) end def valid? validate! ...
true
8a5c94ee47f0376635de3e1c8bc405ac053a9726
Ruby
christopheraue/m-ruby-concurrently
/ext/mruby/io.rb
UTF-8
1,459
2.609375
3
[ "Apache-2.0" ]
permissive
# @api mruby_patches # @since 1.0.0 # # mruby-io does not support non-blocking io operations. class IO unless const_defined? :EAGAIN # raised if {IO#read_nonblock} or {IO#write_nonblock} would block class EAGAIN < Exception; end end unless const_defined? :WaitReadable # raised if IO#read_nonblock wou...
true
2eded796834d81348d69b1df9b9bd371618eb719
Ruby
RickHanolt/collections_practice-v-000
/collections_practice.rb
UTF-8
657
3.796875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(array) array.sort end def sort_array_desc(array) array.sort.reverse end def sort_array_char_count(array) array.sort do |a, b| a.length <=> b.length end end def swap_elements(array) array = array[0], array[2], array[1] end def reverse_array(array) array.reverse end def kesha_mak...
true
105acfe44286768bf37af9fa8b753595f482228e
Ruby
RealGeeks/lab_tech
/spec/models/lab_tech/summary_spec.rb
UTF-8
11,841
2.65625
3
[ "MIT" ]
permissive
require 'rails_helper' RSpec.describe LabTech::Summary do let!(:experiment) { LabTech::Experiment.create(name: "wibble", percent_enabled: 100) } let(:summary_text) { experiment.summary.to_s } def record_experiment(cont: "foo", cand: "foo", speedup_factor: nil, baseline: 1.0, comparison: nil) LabTech.publish...
true
0e9ad29d46ef40cead9a5ee8e91c3c62d1c0cc55
Ruby
sranasinghe/employer_accounts_dockerpipeline
/app/services/api_helpers.rb
UTF-8
1,272
2.53125
3
[]
no_license
module APIHelpers extend Grape::API::Helpers def raise_not_found error!( { errors: [{ title: 'Not Found', detail: 'The requested resource does not exist' }] }, 404 ) end def raise_system_error error!( { errors: [{ title: 'Serve...
true
9f89c4953d4ff879bbbb38ce10524c9736386a8d
Ruby
threeifbywhiskey/houston
/rb/36.rb
UTF-8
127
3.171875
3
[]
no_license
def palin n, base s = n.to_s base s == s.reverse end p (1..1000000).select { |n| palin(n, 10) && palin(n, 2) }.reduce(:+)
true
0164e47ee8fbcf9a37fef98d127062ec5fc6b938
Ruby
RostykRadzhapov/wimm
/app/queries/reports.rb
UTF-8
979
2.53125
3
[]
no_license
# frozen_string_literal: true module Reports class CategoryReportsQuery include ExpenseAndTransfer def initialize(user) @user = user end def period_sum(start_period, end_period) Record.where(user: user) .where('DATE(created_at) >= ? AND DATE(created_at) <= ?', start_period, ...
true
d46d4685ceaa9fe503d940e741557d2b49c6e36a
Ruby
Pixelus/App-Academy-Full-Stack-Web-Development-Bootcamp
/Intro To Programming/Advanced Problems/anagrams.rb
UTF-8
676
4.5625
5
[]
no_license
# Write a method anagrams? that takes in two words and returns a boolean indicating whether or not the words are anagrams. Anagrams are words that contain the same characters but not necessarily in the same order. Solve this without using .sort def anagrams?(word1, word2) count1 = Hash.new(0) count2 = Hash.new(0) ...
true
f1996c7f67ee54b8782847ea309a1d869169d3b1
Ruby
martinliptak/codility
/S-MissingElement.rb
UTF-8
1,043
3.53125
4
[ "MIT" ]
permissive
# you can use puts for debugging purposes, e.g. # puts "this is a debug message" def solution(a) return 1 if a.empty? (1..a.count + 1).inject(:+) - a.inject(:+) end require "minitest/autorun" require "byebug" require "timeout" class TestSolution < Minitest::Test def test_default input = [2, 3, 1...
true
a3f27ce042127ab766039ef14b4739ed393a4277
Ruby
SwanHub/MyMDb
/app/models/stat_sheet.rb
UTF-8
1,045
2.96875
3
[]
no_license
class StatSheet < ApplicationRecord before_save :save_stats def save_stats self.total_movies = self.total_movies_string self.total_votes = self.total_votes_string self.avg_votes_per_movie = self.average_votes_string self.avg_rating_per_movie = self.average_rating end de...
true
e905492925344d80592ea69503431d46926262b2
Ruby
M-Munk/rb101_exercises
/easy3/easy6.rb
UTF-8
517
4.46875
4
[]
no_license
# write a function named xor that takes two arguments and returns true if # exactly one of its arguments is truthy and false otherwise. # output should be a boolean result # input 2 arguments # output: boolean def xor?(arg1, arg2) !!(arg1 && !arg2 || !arg1 && arg2) end # needs the !! because if both values are ...
true
ea5aac33afbd1a849c595a393fff470ba3f8c0d1
Ruby
UTDoi/ruby-design-pattern
/chain_of_responsibility/limit_support.rb
UTF-8
232
2.6875
3
[]
no_license
require_relative 'support' class LimitSupport < Support def initialize(name, limit) super(name) @limit = limit end def resolve(trouble) if trouble.number < @limit true else false end end end
true
9a86c61242b722368f95b67f00b02c0b1c021a49
Ruby
jonfoster9999/my-each-v-000
/my_each.rb
UTF-8
185
3.25
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def my_each(array) if block_given? counter = 0 while counter < array.size yield(array[counter]) counter += 1 end else "No block given" end array end
true
e9ccccb79280b0aebfa7e4d1262f702beb56a423
Ruby
goargo/is_business_day
/lib/is_business_day/memorial_day/tests.rb
UTF-8
514
2.6875
3
[ "MIT" ]
permissive
module IsBusinessDay module MemorialDay module Tests extend ActiveSupport::Concern included do def is_memorial_day? memorial_day = self.class .parse("05/01/#{ self.year }") .get_all_specific_days_in_month(:monday) ...
true
433b2c4cd96bb606bd5e6c4ca3f9fc203d769f79
Ruby
bebepeng/listen_to
/app/models/stat_compiler.rb
UTF-8
766
2.90625
3
[]
no_license
class StatCompiler attr_reader :stats def initialize(user) @stats = Song.all_viewer_counts(user) end def all_titles stats.map { |song| song[:title] } end def all_views stats.map { |song| song[:views] } end def all_likes stats.map { |song| song[:likes] } end def all_dislikes ...
true
2d99d302cf640cf188574d8473893cf15b3c1c80
Ruby
ijcd/dotfiles
/local/bin/find-similar
UTF-8
362
2.984375
3
[ "MIT" ]
permissive
#!/usr/bin/ruby md5hash = {} # TODO: Use ruby's Find method %x{find #{ARGV.join(' ')} -type f -print0 | xargs -0 md5sum}.each do |line| md5 = line[/^\w+/] file = line[/ +(.*)$/, 1] # test if hash has been found already, print results if it has if md5hash.include?(md5) puts [md5hash[md5], file].join(' ') ...
true
237b6ec475819234c638eaf3687e9190475a81d9
Ruby
alphagov/whitehall
/lib/taxonomy/tree.rb
UTF-8
872
2.6875
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
# This has been copied into Content Tagger, pending a decision on # where it should live. If you're changing it, please consider # handling the common case. # Recursive parser for publishing-api Taxon data module Taxonomy class Tree attr_reader :root_taxon def initialize(root_taxon_hash) @root_taxon ...
true
f7321db000eb0149b1aa045eae58200e46dad78e
Ruby
GuiHeurich/Rley
/lib/rley/syntax/literal.rb
UTF-8
511
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true require_relative 'terminal' # Load superclass module Rley # This module is used as a namespace module Syntax # This module is used as a namespace # A literal is terminal symbol that matches a lexical pattern class Literal < Terminal # The exact text representation of the ...
true
6d884f04e6680a6fcdf725524bfe11aae0c797e7
Ruby
anandsharma71098/Age_Calculator_Gem
/lib/agecalci.rb
UTF-8
1,086
3.390625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative "agecalci/version" require 'date' module Agecalci class Error < StandardError; end # Your code goes here... def age_calculator(date) current = ((Date.today).to_s).split("-") current_date=current[2].to_i current_month=current[1].to_i current_yea...
true
2e006d10ad2985747195baf599d2bb6a4e56c1dd
Ruby
omustafa1994/ruby-oop-zoo
/living_organism.rb
UTF-8
2,546
3.78125
4
[]
no_license
# This is the super class of defining a living organism class LivingOrganism def self.alive puts 'Living organisms move, feed, respire (burn food to make energy), grow, sense their environment, excrete and reproduce. These seven characteristics are sometimes summarized by the words “MRS GREN”. functions of:...
true
d14b86de61795aadb67d504f6e76b79ff60b269d
Ruby
Ardivaba/NetworkedClasses
/lib/Network/object_registry.rb
UTF-8
201
3.125
3
[]
no_license
class ObjectRegistry def initialize @objects = [] end def register_object(object) @objects << object puts "Object #{object.identity} registered with owner #{object.owner}" end end
true
84bf07868d60c42a7f18a912c70004c58f0158c0
Ruby
s-ashwinkumar/smartcar-ruby
/lib/smartcar/engine_oil.rb
UTF-8
318
2.53125
3
[ "MIT" ]
permissive
module Smartcar # class to represent Engine oil life # # @author [ashwin] # class EngineOil < Base include Utils PATH = Proc.new{|id| "/vehicles/#{id}/engine/oil"} attr_accessor :lifeRemaining # just to have Ruby-esque method names alias_method :life_remaining, :lifeRemaining end end
true
63daf4434afcd35c3617c999c560cc3790932fe1
Ruby
ederign/ederign.github.io
/_lib/wiki_processor.rb
UTF-8
613
2.921875
3
[]
no_license
# frozen_string_literal: true class WikiProcessor attr_reader :wiki def initialize(wiki) @wiki = wiki end def execute! create_wiki_dir create_wiki_index show_success_message rescue StandardError show_error_message end private def create_wiki_dir Dir.mkdir(wiki.dir) end ...
true
7869dacc97f2136168d44b93cd189e8b51845fd6
Ruby
mcoul/nasa-rovers
/lib/models/plateau.rb
UTF-8
220
3.15625
3
[ "MIT" ]
permissive
class Plateau def initialize(max_x, max_y) @max_x = max_x.to_i @max_y = max_y.to_i end def out_of_bounds?(x_pos, y_pos) x_pos > @max_x || y_pos > @max_y || x_pos.negative? || y_pos.negative? end end
true
553424bacae03509ca6756f30a07c3c8c1a28095
Ruby
simplymimmozzo/rbus
/lib/RequestQuotesCommandHandler.rb
UTF-8
340
2.5625
3
[ "MIT" ]
permissive
module Handlers class RequestQuotesCommandHandler def initialize(bus) @bus = bus end def handle(command) #do something with the command, interact with the domain object(s) #generate quotes and persist them @bus.publish(QuotesGeneratedEvent.new) end end class QuotesGenera...
true
8c45ebde7f3f4946bf55debfc777a2810139e40a
Ruby
yanlau/mathgame
/game_engine.rb
UTF-8
326
2.625
3
[]
no_license
require_relative 'math_variables' require_relative 'player' #Engine to manage all aspects of the game class GameEngine # def initialize # end class << self def calculate_question MathVariables.new end def validate_answer(playeranswer, companswer) playeranswer == companswer end e...
true
bb721baaa2e2df5016ee693556cca02641eb9d75
Ruby
lpile/jungle_beat
/spec/iter_3_spec.rb
UTF-8
851
3.046875
3
[]
no_license
require './spec/spec_helper' describe 'Iteration 3 Spec:' do before :each do @list = LinkedList.new @node_1 = @list.append("plop") @node_2 = @list.append("suu") end describe "can .prepend" do before do @node_3 = @list.prepend("dop") end it "add new node to the beginning of the lis...
true
5d98a1388fe205b48b73536f4aad72d3e0a38de0
Ruby
tim0414/ruby_practice
/immediate_value.rb
UTF-8
952
3.546875
4
[]
no_license
a = -10 b = -10 a.object_id # => 21 b.object_id # => 21 puts a.class c = 5*(10**18) d = 5*(10**18) c.object_id # => 47188366465580 d.object_id # => 47188366465480 puts c.class e = 4*(10**18) f = 4*(10**18) e.object_id # => 8000000000000000001 f.object_id # => 8000000000000000001 puts e.class class A attr_acces...
true
352c9b5c8e8ffca4af60dc50ed410376d4dbd151
Ruby
dsoisson1/calculator-rspec
/spec/calculator_spec.rb
UTF-8
1,344
3.40625
3
[ "MIT" ]
permissive
require 'rspec' require 'calculator' describe Calculator do describe 'addition' do it 'does not care about the order numbers are added' do calc = Calculator.new expect(calc.add(5, 9)).to eq 14 expect(calc.add(9, 5)).to eq 14 end it 'does not change when you add 0' do calc = Calculator.new expect(...
true
4b56edb78c7c5ee3a0c67a6225fb5881953dc791
Ruby
joestephens/learn_to_program
/ch11-reading-and-writing/build_a_better_playlist.rb
UTF-8
409
2.890625
3
[]
no_license
def music_shuffle(filenames) last_artist = "" filenames.each_with_index do |file, index| pieces = file.split("/") artist = pieces[pieces.index{|p| p == "iTunes Media"}+2] if artist == last_artist filenames << file pieces.delete_at(index) end end filenames end songs = Dir["/Users/...
true
d99bb0070f06986925075042ac99996b5a12bde0
Ruby
ladislavlisy/cz_payrollee5mac
/lib/cz_payrollee5/core_items/symbolic.rb
UTF-8
367
2.828125
3
[ "MIT" ]
permissive
module CzPayrollee5 class Symbolic attr_reader :code, :name def initialize(code, name) @code = code @name = name end def ==(other) @code == other.code end def <=>(other) @code <=> other.code end def eql?(other) @code == other.code end def hash...
true
107a94941fa045bf8847fa451c0bca39ad0ccc56
Ruby
kazu228/ruby-book
/lib/range.rb
UTF-8
54
3.234375
3
[]
no_license
puts (1..5).class a = [1, 2, 3, 4, 5] puts a[1..3]
true