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
8c2bac7f28930bd78094233dd3135a053b904bfb
Ruby
railis/challenge
/puzzles/string_equation_evaluator/spec.rb
UTF-8
1,450
3.109375
3
[]
no_license
Challenge::Spec.new do context "when expression is invalid" do context "when it includes invalid characters" do let(:exp) { "1 + 2a" } it "raises error" do expect { @solution_class.new(exp).calculate }.to raise_error("Invalid character 'a'") end end context "when there are not ...
true
2fe8dde7139ee38543a4e962b9de251b80b17b10
Ruby
ecksma/wdi-darth-vader
/04_ruby/d01/Myron_Johnson/test.rb
UTF-8
84
3.78125
4
[]
no_license
# puts stands for put string name = 'Myron' puts 'hello, world!' ' from, ' + name
true
007d8ae1ca4537a009e1300d5e9f9a32f5aec4e0
Ruby
gabrielpelo/work-time-calculations
/tests.rb
UTF-8
847
3.359375
3
[]
no_license
require_relative 'instant' a = Instant.new("1012") b = Instant.new("2021") w = Instant.new("948") puts a puts a + 30 puts a + w puts "\n" puts b puts b - 30 puts b - w puts "\n" puts a.to_i puts a puts "\n" puts b.to_i puts b puts "\n" times = %w{ 10:12 935 8:30 7.50 0637 1130 11.15 0 24 23:59 } same_times = ...
true
5d9642fdc1129e8836730f7ce6cb162f3cebaa6f
Ruby
trishgarrett/square_array-v-000
/square_array.rb
UTF-8
292
3.578125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def square_array(array) # this method should return 'an' array that has the numbers squared variable = [] array.each do|i| # how can we store this value? And what do we use to store multiple values? variable << i**2 end # modified array will be returned here variable end
true
1f202fbc72c62ec294de7732b84b39cba0565588
Ruby
jeroenvandijk/nokogiri_jquery
/vendor/plugins/steam/lib/steam/matchers/html_unit.rb
UTF-8
1,586
2.84375
3
[ "MIT" ]
permissive
module Steam module Matchers module HtmlUnit class HasContent #:nodoc: def initialize(content) @content = content end def matches?(target) @target = target !!@target.locate_element(@content) end def failure_message "expected t...
true
d7d31337667bbdd185510e1f946085662b3157d8
Ruby
gvoicu/pag_seguro
/spec/pag_seguro/shipping_spec.rb
UTF-8
1,668
2.65625
3
[]
no_license
# encoding: utf-8 require "spec_helper" valid_attributes = { type: PagSeguro::Shipping::SEDEX, state: "SP", city: "São Paulo", postal_code: "05363000", district: "Jd. PoliPoli", street: "Av. Otacilio Tomanik", number: "775", complement: "apto. 92" } describe PagSeguro::Shipping do context "instance"...
true
91a326a78f33517b34cf3a199e1256708569380a
Ruby
donwildman/rover
/app/controllers/commands_controller.rb
UTF-8
2,037
2.8125
3
[]
no_license
class CommandsController < ApplicationController DIRECTIONS = 'NSEW' COMMANDS = 'LRM' def index @X = 0 @Y = 0 @direction = 'N' @commands = { :x => @X, :y => @Y, :direction => @direction, :error => nil } @rover...
true
607fdebe663ac4d38beefce74fb37b12f5bdbb4f
Ruby
sadiqmmm/mlist
/lib/mlist/email_post.rb
UTF-8
3,428
2.78125
3
[ "MIT" ]
permissive
module MList # The simplest post that can be made to an MList::MailList. Every instance # must have at least the text content and a subject. Html may also be added. # # It is important to understand that this class is intended to be used by # applications that have some kind of UI for creating a post. It a...
true
915ef42972c6bea8f5501d045efde9a95a8bdf26
Ruby
Sydneyc44/learn-co-sandbox
/mmpractice.rb
UTF-8
84
3.328125
3
[]
no_license
def greeting(name) puts "Hi, I'm #{name}" end greeting("Sydney") greeting("Alex")
true
8c9c4c9ce598e0a6e5ec426df031f9088689acd9
Ruby
targess/ironhack-week-2
/day4/sinatra-blog/spec/blog_spec.rb
UTF-8
532
2.734375
3
[]
no_license
require 'Blog' RSpec.describe Post do let (:my_blog) {Blog.new} describe "#posts" do it "returns an array of posts" do expect(my_blog.posts.class).to be(Array) end end describe "#latest_posts" do it "return array of sorted posts" do first_post = Post.new("post 1","10/23/2016", "Lorem Ipsum Dolor") ...
true
5841aa1023cc0b1be5dc547cd230a17c7fa2f74c
Ruby
karrkode/recursion
/recursion.rb
UTF-8
1,504
3.8125
4
[ "MIT" ]
permissive
# require 'pry' class Game attr_reader :board, :position def initialize(board) @position = {x: 0,y: 0} @board = create_board(board) end def create_board(board) board[position[:y]][position[:x]] = "X" board end def update_board(board,move) board[position[:x]] = 'X' if move == "A" board[position...
true
c151b245cd19ce1c47ef97778ea004c05ade7a6d
Ruby
cha63506/basset-2
/spec/basset/feature_collection_spec.rb
UTF-8
4,119
2.78125
3
[ "MIT" ]
permissive
require File.dirname(__FILE__) + '/../spec_helper' describe "feature collection" do describe "numbering features" do before(:each) do @collection = Basset::FeatureCollection.new @collection.add_row %w[hello paul hello] end it "takes rows of features" do @collection.features.should == %...
true
fedcf4a07553774cb64d94b4f6bb55b69be67276
Ruby
YashTotale/learning-ruby
/basics/control-structures/conditionals/case.rb
UTF-8
332
3.859375
4
[ "MIT" ]
permissive
count = 3 # Case with booleans case when count == 0 puts "nobody" when count ==1 puts "1 person" when (2..5).include?(count) puts "several people" else puts "many people" end # Case with comparisons case count when 0 puts "nobody" when 1 puts "1 person" when 2..5 puts "several people" else puts "many ...
true
e7086f632f7d4985a5a1f36f641ed1452325a941
Ruby
jimmy2/launchschool_ruby_basics
/methods/exercise_08.rb
UTF-8
138
3.40625
3
[]
no_license
# exercise_08.rb # Name Not Found def assign_name(name="Bob") name end puts assign_name('Kevin') == 'Kevin' puts assign_name == 'Bob'
true
0f217147173280127197fe952feae52d2cb23813
Ruby
jginor/ttt-6-position-taken-rb-bootcamp-prep-000
/lib/position_taken.rb
UTF-8
209
3.171875
3
[]
no_license
# code your #position_taken? method here! def position_taken?(board, index) if board[index]==" " || board[index]=="" || board[index]==nil false elsif board[index] == "" true else true end end
true
909cd9b2c0187072eefe0408a021a713d458f1e5
Ruby
feedbin/feedbin
/app/models/sourceable.rb
UTF-8
421
2.765625
3
[ "MIT" ]
permissive
class Sourceable ATTRIBUTES = %i[title type id section jumpable] attr_accessor *ATTRIBUTES def initialize(type:, id:, title:, section: nil, jumpable: false) @title = title @type = type.downcase @id = id @section = section @jumpable = jumpable end def to_h {}.tap do |hash| ATTR...
true
b159e9ad1b259da8257513bf5b43222274c47d6c
Ruby
gilesbowkett/citrus
/test/match_test.rb
UTF-8
2,211
2.921875
3
[ "MIT" ]
permissive
require File.expand_path('../helper', __FILE__) class MatchTest < Test::Unit::TestCase def test_string_equality match = Match.new('hello') assert_equal('hello', match) end def test_match_equality match1 = Match.new('a') match2 = Match.new('a') assert(match1 == match2) assert(match2 == ma...
true
19364d7ed937bcc61eb9c501a13f1dfe88d322f2
Ruby
breadbaker/jana
/app/models/user.rb
UTF-8
1,564
2.546875
3
[]
no_license
class User < ActiveRecord::Base attr_accessible( :email, :pwd_hash, :token, :password, :first_name, :image, :last_name, :uid, :confirmed, :confirm_token ) before_save :legit_email before_create :set_admin, :set_confirm_token validates_presence_of :email validates_uniqu...
true
bd73e05b3275dd3ceba9fe98e5d8d370305b5882
Ruby
durrellchamorro/Twenty-One
/app/game.rb
UTF-8
1,771
3.875
4
[]
no_license
require_relative 'dealer' require_relative 'deck' require_relative 'player' class Game attr_accessor :deck, :dealer, :player def initialize @deck = Deck.new @dealer = Dealer.new @player = Player.new end def play system 'clear' puts "Let's play twenty-one." shuffle_cards! deal_init...
true
23ae047a99175a9a113d9e2873e46632161410ff
Ruby
antoinelyset/novify
/app/models/track.rb
UTF-8
703
2.53125
3
[]
no_license
class Track < ActiveRecord::Base after_save :update_radio_started_at, :update_radio_ended_at belongs_to :radio attr_accessible :href, :played_at attr_accessible :radio_name, :radio_artist attr_accessible :formatted_name, :formatted_artist attr_accessible :spotify_name, :spotify_artist validates_p...
true
7607770981ac802d69cb8c95d21fbd088456c553
Ruby
carolfly86/altar
/lib/crosstab.rb
UTF-8
2,091
2.5625
3
[]
no_license
module Crosstab # attr_accessor :total_true, :total_false, :passed_true, :passed_false def self.ranking_calculation query = "select passed_cnt,failed_cnt, total_passed_cnt,total_failed_cnt, branch_name||'-'||node_name as bn_name, eval_result from tarantular_tbl" rst = DBConn.exec...
true
b0174ac13ae8a2596479bf16ce5e017b5f056539
Ruby
yann021/thp_training
/formation/s3/j4/mon_projet/lib/show.rb
UTF-8
1,644
3.46875
3
[]
no_license
class Show def initialize end def creation_player print "What is your name player 1 ............: " $players["name1"] = gets.chomp print "what is your symbole player 1 (x ou o) : " $players["symbole1"] = gets.chomp while $players["symbole1"] != "x" && $players["symbole1"] != "o" print "what is your sy...
true
f248a3da48723da311eb0170514dada91c833f22
Ruby
jake-007/rxruby
/examples/subscribe_on.rb
UTF-8
799
3.03125
3
[ "Apache-2.0" ]
permissive
require 'rx' def in_a_second(n) Rx::Observable.create do |observer| sleep(1) observer.on_next(n) observer.on_completed end end # subscribe_on will schedule ancestry on given scheduler; each sleep happens in a separate thread source = Rx::Observable.of( in_a_second(1) .map {|v| v + 1 } .subsc...
true
1ed5a0c6918d1afe3077f5a59ead26d5ce7e7edd
Ruby
laurenelee/hotel
/lib/booking.rb
UTF-8
399
2.921875
3
[]
no_license
require 'date' module Hotel class Booking attr_reader :id, :dates, :rooms def initialize(checkin, checkout, rooms, id) @dates = DateRange.new(checkin, checkout) @id = id @rooms = rooms end def total_cost total_cost = 0 @rooms.each do |room| total_cost += room.c...
true
4fa38fed87bfc07972a0b69e6a3aeb241a87bf94
Ruby
luisfoxi/teste
/files/paises.rb
UTF-8
450
2.609375
3
[]
no_license
require 'open-uri' require "yaml" config = YAML.load_file('../config/app_config.yml') source = config['source'] country= source['country'] uri = URI.parse(country) open(uri) do |file| file.each_line do |linha| puts "\nCreated: #{linha}" end # puts file.read() end # File.open('http://www.bcb.gov.b...
true
79f1d32d2f6aa2a6a07c6f4061407ab681f03299
Ruby
shiningflint/learn_web_scrape_ruby
/index.rb
UTF-8
685
3.078125
3
[]
no_license
require 'httparty' require 'nokogiri' # RESOURCE RELATED def get_from_file File.read("sample-file.txt") end def get_resource(url = "") if url == "" get_from_file() else HTTParty.get(url, verify: false) end end # NOKOGIRI RELATED def get_jpy_jual(htmlResource) nokogiriObject = Nokogiri::HTML(htmlRes...
true
9b6fc0d364744838010471cc8c3f16aa45ae40dc
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/hamming/6ad0b37876194c03b14f11ec283fd79b.rb
UTF-8
222
3.21875
3
[]
no_license
class Hamming def self.compute(dna1,dna2) length = [ dna1.length, dna2.length ].min - 1 ( 0..length ).inject( 0 ) do | diff_count, i | dna1[i] == dna2[i] ? diff_count : diff_count += 1 end end end
true
fc5253eef90f337f2c30223b8e8bba4d8149a982
Ruby
acastemoreno/c2-module2
/week-1/day-3/non-duplicates-values.rb
UTF-8
217
3.34375
3
[]
no_license
def non_duplicated_values(values) values.uniq.select{|i| values.count(i) == 1} end puts non_duplicated_values([1,2,2,3,3,4,5]).inspect #Return [1,4,5] puts non_duplicated_values([1,2,2,3,4,4]).inspect #Return [1,3]
true
2e5a41298a0ff9c4c3c7b07e2aebc8f0e9fb04b0
Ruby
afhight/NameVersioning
/warmup.rb
UTF-8
358
3.765625
4
[]
no_license
visited = [] puts "Enter all the states you have been to, and type 'done' when complete." keepgoing = true while keepgoing state = gets.chomp.upcase if state != 'DONE' visited.push(state) else keepgoing = false end end # while (state != 'DONE') # visited.push(state) # end puts "you have visited the follow...
true
795f7bae7dfb137fddef15fe8183aeffe827f025
Ruby
kkalpakloglou/banking-app
/app/models/account.rb
UTF-8
633
2.546875
3
[]
no_license
class Account < ApplicationRecord # Associations belongs_to :user has_many :transactions # Validations validates :number, presence: true, uniqueness: true validates :user_id, presence: true # Callbacks before_validation :set_account_number, on: [:create] def balance Money.new(sum_of_credit_in_c...
true
df6b0850045da332d02341cea76425f79aeb06b0
Ruby
bborn/eschaton
/slices/google_maps/google/marker.rb
UTF-8
11,638
2.8125
3
[ "MIT" ]
permissive
module Google # Represents a marker that can be added to a Map using Map#add_marker. If a method or event is not documented here please # see googles online[http://code.google.com/apis/maps/documentation/reference.html#GMarker] docs for details. See MapObject#listen_to on how to use # events not listed on thi...
true
2fe3284774807e1df42af4a3ef61275e071fa6b4
Ruby
wwb0709/ruby
/rubywork/student.rb
UTF-8
797
3.953125
4
[]
no_license
load "person.rb" module Me def sqrt(num, rx=1, e=1e-10) num*=1.0 (num - rx*rx).abs <e ? rx : sqrt(num, (num/rx + rx)/2, e) end end class Student < Person @@count=0 # def initialize # @@count+=1 # end def talk super puts "I am a student. my name is "+@name+", age is "+@age.to_s pu...
true
e7a22b21d0478d9c8ea9359bf8591cbbf27d2325
Ruby
danachen/Ruby
/LS130/Exercises/easy/easy2_6.rb
UTF-8
413
4.1875
4
[]
no_license
# Easy, #select method # with iterator def each_with_index(arr) arr.each do |el| yield(el, arr.find_index(el)) end end # without iterator def each_with_index(arr) counter = 0 arr.each do |el| yield(el, counter) counter += 1 end end result = each_with_index([1, 3, 6]) do |value, index| puts "#...
true
be13dbaea0307787ee7dbc0a9f88078f17359998
Ruby
MikeAllison/tealeaf_oop
/05_workbook/intermediate/quiz_1/03.rb
UTF-8
426
3.4375
3
[]
no_license
class InvoiceEntry attr_reader :product_name, :quantity def initialize(product_name, number_purchased) @quantity = number_purchased @product_name = product_name end def update_quantity(updated_count) # prevent negative quantities from being set @quantity = updated_count if updated_co...
true
4178f9079a4ebff19ff92f8dae3c8949df24ac86
Ruby
eric-wood/roomba
/lib/rumba/dsl.rb
UTF-8
1,890
3.875
4
[]
no_license
# Define the Rumba "DSL" # Lots of easy to use methods for basic tasks class Rumba module Dsl # Remember, Roomba speeds are defined in mm/s (max is 200) DEFAULT_SPEED = 200 # move both wheels at the same speed in a certain direction! # NOTE THAT THIS BLOCKS UNTIL COMPLETE def straight_distance(d...
true
ab43358b1fd1acb957deb3db0cc54e6049a1ef90
Ruby
cielavenir/procon
/atcoder/arc/tyama_atcoderARC044A.rb
UTF-8
104
3.296875
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby n=gets.to_i puts n==2||n==3||n==5||(n!=1&&n%2!=0&&n%3!=0&&n%5!=0) ? :Prime : 'Not Prime'
true
29f6d36bff26c1a399484bc85caeaebf9b5c3ecf
Ruby
AlineFreitas/AdventOfCode
/2019/day01/spec/fuel_counter_spec.rb
UTF-8
2,245
3.03125
3
[]
no_license
require_relative '../fuel_counter' RSpec.describe "Fuel Counter" do context "Calculate fuel by mass" do it "returns 2 when mass is 12" do # Given mass = 12 # When needed_fuel = FuelCounter.fuel_by_mass(mass) # Then exp...
true
334b25a0a4863d43cce3dd6ff57a85b344d6423c
Ruby
msanroman/gilded-rose
/spec/normal_item_spec.rb
UTF-8
560
2.5625
3
[]
no_license
require File.expand_path(File.dirname(__FILE__)+'/../lib/normal_item.rb') describe NormalItem do it "decreases it's quality and it's sell_in in one point every day when the sell day hasn't passed yet" do item = NormalItem.new("+5 Dexterity Vest", 10, 20) item.update_stats item.sell_in.should equal 9 ...
true
bba7d7bb03d3ac2f70a3a3e91e5b4251055ce5dd
Ruby
Zheka1988/ruby_replay
/lesson_1/prymougol_treugolnik.rb
UTF-8
562
3.46875
3
[]
no_license
puts "Vvedite storony treugol'nika!" puts 'a?' a = gets.chomp.to_i puts 'b?' b = gets.chomp.to_i puts 'c?' c = gets.chomp.to_i sides = [a, b, c].sort def pryamougolniy?(sides) sides[2]**2 == sides[0]**2 + sides[1]**2 ? 'prymougolniy' : 'ne prymougolniy' end def ravnobedrenniy?(a, b, c) a == b || a == c || c == b ...
true
a1ec5b92a555989165bae11a33eeb337b1a9b3d4
Ruby
hyx131/TwO-O-Player-Math-Game
/game.rb
UTF-8
1,308
3.78125
4
[]
no_license
require './player' require './math_question' class Game def initialize @players = [ Player.new('Player 1', 'P1'), Player.new('Player 2', 'P2') ] @round = 0 @index = 0 end def play while !game_over? do header "NEW TURN" question = Question.new puts question...
true
8c6e07131604f545458ffc131911625ab040149c
Ruby
tomoakin/DepthHist
/range_compress.rb
UTF-8
493
2.546875
3
[]
no_license
#!/bin/env ruby # lastref=nil lastpos=0 min_depth=100000 cur_range_start = nil ARGF.each_line do |l| a=l.chomp.split ref=a[0] pos=a[1].to_i depth=a[2].to_i min_depth = depth if depth < min_depth if lastpos == 0 cur_range_start = pos lastref = ref lastpos = pos next end if ref!=lastref o...
true
55f649ce9f1f2d8a6657646df3ea8e63ba731254
Ruby
pelf/New-Scientist-Enigmas
/1688.rb
UTF-8
1,249
3.40625
3
[]
no_license
# find primes in the first 1000 integers primes = Array.new(1000,true) for i in 2...1000 next unless primes[i] for j in 2...1000 prod = i*j break if prod > 1000 primes[prod] = false end end prime_nrs = [] for i in 2...1000 prime_nrs << i if primes[i] end #puts prime_nrs.inspect products = [] products_prime...
true
1a53bc10ee0689d7f67004b1f95a439de62ccfb7
Ruby
turingschool-examples/battleshift
/app/services/turn_processor.rb
UTF-8
828
3.28125
3
[]
no_license
class TurnProcessor def initialize(game, target) @game = game @target = target @messages = [] end def run! begin attack_opponent ai_attack_back game.save! rescue InvalidAttack => e @messages << e.message end end def message @messages.join(" ") end p...
true
cd58a02390e3e16c67825e444f08072921917bfe
Ruby
kahohonda917/rubykakunin
/lesson6.rb
UTF-8
229
3.109375
3
[]
no_license
total_price=105 if total_price>100 puts "みかんを購入。所持金に余りあり" elsif total_price ==100 puts "みかんを購入。所持金は0円" else puts "みかんを購入することはできません" end
true
328871de2690d58eab658e03d4e5752d59c52f20
Ruby
mongodb/mongoid
/lib/mongoid/errors/callback.rb
UTF-8
656
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true # rubocop:todo all module Mongoid module Errors # This error is raised when calling #save! or .create! on a model when one # of the callbacks returns false. class Callback < MongoidError # Create the new callbacks error. # # @example Create the new callba...
true
1552f28873f700174305a6e86f533cad2d7b0a8f
Ruby
cies/mostfit
/lib/rules.rb
UTF-8
12,343
3.15625
3
[ "MIT" ]
permissive
module Mostfit module Business class BasicCondition # attr_accessor :appliesOn, :operator, :compareWith, :validator attr_accessor :var1, :binaryoperator, :var2, :comparator, :const_value, :validator def self.get_basic_condition(cond) if(cond.keys.length < 3) return ...
true
d0aa5dd0b1b703f7bc6d646502e79ef6284be5aa
Ruby
rclegend/bewd_11_nyc_homework
/_Kelly_Lo/Midterm/lib/Images.rb
UTF-8
202
2.890625
3
[]
no_license
class Image attr_accessor :image_url :username :tags :likes def initialize (image_url, username, tags, likes) @image_url = image_url @username = username @tags = tags @likes = likes end end
true
09c64ff25dae8816bb54fab73715aa056c45ebc7
Ruby
wilcoxst/red_lodge_town_series.1
/app/models/time_entry.rb
UTF-8
2,228
3.09375
3
[]
no_license
require 'csv' class TimeEntry < ActiveRecord::Base belongs_to :week belongs_to :racer def self.getSet(gender, discipline, classification, week) set = TimeEntry.joins(:racer).where({racers: {gender: gender, discipline_id: discipline.id, classification_id: classification.id}, ...
true
4aa771d03def2b5b1967889cdabe2a0c8f9ea2a4
Ruby
Pantapone/RB101
/small_problems/easy_9.rb
UTF-8
2,899
3.9375
4
[]
no_license
#1 def greetings(arr, hash) name = arr.join(" ") title = hash[:title] occupation = hash[:occupation] puts "=> Hello, #{name}! Nice to have a #{title} #{occupation} around." end greetings(['John', 'Q', 'Doe'], { title: 'Master', occupation: 'Plumber' }) #2 #3 def negative(num) num.negative? ? num : -nu...
true
d897df3ca34a0a72a0c15c1dee8f8c39348ae5e8
Ruby
hoelzro/dev-study
/maze-generation/maze.rb
UTF-8
3,681
3.40625
3
[]
no_license
class Edge def initialize @closed = true end def open? not closed? end def closed? @closed end def open @closed = false end end class Cell attr_reader :x attr_reader :y def initialize(maze, x, y) @maze = maze @x = x @y = y @edges = [] end def open...
true
8e4b8f1dd7bc06d52891be7cae66f7b117a97d4a
Ruby
harrietc52/the_well_grounded_rubyist
/chapter_08/numerical_objects.rb
UTF-8
164
3.578125
4
[]
no_license
n = 99.8 m = n.round puts m x = 12 if x.zero? puts "x is zero" else puts "x is not zero" end puts "The ASCII character equivalent of 97 is #{97.chr}"
true
0f4c40a0b84661989fa75ddc0cf4e059d7584d21
Ruby
CenCalRuby/test-doubles
/lib/twitter_client.rb
UTF-8
401
2.796875
3
[ "MIT" ]
permissive
require 'net/http' require 'uri' require 'json' class TwitterClient def self.post(username, message) uri = URI("https://api.twitter.com/#{username}/tweets") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.path, {'Content-Type' =>'application/json'}) ...
true
b7b10ee0f8fcc873345f9f70cb5eebf7cf6e0365
Ruby
Quang7hong81/ruby-xdr
/spec/lib/xdr/dsl/enum_spec.rb
UTF-8
928
2.796875
3
[ "Apache-2.0" ]
permissive
require "spec_helper" describe XDR::DSL::Enum, "#member" do subject do Class.new(XDR::Enum) do member :one, 1 member :two, 2 end end it "adds to the members collection of the class" do expect(subject.members.length).to eq(2) expect(subject.members[:one]).to eq(subject.one) expect...
true
f0f03309fc7b3f1725a7b0bc4eceeafeb630841c
Ruby
camsys/transam_core
/spec/models/notice_spec.rb
UTF-8
3,166
2.59375
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
require 'rails_helper' RSpec.describe Notice, :type => :model do let(:notice) {build_stubbed(:notice)} #------------------------------------------------------------------------------ # # Class Methods # #------------------------------------------------------------------------------ describe '.n...
true
2c4928e27ddef8aa525712ac29e64848f6e77170
Ruby
nasum/scracket_tool
/scracket_tool.rb
UTF-8
555
2.640625
3
[]
no_license
require 'thor' require './lib/db_connector.rb' class ScracketTool < Thor desc "hello NAME", "say hello to NAME" def hello(name) puts "Hello #{name}" end desc "show-tables DBNAME", "show table" option :h option :u option :p def show_tables(db_name) DBConnector.show_tables(db_name, options[:h], ...
true
4ea99afa66124f1464fb0b704dd54a88dc0521c5
Ruby
cielavenir/procon
/codeforces/tyama_codeforces719B.rb
UTF-8
131
2.890625
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby gets s=[0]*4 x=0 gets.chomp.chars{|c| f=c!='r' ? 2 : 0 s[f|x]+=1 x^=1 } p [[s[0],s[3]].max,[s[1],s[2]].max].min
true
f08ff49f3308dd80d97508cddb6904a72b4e75e5
Ruby
VishnuHaasan/KnightTravails
/main.rb
UTF-8
1,336
3.875
4
[]
no_license
class Knight STEPS = [[1,2],[1,-2],[-1,2],[-1,-2],[2,1],[2,-1],[-2,1],[-2,-1]] attr_accessor :steps, :position, :parent @@visited = [] def initialize(position,parent) @position = position @steps = [] @parent = parent end def check(element) return element[0]>7 || element[0]<0 || element[1]>...
true
9b566d1298c5f4668a9cf193036dec4576ae8a07
Ruby
kixton/rock-paper-scissors
/spec/rock_pape_scis_spec.rb
UTF-8
1,010
2.90625
3
[ "MIT" ]
permissive
require_relative './spec_helper.rb' describe 'RockPapeScis' do let(:kim) { {id: 1, move: 'rock'} } let(:jeff) { {id: 2, move: 'paper'} } let(:peng) { {id: 3, move: 'scissors'} } let(:pong) { {id: 4, move: 'scissors'} } describe 'play' do it 'player has id and move' do expect(kim[:id]).to eq(1...
true
f18ee7ab40daa75eae5d6c885490a0e47c8735c4
Ruby
mfirmanakbar/ruby-basic
/17-reading-files.rb
UTF-8
533
3.59375
4
[]
no_license
# File.open("D:/ruby/ruby-basic/17-students-list.txt") # r: read, storing do into variable files File.open("17-students-list.txt", "r") do |file| # puts file.read() #read all # puts file.read().include? "Akbar" #read all and checking # puts file.readline() #read first line # puts file.readlines()[2] #getting in...
true
30626c0fc201a4a347f4d195f25ab35ddf35d655
Ruby
cha63506/rbx-trepanning
/processor/command/info_subcmd/breakpoints.rb
UTF-8
2,082
2.703125
3
[]
no_license
require 'rubygems'; require 'require_relative' require_relative '../base/subcmd' class Trepan::Subcommand::InfoBreakpoints < Trepan::Subcommand HELP = <<-EOH info breakpoints [num1 ...] [verbose] Show status of user-settable breakpoints. If no breakpoint numbers are given, the show all breakpoints. Otherw...
true
16142b2f87deea05ef891aeae1ee19e563efd06b
Ruby
proprietary/twitter-name-finder
/twitter-name-finder.rb
UTF-8
6,215
3.1875
3
[]
no_license
#!/usr/bin/env ruby # coding: utf-8 require 'unirest' require 'optparse' class Twitter def initialize @csrf_token = self.get_csrf_token @backoff = 2.0 # seconds to wait before hitting Twitter again end def get_csrf_token r = Unirest.get "https://twitter.com" r.headers[:set_cookie].each do |hd...
true
b298a6503d8e70deae9a27b9252ffe509eb8e7b0
Ruby
barrym/penguin
/examples/Rakefile
UTF-8
1,765
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#! /usr/bin/env ruby require '../lib/penguin' def green(text) "\e[32m#{text}\e[0m" end def red(text) "\e[31m#{text}\e[0m" end # I apologise to the programming gods for what is about to happen def as_table(data) headers = data.first.keys.sort widths = {} data.each do |e| e.each do |k,v| bigger = k...
true
2b362134f4c28cb96be626500489bcd8667ca5ba
Ruby
imazen/ruby-vips-riapi
/web.rb
UTF-8
769
2.640625
3
[]
no_license
require 'fileutils' require 'riapi' require 'sinatra' require 'level1/image_resizer.rb' IN_DIR = 'samples/images' OUT_DIR = 'out' # list available sample images get '/samples' do images = Dir[File.join(IN_DIR, '*')].map { |path| File.basename(path) } images.map { |img| "#{img}\n" } .join end # perform an image...
true
5bb4bff2d572b618262da1209404bdc03adc8856
Ruby
danielribeiro/hamster
/lib/hamster/stack.rb
UTF-8
1,200
3.0625
3
[ "MIT" ]
permissive
require 'forwardable' require 'hamster/immutable' require 'hamster/list' module Hamster def self.stack(*items) items.reduce(EmptyStack) { |stack, item| stack.push(item) } end class Stack extend Forwardable include Immutable def initialize @list = EmptyList end def empty? ...
true
54acde4cbd3a709cee89550d5a353c2dbd57b261
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/etl/56320335ffc748a48cc551a5ba3700b6.rb
UTF-8
199
2.890625
3
[]
no_license
class ETL def self.transform(old) new = {} old.each do |score,letters| letters.each do |letter| new[letter.downcase] = score end end new end end
true
9a01e79e7fa47b2fab5c0d7fe624f28311d0addc
Ruby
khu/newwordsforme
/app/models/tabs.rb
UTF-8
814
2.8125
3
[]
no_license
class Tabs def initialize @tabs = [] end def logged_in user @tabs = [] @tabs << Tab.new(:home , 'Home', root_path) @tabs << Tab.new(:addons, 'Addons', addons_path) @tabs << Tab.new(:signin, 'Sign out', signout_path) @tabs.reverse! return self end def logged_out @tabs = [...
true
4270a28b4144f5a10818f318624e378013ec3229
Ruby
xdkernelx/personality-analyzer
/app/helpers/result_helper.rb
UTF-8
2,427
2.78125
3
[]
no_license
helpers do MAX_SCORE = 100 NEG_TRAIT_SCORE_MULT = 0.125 # Original base score: 0.10 POS_TRAIT_SCORE_MULT = 0.05 DEDUCT_POINT = 5 EMPLOYER_REQS = ["Politician", "Charmer", "Closer", "Evangelist"] def assessment if logged_in? @assessment = Assessment.find_by(user_id: @user.id) end end d...
true
5b39169f97be2d1f40299c170dc295a477e34839
Ruby
whitemage12380/dungeon_generator
/lib/connector.rb
UTF-8
5,809
3.078125
3
[]
no_license
require_relative 'configuration' require_relative 'map_object' require_relative 'map_object_square' class Connector include DungeonGeneratorHelper attr_reader :map_object, :connecting_map_object, :square, :facing, :width, :map_x, :map_y def initialize(map_object:, square: nil, facing: nil, width: nil, map_x: ni...
true
b35b4c8dafd5f52d3fbf862601cfe1d6eb643895
Ruby
fox3000wang/BASH_SHELL
/ruby/RubyLearning/1.5.Hash/4.rb
UTF-8
176
3.203125
3
[]
no_license
a = {1 => "a", 2 => "b", 3 => "c"} print "1: " b = a.reject {|key, value| value == 'b'} puts b.inspect print "2: " puts a.merge({1 => 'A', 3 => 'C', 4 => 'd'}).inspect
true
5251f385435f62d9ba0ec60238f81ee27a534141
Ruby
isundaylee/2048
/lib/core.rb
UTF-8
1,918
3.71875
4
[]
no_license
class GameCore UP = 0 RIGHT = 1 DOWN = 2 LEFT = 3 VALID = 0 INVALID = 1 WINNING = 2 LOSING = 3 attr_reader :dimension attr_reader :board def initialize(dimension = 4) @dimension = dimension @board = Array.new(dimension) { Array.new(dimension) } 2.times { generate_new_tile ...
true
3be66f1de0a5f28aadae37da15d9670f5cff3480
Ruby
facingsouth/project_tdd_minesweeper
/lib/minesweeper.rb
UTF-8
823
3.234375
3
[]
no_license
require_relative './board.rb' require_relative './space.rb' require_relative './player.rb' require 'yaml' class Minesweeper attr_reader :board, :player def initialize @board = Board.new @player = Player.new @file = File.new("save.txt", "w") end def play @move = 0 until defeat? ...
true
c90f54a1700ea8d8890b9b903e6311d2ad1e1424
Ruby
mcbain220/intro_to_programming
/more_stuff/other_stuff_exercise_1.rb
UTF-8
181
2.875
3
[]
no_license
# other stuff exercise 1 words = ["laboratory","experiment","Pan's Labyrinth", "elaborate", "polar bear"] words.each do |word| if word.downcase =~ /lab/ puts word end end
true
eece6862d7c9e0b2992f74caad1416e83c7c9054
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/bob/12c6939d57304267866de4dec7e98bc1.rb
UTF-8
636
3.90625
4
[]
no_license
class Bob def hey(message) return 'Fine. Be that way!' if silent? message return 'Woah, chill out!' if shouting? message return 'Sure.' if question? message 'Whatever.' end private def silent?(message) message.strip.empty? end def question?(message) message.end_with...
true
f4e2fd641990fd29f65e6ea7ab0ef26d5ab5ec80
Ruby
lly123/FT
/_0.rb
UTF-8
3,191
2.5625
3
[]
no_license
alias L lambda $_0C = L{|x| L{|y| L{|f| f[x][y]}}} $_0Car = L{|p| p[L{|x| L{|y| x}}]} $_0Cdr = L{|p| p[L{|x| L{|y| y}}]} $_Y = L{|f| L{|g| u = L{|x| f[ L{|g| x[x][g]} ]} u[u][g]}} # --------------------- $_00 = L{|f| L{|x| x}} $_01 = L{|f| L{|x| f[x]}} $_0Add1 = L{|n| L{|f| L{|x| f[n[f][x]] }}} $_0Add = L{|n| ...
true
f42f6a4a5ea7dfd0f0793542fe1f228079a3ae06
Ruby
tsetsefly/launch_school-prepwork
/back_end_prep/ruby_basics_exercises/user_input/login.rb
UTF-8
328
3.078125
3
[]
no_license
response = [nil, nil] USERNAME = 'admin' PASSWORD = 'SecreT' loop do puts '>> Please enter your user name:' response[0] = gets.chomp puts '>> Please enter your password:' response[1] = gets.chomp break if response[0] == 'admin' && response[1] == 'SecreT' puts '>> Authorization failed!' end puts 'Welcome!'
true
3a7d8f66eafeb9f4f656e9c59c72d5e799a41eac
Ruby
almostwhitehat/mailcatcher-api
/lib/mailcatcher/api/mailbox/message.rb
UTF-8
1,116
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'uri' require 'mail' module MailCatcher module API class Mailbox class Message attr_reader :id, :raw attr_reader :message_id, :date attr_reader :from, :to, :subject, :body, :decoded_body, :header_fields attr_reader :mime_type, :charset, :content_type def ini...
true
35a58c5ade3dd850db25d9b66b986f8d2241ecb6
Ruby
bver/GERET
/lib/sampling.rb
UTF-8
1,682
3.265625
3
[ "MIT" ]
permissive
require 'lib/roulette' module Selection # Stochastic Universal Sampling selection method. The probability of the individual selection is # proportional to some (usually fitness) non-negative value (as in Roulette selection). # However, more individuals can be selected at once by the single run of a wheel, whic...
true
01d7ce28e68eb204e2d43477c4dbd229cbc89bca
Ruby
dan3lson/leksi
/app/models/words_api.rb
UTF-8
1,936
2.84375
3
[]
no_license
class WordsApi class NoWordError < StandardError end def initialize(name) @name = name end def define response = self.everything words = [] api_words = response["results"] api_words.each do |word| syllables = response["syllables"] joined_syllables = syllables["list"].join("·") if syllables ne...
true
f1450e5aaac32998208edf434f5cbff82c23e0fe
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/cs169/800/spectral_cluster/cluster6/25627.rb
UTF-8
360
3.75
4
[]
no_license
def combine_anagrams(words) res = Hash.new([]) words.each do |word| w = word.downcase.chars.sort.join res[w] = res[w] + [word] end res.values end puts combine_anagrams(['cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams', 'scream']) # => output: [["cars", "racs", "scar"], ["four"], ["f...
true
a495613abfc62969240aa444cce83431c77625e4
Ruby
bogusoft/cukehead
/lib/cukehead/feature_node_child.rb
UTF-8
1,489
3.171875
3
[ "MIT" ]
permissive
require 'rexml/document' require 'cukehead/feature_node_tags' module Cukehead # Responsible for extracting the contents of a mind map node representing # a sub-section of a feature (such as a Background or Scenario) and # providing it as text for a feature file. # class FeatureNodeChild # Extracts the ...
true
2b40c87ddbb01b0f49b363bc68d522cef0983fbd
Ruby
nstielau/reptile
/lib/reptile/delta_monitor.rb
UTF-8
2,939
2.890625
3
[ "MIT" ]
permissive
module Reptile # This monitor compares the row counts for each table for each master and slave. class DeltaMonitor # Set the user settings for a user that has global SELECT privilidgess def self.user=(user_settings) @user = user_settings end # The user settings for a user that has global sele...
true
f578b551fdfacd449bd578282b95bd43e0f5cfbf
Ruby
petrucioata/fakerbot
/lib/fakerbot/cli.rb
UTF-8
1,629
2.65625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'thor' require 'fakerbot/cli' require 'fakerbot/version' require 'fakerbot/commands/list' require 'fakerbot/commands/search' module FakerBot class CLI < Thor Error = Class.new(StandardError) desc 'version', 'fakerbot version' def version require_relative 'ver...
true
bda7379cb7f68048ce2872dd9b675424f5d94b4f
Ruby
zklamm/ruby-basics
/0_the_basics/exercise_1.rb
UTF-8
97
2.875
3
[]
no_license
first_name = 'Zac' last_name = 'Klammer' full_name = first_name + ' ' + last_name puts full_name
true
3d5e63c66f109bbd8549c6683077ea5af4460ad4
Ruby
btmccollum/oo-banking-v-000
/lib/bank_account.rb
UTF-8
1,368
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class BankAccount attr_accessor :balance, :status attr_reader :name #upon instantiation the object is created with a given name, and a default #@status of open and @balance of $1000 def initialize(name) @name = name @status = "open" @balance = 1000 end def display_balance "Your balance i...
true
fd133dbbc0313dfaddf6a259edd30b5782dd1e89
Ruby
AllPurposeName/mastermind
/lib/printer.rb
UTF-8
5,048
3.828125
4
[]
no_license
require 'colorize' class Printer def mm "#{"M".red}#{"A".red}#{"S".red}#{"T".red}#{"E".red}#{"R".red}#{"M".light_black}#{"I".light_black}#{"N".light_black}#{"D".light_black}" end def intro "Welcome to DJ's MASTERMIND challenge! You are to determine the number and order of four colors: #{"Blue"...
true
79f07e54f4e538d7ef897000e75ce61c7991d6f9
Ruby
JDittles/intro-to-ruby-book
/4_methods/return.rb
UTF-8
179
3.65625
4
[]
no_license
def add_three(number) number + 3 # <== we don't need to put return here, Ruby always returns on the last line of a method end returned_value = add_three(4) puts returned_value
true
33802efa5c54694c5f783ceb6a6da6b2c2e3accf
Ruby
geeksam/hangman
/spec/hangman_spec.rb
UTF-8
3,486
3.453125
3
[]
no_license
require 'rubygems' require 'rspec' require './hangman.rb' describe Hangman do ValidPuzzle = File.open("spec/sample_puzzle.txt").read describe "#new_game" do end describe "#guess" do before(:each) do @hangman = Hangman.new_game(ValidPuzzle) end it "should throw game over if there are no gue...
true
2aea02b53d76a178272ccbc1b5912a2ba6e3c99c
Ruby
flatiron-lessons/ruby-collaborating-objects-lab-web-071717
/lib/artist.rb
UTF-8
519
3.609375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Artist attr_accessor :name @@all = [] def initialize(name) @name = name @songs = [] end def songs @songs end def save @@all << self end def self.find_or_create_by_name(artist) x = @@all.find do |instance| instance.name == artist end if x == nil y = self.new(artist)...
true
12730af4cce5ff3e71d8bf9a00e4b1009bc1b7da
Ruby
RomanVarhola/order_lunch
/app/services/calculate_total_price_for_orders.rb
UTF-8
261
3.328125
3
[]
no_license
class CalculateTotalPriceForOrders attr_reader :orders def initialize(orders) @orders = orders end def call total_price = 0 @orders.each do |order| total_price += order.food.price + order.drink.price end total_price end end
true
f3f68bdd431b1c5bb4180d98a853fc829a83f601
Ruby
recortable/letamendi
/app/controllers/alquileres_controller.rb
UTF-8
2,632
2.546875
3
[]
no_license
class AlquileresController < ApplicationController layout 'cinemascope' def index params[:id] = Time.now lista render :action => 'lista' end def lista ms = params[:id].to_i now = Time.at(ms) if ms > 0 now = Time.now if ms == 0 @report = Report.new(now) end def close_rent ...
true
b00a1610b4c1b65f04635fe2859bce61f8892641
Ruby
smcand92/week2_weekend_hw
/specs/room_spec.rb
UTF-8
1,427
3.21875
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../rooms') require_relative('../songs') require_relative('../guests') class RoomTest < MiniTest::Test def setup @song1 = Song.new("Dancing Queen") @song2 = Song.new("Silly Boy") @song3 = Song.new("Younger Now") @song4 = Song.new("N...
true
cc2af552a1802579c65dad041da1804f353e9f85
Ruby
Rockster160/Portfolio
/lib/core_extensions/core_extensions.rb
UTF-8
1,199
2.890625
3
[]
no_license
module CoreExtensions refine Hash do def deep_set(path, new_value) return self unless path.any? new_hash = new_value path.reverse.each do |path_key| new_hash = {path_key => new_hash} end self.deep_merge!(new_hash) { |key, this_val, other_val| this_val + other_val } sel...
true
384629b5afbaaa7a169d30489340cd4010ee7098
Ruby
yaoyunchen/LH_warcraft3
/spec/test_11.rb
UTF-8
1,155
3.296875
3
[]
no_license
require_relative 'spec_helper' # In most strategy games, like Warcraft III, buildings can also be attacked by units. Since a barracks is a building, it has substantial more HP (500) To make matters worse, a Footman does only HALF of its AP as damage to a Barracks. This is because they are quite ineffective against bui...
true
e0accbb1165810de9d0fc4b529d2c396996d6c1c
Ruby
levkk/emoji_differ
/lib/emoji_differ/slack_api.rb
UTF-8
655
2.765625
3
[ "MIT" ]
permissive
require "net/https" require "emoji_differ/list" module EmojiDiffer class SlackApi < Struct.new(:token) API_ENDPOINT = 'https://slack.com/api/emoji.list' def emoji EmojiDiffer::List.new.load_json(get_emoji.to_s) end def api_endpoint API_ENDPOINT end def build_query uri = U...
true
3ac9e915161ebce4d2fdec60ae85b84a6a3a7511
Ruby
guyviner/codecorelife
/day2/day2/quiz3.rb
UTF-8
176
3.1875
3
[]
no_license
# sandra puts "how many sides does a hexagon have?" response = gets.chomp case response when "six", "Six", 6.to_s puts "that is correct" else puts "that is incorrect" end
true
ffa988d764d5752d69060807e1b3c999fc17229d
Ruby
tommfernandes/rubypragmatic
/rubypragmatic-sources/p33-metods-class/song_test.rb
UTF-8
357
3.1875
3
[]
no_license
require_relative 'song.rb' require_relative 'song_list.rb' class SongTest s1 = Song.new("Song 1", "Artista 1", 179) puts "Song #{s1.name}, with #{s1.duration} seconds, is too long? #{SongList.is_too_long(s1)}" s2 = Song.new("Song 2", "Artista 2", 475) puts "Song #{s2.name}, with #{s2.duration} seconds, is too l...
true
4971ccb8919676bf09eab4ec5601d88c33ef1f2f
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/word-count/3f570100ff444fc382eb8458a831598e.rb
UTF-8
227
3.1875
3
[]
no_license
class Phrase < Struct.new(:text) def word_count counts = {} counts.default = 0 words.each do |word| counts[word] += 1 end counts end private def words text.downcase.scan /\w+/ end end
true
af87de318d77ee5ca5e3c5bc6aa45dd0b5cfb821
Ruby
TheArQu/TDCGExplorer
/batora/lib/authenticated_system.rb
UTF-8
900
2.546875
3
[]
no_license
module AuthenticatedSystem protected def logged_in? !!current_user end def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end def current_user=(user) session[:user_id] = user ? user.id : nil @current_user = user end def login_req...
true
e7c8d3d1f6ad875ac2a5f5f9423719bbe3b6658a
Ruby
tk0358/meta_programming_ruby2
/chapter5/23module_trouble_extend.rb
UTF-8
201
3.421875
3
[]
no_license
module MyModule def my_method; 'hello'; end end obj = Object.new obj.extend MyModule p obj.my_method #=> "hello" class MyClass extend MyModule end p MyClass.my_method #=> "hello"
true
018b70a4c7983d21168a41d3cc700542ec12816f
Ruby
maht0rz/otvorenezmluvy
/lib/core_ext/recursive_openstruct.rb
UTF-8
866
3.125
3
[]
no_license
# use optimized OpenStruct without slow method creation class OpenStruct def initialize(hash = {}) @table = hash.with_indifferent_access end def method_missing(method, *args) member = method.to_s if member.chomp!('=') @table[member] = args[0] else @table[member] end end def r...
true