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
39735d0972a3b4bdfe5faa8705fbded84dadd9cc
Ruby
taratip/chillow
/spec/apartment_spec.rb
UTF-8
2,271
2.984375
3
[]
no_license
require 'spec_helper' describe Apartment do it 'should take 8 arguments to construct a apartment object' do expect(Apartment.new("123 Boston st.", "Boston", "MA", "02116", "1300", "2016-09-01", "2017-09-01", 4)).to be_a(Apartment) end it 'has readers for address, town, state, zip, rent, lease start date and...
true
308b235cbec26977094d74653e9e5171d0d3d353
Ruby
sametcilli/caesar_cipher
/caesar_cipher.rb
UTF-8
594
3.84375
4
[]
no_license
def convert(char, right) new_i = (char.ord + right) lowerlist = ("a".ord.."z".ord).to_a upperlist = ("A".ord.."Z".ord).to_a #p upperlist #p char.ord, new_i, upperlist[2], "Z".ord - new_i, upperlist["Z".ord - new_i].chr case char.ord when "a".ord.."z".ord lowerlist[(new_i - "z".ord) -...
true
3d6dfb1ff2207573397b68d7fd2ae8c110704403
Ruby
szabgab/code-maven.com
/examples/ruby/split_comma_limit.rb
UTF-8
134
3.09375
3
[]
no_license
require 'pp' words_str = 'Foo,Bar,Baz,Moo,Zorg' words_arr = words_str.split(',', 3) pp words_arr # ["Foo", "Bar", "Baz,Moo,Zorg"]
true
52f6649b3ec35a4b7767f3e0dfd519f0f559fddc
Ruby
Messi2002/furima-28804
/spec/models/category_spec.rb
UTF-8
3,499
2.578125
3
[]
no_license
require 'rails_helper' RSpec.describe Item, type: :model do before do @item = FactoryBot.build(:item) @item.image = fixture_file_upload('public/images/test_image.png') end describe '商品情報の登録' do context '商品情報の登録がうまくいくとき' do it 'item,introduction,category_id,status_id,price,postage_payer_id,prep...
true
242bedef613b842fac25357d75a48ce2f7d699d6
Ruby
tochman/hash-demo
/lib/my_hash.rb
UTF-8
2,473
3.28125
3
[]
no_license
require 'terminal-table' require 'byebug' class MyHash attr_accessor :grid def initialize self.grid = populate_grid end def check_neighbours(coord) if all_water_cells?(coord) :all_water else :ships_around end end def populate_grid grid = {} [*'A'..'J'].each d...
true
07733dd9000e8c776ca8402f38530ff1f0ea8b68
Ruby
tenzin2017/ruby_fundamentals1
/exercise4_4.rb
UTF-8
196
3.671875
4
[]
no_license
puts "Enter your name" user_name = gets.chomp if (user_name.length > 10) puts " Hi! #{user_name}" elsif (user_name.length < 10) puts "Hello! #{user_name}" else puts "Hey! #{user_name}" end
true
b03d95273dbacd6c287c1a67c196e816c4311c26
Ruby
mateowh/checkout
/spec/promotion_spec.rb
UTF-8
1,492
3.0625
3
[]
no_license
require 'promotion' require 'items/lavender_heart' class DummyTestClass include Promotion end RSpec.describe Promotion do let(:dummy_class) { DummyTestClass.new } describe '.discount_60_spend' do let(:basket_total) { 100 } let(:items) { [] } subject { dummy_class.discount_60_spend(basket_total, it...
true
2878b4e108a1048f3cdf5d5ce3a19fb56e4d36f8
Ruby
rossyoung5/tts-ruby_projects
/array_example.rb
UTF-8
221
3.5
4
[]
no_license
fruit = ["apple", "orange", "banana"] fruit << "tomato" fruit.push("kiwi") fruit.each_with_index do |fruit_item, index| puts "#{fruit_item} with an index of #{index}" end fruit.each { |fruit_item| puts "#{fruit_item}"}
true
e3f22fdc747a063bf84a0faf5690fc2fd2b475eb
Ruby
LoveMyData/atdis
/lib/atdis/model.rb
UTF-8
7,044
2.5625
3
[ "MIT" ]
permissive
require 'multi_json' require 'active_model' require 'date' module ATDIS module TypeCastAttributes extend ActiveSupport::Concern included do class_attribute :attribute_types end module ClassMethods # of the form {section: Fixnum, address: String} def set_field_mappings(p) d...
true
3b6296a28d7537d4ea290859ef15811aabb25fa3
Ruby
tyrbo/mastermind
/test/game_test.rb
UTF-8
878
2.78125
3
[]
no_license
require './test/test_helper.rb' require './lib/game.rb' class GameTest < MiniTest::Test def test_a_game_starts_with_zero_guesses g = Game.new assert_equal 0, g.guesses.count end def test_add_a_guess g = Game.new g.start g.guess('RGBY') assert_equal 1, g.guesses.count end def test_...
true
dba7f017b8d40a1b80ad3864cd0230c5bda8d813
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/word-count/9f2a3f9824d942929f0f3ba07fbce575.rb
UTF-8
304
3.359375
3
[]
no_license
class Words attr_reader :sentence def initialize(string) @sentence = normalize(string) end def count sentence.each_with_object(Hash.new(0)) do |word, hash| hash[word] += 1 end end private def normalize(string) string.downcase.gsub(/\W+/, ' ').split(" ") end end
true
1815f19b6b233d5906a5e74ed21de6ce01ef3b23
Ruby
lynettepod/programming-book
/Ch7-Hashes/hash_ex2.rb
UTF-8
473
4.125
4
[]
no_license
#hash_ex2.rb # Merge will not change the original hash; Merge! is destructive and will change the original hash to the result of the merged hash created h1 = {a: 120, b: 90, c: 60} h2 = {a: 200, b: 700, d: 89, e: 200} h3 = h1.merge(h2) # Merged with regular merge; both original hashes stay the same #h3 = h1.merge!(...
true
fd6a200506a8ae60cd46dc9e7e3a2dd145306dac
Ruby
laurenherdman/learn_ruby
/03_simon_says/simon_says.rb
UTF-8
613
3.84375
4
[]
no_license
def echo (input) input end def shout (cap) cap.upcase end def repeat (string, num = 2) output = [] while num > 0 output.push(string) num -= 1 end output.join(' ') end def start_of_word(word, number) word[0..number-1] end def first_word(some_words) first_word = some_words.split(' ') first_word[0] end d...
true
103677abe043e6a9e5f9269f02dfd19e06329305
Ruby
probpgh/learnruby_exercises
/ex13b.rb
UTF-8
245
2.859375
3
[]
no_license
alpha, bravo, charlie, delta, echo = ARGV puts "Your first variable is: #{alpha}" puts "Your second variable is: #{bravo}" puts "Your third variable is: #{charlie}" puts "Your fourth variable is: #{delta}" puts "Your fifth variable is: #{echo}"
true
990875ad4df4bcaa8d1260d7c4fac56edfee8f9c
Ruby
richcole/Griff
/cass_browser/util.rb
UTF-8
488
3.484375
3
[]
no_license
def min_of(x,y) if x != nil && x <= y then return x else return y end end def max_of(x,y) if x != nil && x >= y then return x else return y end end def contents_of_file(filename) result = nil File.open(filename) { |file| return file.read() } return result end def count_in xs count = 0 for x in xs do ...
true
22934debc44681c7a1f105c2cf5cbfe48d93979d
Ruby
illogic-al/rosalind-ruby-solutions
/lib/rna.rb
UTF-8
395
3.140625
3
[]
no_license
require_relative 'dna' class RNA attr_reader :bases, :dna_bases, :rna_bases def initialize(sequence) @bases = Gandalf.the_validator(sequence) end def dna_bases? @bases.include? "T" end def rna_bases? @bases.include? "U" end def dna_to_rna @rna_bases = @bases.gsub("T", "U") end ...
true
a72e09eab7fbe87d395ee7869c1c9e77349bdc68
Ruby
tcweinlandt/TnTStats
/TnT_replay_parser.rb
UTF-8
2,340
2.765625
3
[]
no_license
require 'rubygems' require 'nokogiri' require 'cgi' require 'open-uri' def parse(filename) @doc = Nokogiri::XML(File.open(filename)) player_names = @doc.xpath("//Name") player_ids = @doc.xpath("//m_SteamID") player_teams = @doc.xpath("//Team") player_picks = @doc.xpath("//Card") names = [] ids = [] teams = [] ...
true
22d75ae628ee3454153d8fbfb3f7063a81c8a3b9
Ruby
hambrice/playlister-sinatra-v-000
/app/models/artist.rb
UTF-8
354
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Artist < ActiveRecord::Base has_many :songs has_many :genres, through: :songs #binding.pry def slug self.name.split.collect do |word| #binding.pry word.downcase.gsub(/\W/,"") end.join("-") end def self.find_by_slug(slug) Artist.all.select do |artist| artist....
true
f1b9cba29fcd5510925f9bd4c96b4899bcc8ecd2
Ruby
ankush-amura/ShopReg
/app/models/customer.rb
UTF-8
964
2.875
3
[]
no_license
class Customer < ApplicationRecord # this is the callback that needs to perform capitalization opoeration as soon as customer is created after_initialize do |user| puts "u have Successfully Created A customer" user.name.capitalize! end # this callback is responsible for updating the contact to some...
true
fa609a22f6ab4d9116ad7e1bfa093d981d3e1550
Ruby
bryansray/loottrackr
/spec/models/character_spec.rb
UTF-8
2,959
2.875
3
[]
no_license
require 'spec_helper' describe Character do it "should have looted many items" do character = Character.create item = Item.create loot = Loot.create :item => item, :character => character character.should have(1).items end it "should be able to equip a specific item", :focus => false do ...
true
356138ffba8566e6742cf376709bcffb95637905
Ruby
daveguymon/think_like_a_programmer
/decode_a_message.rb
UTF-8
840
3.390625
3
[]
no_license
def decoder(sequence) upcase = ("A".."Z").to_a downcase = ("a".."z").to_a punctuation = ["!", "?", ",", ".", " ", ";", '"', "'"] mode = "up" decoded_message = [] sequence.each do |integer| if mode == "punct" remainder = integer % 9 else remainder = integer % 27 end if re...
true
d968d1cac553bd7244530aaef97b0229a35d446c
Ruby
ricardosikic/ruby-materia
/clase7-madlibgame/ex1.rb
UTF-8
403
3.28125
3
[]
no_license
# Este famoso juego es sobre crear frases a traves de la informacion recogida # y almacenada en las variables puts 'ingresa un color' color_rosas = gets.chomp() puts 'ingresa tipo de flores' nombre_flores = gets.chomp() puts 'ingresa nombre de famoso' nombre_celebridad = gets.chomp() puts ('las rosas son ' + colo...
true
f13fdbad4a1dabb0f762e37d6a82e9f315ec0d99
Ruby
Precnet/Lesson_8
/cargo_train.rb
UTF-8
950
3.28125
3
[]
no_license
# frozen_string_literal: true require_relative 'train.rb' require_relative 'train_iterator.rb' class CargoTrain < Train attr_reader :carriages include TrainIterator def initialize(train_number) super('cargo', 0, train_number) @carriages = [] end def add_carriage(carriage) error = 'Can`t add ne...
true
95d6117f3cbf358c621cd90cceb077843dd5daae
Ruby
litola/phase-0-tracks
/ruby/iteration.rb
UTF-8
1,014
3.8125
4
[]
no_license
def print_block x = 20 y = 10 puts "this is before running the block" yield(x, y) puts "this is after running the block" end print_block { |x,y| puts "name is #{x} and age is #{y}."} sports = ["Footbal", "Soccer", "Tennis"] leagues = { football: "NFL", soccer: "MLS", tennis: "Summer Circ...
true
9a603faf25c182c4c79f3639ebd1cc590524ff02
Ruby
ChristineBuell/phase-0-tracks
/ruby/list/todo_list.rb
UTF-8
264
3.359375
3
[]
no_license
class TodoList def initialize(array) @array = array end def get_items @array end def add_item(item) @array << item end def delete_item(item) @array.delete(item) @array end def get_item(index) @array[index] end end
true
ea1ed1d56fdc164a129aa3050098ca5b5b120abd
Ruby
jbhdeconinck/oystercard2310
/spec/oystercard_spec.rb
UTF-8
1,995
2.953125
3
[]
no_license
require 'oystercard' describe Oystercard do let(:max_balance) {Oystercard::MAX_BALANCE} let(:min_balance) {Oystercard::MIN_FARE} let(:station) { double(:station, name: "Aldgate", zone: "1") } let(:journey) { double(:journey, fare: 1, start_journey: station, reset: nil, entry_station: station, exit_station: st...
true
ab493f4cda2003b8bfc67793a0e3a7898835d151
Ruby
ElvinGarcia/ttt-10-current-player-q-000
/lib/current_player.rb
UTF-8
400
3.46875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# #turn_count could be done with 3 lines of code def turn_count(board) moves_taken=0 board.each{|token| unless token ==" " || token == "" || token == nil moves_taken+=1 end } return moves_taken end def current_player(board) board.reject!{|item|item == "" || item == " " || item == nil} if boa...
true
bcf442a751e55f3648d4708f371110ae5c50459a
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/pig-latin/01166fb8262e4516811bedef7fb7a4f9.rb
UTF-8
586
2.953125
3
[]
no_license
module PigLatin extend self def translate phrase phrase.gsub(WORD, &method(:translate_word)) end WORD = /\p{L}+/ VOWEL_START = Regexp.union( /^[aeiou]/, /^[yx][^aeiou]/ ) CONSONANT_START = Regexp.union( /^[^aeiou]*qu/, /^[^aeiou]+/ ) private_constant :WORD, :VOWEL_START, :CONSON...
true
a81be894e2b0ed6574aa444a8438cde98da0ac50
Ruby
mmilata/vpsadminos
/osctld/lib/osctld/db/pooled_list.rb
UTF-8
969
2.609375
3
[]
no_license
require 'osctld/db/list' module OsCtld class DB::PooledList < DB::List # Find object by `id` and `pool`. # # There are two ways to specify a pool: # - use the `pool` argument # - when `pool` is `nil` and `id` contains a colon, it is parsed as # `<pool>:<id>` def find(id, pool = ni...
true
3daaf1408b398f79287c8c92e272687823abbe72
Ruby
Thoanguyen65/ProjectEuler
/ex07/ex07.rb
UTF-8
353
3.828125
4
[]
no_license
# What is the 10001st prime number def check_prime?(n) (2..n - 1).each do | i| if n % i == 0 return false end end return true end #start: number 3 count_position = 1 number = 1 until count_position == 10001 number += 2 if check_prime?(number) count_position += 1 end ...
true
4aa4c3acd77a777bbcb58d124a61c2780c269498
Ruby
civol/HDLRuby
/lib/HDLRuby/hruby_rsim.rb
UTF-8
48,422
2.625
3
[ "MIT" ]
permissive
require "HDLRuby/hruby_high" # require "HDLRuby/hruby_low_resolve" require "HDLRuby/hruby_bstr" require "HDLRuby/hruby_values" module HDLRuby::High ## # Library for describing the Ruby simulator of HDLRuby # ######################################################################## class SystemT ## Enh...
true
85bdc2b5fb30084c66307a123b9afcba091cd4f1
Ruby
smart-rb/smart_types
/spec/types/value/string_spec.rb
UTF-8
4,224
2.53125
3
[ "MIT" ]
permissive
# frozen_string_literal: true RSpec.describe 'SmartCore::Types::Value::String' do shared_examples 'type casting' do specify 'type-casting' do expect(type.cast(:test)).to eq('test') expect(type.cast('test')).to eq('test') expect(type.cast(nil)).to eq('') expect(type.cast({})).to eq('{}') ...
true
39277d64bbc9b1c7375ee667cf18d6c0d44ce65d
Ruby
marmo002/w2d3assignment2
/exercise14.rb
UTF-8
873
3.890625
4
[]
no_license
my_dogs = [ { :name => 'Ralph', :position => 5 }, { :name => 'Cindy', :position => 8 }, { :name => 'Jade', :position => 11 } ] def get_absent_dogs(my_dogs) absent_dogs = my_dogs.select do |each_dog| each_dog[:position] > 10 end end bad_dogs = get_absent_dogs(my_dogs) p bad_dogs def call_absent_dogs(bad_...
true
6442d1a11ecc511821b4a69beea6bc1c1a817588
Ruby
valdineireis/wbotelhos-com-br
/spec/initializers/slug_spec.rb
UTF-8
567
2.9375
3
[ "MIT" ]
permissive
# coding: utf-8 require 'spec_helper' describe String do let(:text) { "City - São João del-rey ('!@#$alive%ˆ&*~^]}" } it 'slug blank' do ' '.slug.should == '' end it 'slug space' do 'a b'.slug.should == 'a-b' end it 'slug last dash' do 'a b !'.slug.should == 'a-b' end it 'keeps undersc...
true
4881aabcd25d080a2c4deeb308b3510b57732b3e
Ruby
fzondlo/elevators
/spec/elevator_router_spec.rb
UTF-8
977
2.703125
3
[]
no_license
require 'pry' require_relative '../elevator_router' require_relative 'spec_helper' describe ElevatorRouter, "Manage Elevators" do context "defaulted with 5 floors" do let(:subject) { described_class.new(5) } it "has a top floor" do expect(subject.top_floor).to eq 5 end it "has a bottom floor"...
true
242b86f11b43152407d5d40ab97443b3d76e8dd9
Ruby
ericsoderberg/pbc3
/app/controllers/books_controller.rb
UTF-8
1,725
2.59375
3
[]
no_license
class BooksController < ApplicationController def index @books = VerseParser::BIBLE_BOOKS.map{|b| b[0]} @testaments = [{name: 'Old Testament', sections: []}, {name: 'New Testament', sections: []}] testament = @testaments[0] section = nil @max_count = 0 @books.each do |book| if '...
true
29c4e2ce9bb5c00950ebe0012cc3a23d99c947b5
Ruby
mmlamkin/api-muncher
/test/lib/recipe_test.rb
UTF-8
973
2.71875
3
[]
no_license
require 'test_helper' describe Recipe do it "raises an error without all required parameters" do proc { Recipe.new }.must_raise ArgumentError proc { Recipe.new("Name") }.must_raise ArgumentError end it "must initialize parameters correctly" do recipe = Recipe.new("name", "www.f...
true
2fbf5b50b6e0cb7391bb57609e8c157773af9832
Ruby
jmspsi126/Ruby-sample-userve-
/app/services/payments/stripe.rb
UTF-8
1,053
2.671875
3
[]
no_license
class Payments::Stripe UnsupportedAmountType = Class.new(StandardError) def initialize(stripe_token) @stripe_token = stripe_token @error = nil end def charge!(amount:, description:) amount_in_cents = amount_to_cents(amount) raise UnsupportedAmountType("Amount should be > 0 #{amount}") if amo...
true
c2992ff09dd4fe1a431ff970ecd90583f8abbed6
Ruby
Varsha1986/ruby_20-8-master
/ruby_20-8-master/polymorphism.rb
UTF-8
369
3.453125
3
[]
no_license
class Duck def initialize(speaking,flying) @speaking = speaking @flying = flying end end class Penguin < Duck def speak @speaking end def fly @flying end end class Bird < Duck def speak @speaking end def fly @flying end end parrot=Penguin.new("woohhhs","fly") puts parrot.speak puts parrot.fly s=...
true
7b1db84456493b849b7dd2b6a649ce519b2fce59
Ruby
charlesbjohnson/super_happy_interview_time
/rb/lib/leetcode/lc_394.rb
UTF-8
1,490
3.625
4
[ "MIT" ]
permissive
# frozen_string_literal: true module LeetCode # 394. Decode String module LC394 # Description: # Given an encoded string, return its decoded string. # # The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. # Note that k ...
true
18205ddfa9fced3a77d4badb689917049e7702a1
Ruby
Nuix/SuperUtilities
/RubyTests/PlaceholderResolver_MultiValue.rb
UTF-8
7,346
2.75
3
[ "Apache-2.0" ]
permissive
# Demonstrates basic usage of placeholder resolver and multi value placeholders. script_directory = File.dirname(__FILE__) # Initialize super utilities require File.join(script_directory,"SuperUtilities.jar") java_import com.nuix.superutilities.SuperUtilities java_import com.nuix.superutilities.misc.PlaceholderResolv...
true
2039c34610ac9379d4b2b3759b9faada730fb383
Ruby
jamiemills98/ruby-challenges
/03_largest_number.rb
UTF-8
324
3.734375
4
[]
no_license
# Your code here largest_number = [] puts "Type in any number" number_1 = gets.to_i largest_number << number_1 puts "Type in any number" number_2 = gets.to_i largest_number << number_2 puts "The largest number you entered is: " puts largest_number.max ...
true
d52e1db392546b87f36b481663384a6af731db5f
Ruby
stuartstein777/CodeWars
/6KYU/Grouped by commas/solution.rb
UTF-8
417
3.484375
3
[]
no_license
def solution(n) s = n.to_s len = s.length puts len if len <= 3 return n.to_s elsif len % 3 == 0 return s.chars.each_slice(3).map { |x| x.join("") }.join(",") elsif (len - 1) % 3 == 0 return s[0] + "," + s.chars[1..-1].each_slice(3).map { |x| x.join("") }.reverse.join(",") else return s[...
true
8023ce3e56cb3af7cf5827d2945c36d848ea4bdb
Ruby
ethansagin/school-domain-online-web-ft-041519
/lib/school.rb
UTF-8
398
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class School attr_reader :name, :roster def initialize(name) @name = name @roster = {} end def add_student(stu_name, stu_grade) roster[stu_grade] ||= [] roster[stu_grade] << stu_name end def grade(num) roster[num] end def sort new_var = {} roster.each ...
true
2468fb54e5dd4ba7fbfec93bb9701b771f9204bd
Ruby
wonda-tea-coffee/yukicoder
/51.rb
UTF-8
86
2.65625
3
[]
no_license
w = gets.chomp.to_i d = gets.chomp.to_i d.downto(2) do |i| w -= w/(i*i) end puts w
true
678c54b818a4845ee045fe468fad12260aa1fd21
Ruby
lsethi-xoriant/FandomRails4
/app/helpers/linked_call_to_action_helper.rb
UTF-8
11,484
2.609375
3
[]
no_license
module LinkedCallToActionHelper # Internal: Custom class and methods useful to represent the set of trees containing a call # to action following linking paths defined in interaction_call_to_actions table and cta answer call_to_action_id. # Based on Node class, every single tree is identified by its root Node. ...
true
1e121bbf5eb3b86073ad6923ee96ac941b3d08a9
Ruby
kimono-k/ruby-training-field
/fundamentals/14hashes.rb
UTF-8
138
3.984375
4
[]
no_license
# Hashes -> Associative Array, key => value, dictionary states = { 1 => "Hyuna", 2 => "Kim" } puts states[1] # prints value inside key
true
8b2fa7b3757de9b1279dd5e63e779fbaff198478
Ruby
shazgorn/waroforbs
/app/model/town_aid.rb
UTF-8
1,330
2.609375
3
[]
no_license
require 'prime' class TownAid include Celluloid include Celluloid::Notifications include Celluloid::Internals::Logger def initialize(town) @town = town @awakenenings = 0 @town_aids = 0 @online = true subscribe('user_auth', :user_auth) subscribe('user_quit', :user_quit) end def us...
true
d388c7d7dd3e7bf9dae91e3a53b7f952b3c14367
Ruby
jenpoole/reverse-each-word-cb-000
/reverse_each_word.rb
UTF-8
352
4
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(phrase) # phrase = phrase.split # convert string to array reversed_phrase = [] phrase.split.collect do |word| # convert string to array and iterate over each reversed_phrase << word.reverse # reverse each word in the array & add to new array end reversed_phrase.join(" ") # convert...
true
65a2de4092321ed576ce39f3b6d583746261c2e0
Ruby
KevinKra/Enigma
/test/encrypt_test.rb
UTF-8
575
2.828125
3
[]
no_license
require "minitest" require "minitest/autorun" require "minitest/pride" require 'mocha/minitest' require_relative "../lib/Encrypt.rb" class EncryptTest < Minitest::Test def setup @encrypt = Encrypt.new @key = "12345" @date = "121219" end def test_it_exists assert_instance_of Encrypt, @encrypt e...
true
15eecdcd19e93a53d625b3aaeb331a5f5f7e396c
Ruby
Davkang/guessing-game
/guessing-game.rb
UTF-8
1,476
4.65625
5
[]
no_license
# Accept user input and save it as a variable. # Start a while loop. The while loop should run for as long as the user hasn't found the correct answer. # try again. # After the user has found the correct answer, the loop should exit and a congratulatory message should display. # require 'pry' score = 0 # Ask t...
true
a58d52306c08a1ce0c6b1542f472302be0e0c433
Ruby
nick-stebbings/ruby-rb101-109
/small_problems/Easy_8/ex10.rb
UTF-8
602
4.65625
5
[]
no_license
# Write a method that takes a non-empty string argument, and returns the middle # character or characters of the argument. If the argument has an odd length, # you should return exactly one character. If the argument has an even length, # you should return exactly two characters. def center_of(str) len = str.len...
true
f0328c90d353df2f6aff87e6b701e69857092191
Ruby
a8t/reinfoce25aug
/reinforce.rb
UTF-8
52
2.796875
3
[]
no_license
def word_counter(string) string.split.count end
true
e26da332d7849edfc82a2c06ecde0f9da8c813d5
Ruby
air1bzz/organ_cooker
/lib/organ_cooker/windchest.rb
UTF-8
3,427
3.828125
4
[ "MIT" ]
permissive
require 'organ_cooker/shared' module OrganCooker ## # Represents a +windchest+ for a pipe organ. Not to be confused with the # keyboard. A windchest can have more music notes than a keyboard. # Ex : "Grand-Orgue", "Pedal", "Positif"... class WindChest include Shared ## # The +name+ of the windche...
true
78b763f6e881c196518c03aaa44f2cef84595d05
Ruby
rmatambo8/Ruby-Small-Problems
/easy_5/time_of_day_2.rb
UTF-8
1,510
4.40625
4
[]
no_license
# Prompt: Write two methods that each take a time of day in 24 hr format # and return the number of minutes before and after # midnight respecfully. Both methods should return a value in the range # 0..1439 # code needed =begin P (understand the Problem) - I am given a time in hours and minutes - Convert them t...
true
f02e55152ae8e1f626691142dd93ab4c51f37a62
Ruby
jjhay-bot/batch8-activities
/rubyActivities/codingExercise/count_positives.rb
UTF-8
212
3.296875
3
[]
no_license
array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15] newArray = [] positive = array.select {|x| x > 0 } negative = array.select {|x| x < 0 } newArray.push(positive.length, negative.sum) print newArray
true
7d40bd26c76c710392e0d574f5663b64d29a8876
Ruby
pdpino/music-app
/app/controllers/application_controller.rb
UTF-8
2,535
2.59375
3
[]
no_license
class ApplicationController < ActionController::Base protect_from_forgery with: :exception # makes methods available in the views helper_method :current_user, :is_current_user_admin?, :is_in?, :has_create_permission, :has_modify_permission? def current_user # REVIEW: this method is called a lot of times, ...
true
871361e44c10cccb90a04699d2ae87d841fa90dc
Ruby
tk-com2415/kadai-ruby-oop-3
/human.rb
UTF-8
409
3.46875
3
[]
no_license
require './animal' require './thinkable' class Human < Animal include Thinkable # インスタンスが持つ変数(値) attr_accessor :name, :age, :hobby # インスタンスを初期化するための、特別なメソッド def initialize(name,age,hobby) self.name = name self.age = age self.hobby = hobby end end # tanaka = Human.new("田中",25,"電車") # tanak...
true
7c538038a99c860f0f11a6ba1cb2cf422ce877aa
Ruby
jbkimble/module_3_diagnostic
/app/services/nrel_fuel.rb
UTF-8
494
2.984375
3
[]
no_license
class NrelFuel attr_reader :name, :address, :fuel_type, :distance, :access_times def initialize(attributes={}) @name = attributes[:station_name] @address = attributes[:street_address] @fuel_type = attributes[:fuel_type_code] @distance = attributes[:distance] @access_times = attributes...
true
39f88316a0f275cd22542f0ddeaaea2a9d353684
Ruby
sarabrandao21/grocery-store
/lib/customer.rb
UTF-8
716
3.1875
3
[]
no_license
require 'csv' class Customer attr_reader :id attr_accessor :email, :address def initialize(id, email, address = {}) @id = id @email = email @address = address end def self.all all_customer = [] CSV.read('./data/customers.csv').each do |customer| all_customer << Customer.new(c...
true
a3ad9dbfb4d83a354c1f541195daa0a551e07262
Ruby
NosaPrecious/oo-basics-dc-web-career-040119
/lib/shoe.rb
UTF-8
620
3.640625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Make your shoe class here! class Shoe def initialize(brand_name) @brand= brand_name end def brand @brand end def color=(color_type) @color= color_type end def color @color end def size=(size_type) @size= size_type end def size @size end def mat...
true
caf3e4eea765549a51ffb76699aa987b95030c7c
Ruby
hanrattyjen/learn_to_program
/ch14-blocks-and-procs/better_program_logger.rb
UTF-8
525
3.203125
3
[]
no_license
$logger_depth = 0 def better_log desc, &block prefix = ' '*$logger_depth puts prefix + 'Beginning "' + desc + '"...' $logger_depth = $logger_depth + 1 result = block.call $logger_depth = $logger_depth - 1 puts prefix + '..."' + desc + '" finished, returning: ' + result.to_s end better_log 'outer block' do bett...
true
5836a6354681e363e9101d67fcbc1a231e59638b
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/rna-transcription/4665bbdbf8784c2a9b15be46245bb280.rb
UTF-8
149
2.6875
3
[]
no_license
class Complement def self.of_dna(s) return s.tr('GCTA', 'CGAU') end def self.of_rna(s) return s.tr('CGAU', 'GCTA') end end
true
657da3cfb73267766eb6b02a152305158adc16c6
Ruby
fideliom/problem
/server.rb
UTF-8
440
2.703125
3
[]
no_license
require 'socket' server = TCPServer.open(2000) loop { client = server.accept request = client.read verb, file = request.split(' ') print verb if (File.exist?(file)) if verb == 'GET' content = File.open(file).read response = "HTTP/1.0 200 OK\r\n\r\nContent-Type...
true
89d2b8a2e3363f512244ebcf204ad02eaccd0155
Ruby
liuqiaoping7/CourseSelect
/app/models/grade.rb
UTF-8
841
2.515625
3
[ "MIT" ]
permissive
class Grade < ActiveRecord::Base belongs_to :course belongs_to :user validates :grade_h, numericality: {only_integer: true,greater_than_or_equal_to:0,less_than_or_equal_to:100, message: " 平时成绩 is not a valid grade,please input 平时成绩>=0&&<=100" } validates :grade_e, numericality: {only_integer: true,greater_t...
true
edd105bbc232a38e892b7b3b8138476d96627290
Ruby
nikkigraybeal/rb101
/exercises/easy6/does_list_include.rb
UTF-8
499
4.09375
4
[]
no_license
# Write a method named include? that takes an Array and a search value as arguments. This method should return true if the search value is in the array, false if it is not. You may not use the Array#include? method in your solution. def include?(array, val) includes = array.select { |i| i == val } includes.size > ...
true
67f198f5837e925a17f7ff56e30e1428d64506da
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/leap/e4b3a6c886a441a58e9e8f7d7a73b1f4.rb
UTF-8
353
3.578125
4
[]
no_license
class Year def initialize(year) @year = year end def leap? evenly_divisible_by_4? and (evenly_divisible_by_400? or not_evenly_divisible_by_100?) end def evenly_divisible_by_4? @year % 4 == 0 end def not_evenly_divisible_by_100? not @year % 100 == 0 end def evenly_divisible_by_400?...
true
317a1b26c246b6354c6c047b8ed0cda8c68a7b95
Ruby
chylli/calculator-ruby
/spec/lexer_spec.rb
UTF-8
2,026
3.140625
3
[]
no_license
require 'lexer' describe Lexer do it 'should parse "" as end token' do for str in ['', ' ', ' '] do lexer = Lexer.new(str) expect(lexer.next_token.kind).to eq(Token::End) end end it 'should parse "5" as number and has end token' do for str in ['5', '5 ', ' 5 ', ' 5'] do lex...
true
298e3d09af8ac30d8173b998e6c8482043409d9e
Ruby
glukhikh/multicloud-core
/lib/multicloud/core/entities/directory.rb
UTF-8
874
2.625
3
[]
no_license
module Multicloud module Core module Entities # The cloud storage resource (base for file/dir). class Directory < Resource attr_reader :resource_list # Creates a new directory. # @param [String] name - The directory name. # @param [String] path - The directory path. ...
true
df5dcc1b34b6d8f117662afbd0a3fbfe4102f2d9
Ruby
eregon/adventofcode
/2020/16a_parse.rb
UTF-8
365
2.765625
3
[]
no_license
fields, mine, others = File.read('16.txt').split("\n\n") valid = fields.lines.flat_map { |line| line[/^[\w ]+: ((\d+-\d+)( or \d+-\d+)*)$/, 1].split(' or ').map { |range| range =~ /(\d+)-(\d+)/ and ($1.to_i..$2.to_i) } } p others.lines.drop(1).flat_map { |line| line.chomp.split(',').map(&:to_i) }.select { |...
true
802664841d2df8b80103a637657ec895b69f0eea
Ruby
ncaq/aoj-code
/10025/main.rb
UTF-8
202
2.75
3
[]
no_license
a, b, c = gets.split(' ').map(&:to_i) rc = c * Math::PI / 180 h = b * Math::sin(rc) puts [a * h / 2, a + b + Math::sqrt((a ** 2) + (b ** 2) - 2 * a * b * Math::cos(rc)), h].map{ |f| sprintf("%.8f", f)}
true
8846a7177bbaf210fed414a2c2dbdb0dc33b1828
Ruby
levibostian/Trent
/lib/github/github.rb
UTF-8
1,560
3.015625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'net/http' require 'json' require_relative '../log' # Functions to run on GitHub class GitHub def initialize(api_key) @api_key = api_key end # Comment on Pull Request def comment(message) # https://docs.travis-ci.com/user/environment-variables/#convenience-variab...
true
74047fd41020397b1c76be5269f11cc77e66b3dc
Ruby
jeremiahlukus/exploringTests
/test/models/article_test.rb
UTF-8
917
2.5625
3
[]
no_license
require 'test_helper' class ArticleTest < ActiveSupport::TestCase def setup @article = Article.create(title: "Article1", description: "This is an article",) end test 'article should be valid' do assert @article.valid? end test 'title should be present' do @article.title = " " assert_not...
true
e756522783b9380135d59a5767083ed768a80d1e
Ruby
beaucouplus/inch_test
/spec/import/csv_spec.rb
UTF-8
5,899
2.515625
3
[]
no_license
require 'rails_helper' describe Import::Csv, type: :csv do subject { Import::Csv.new(file_path: generated_csv.path) } after(:each) { File.delete(path) if File.exist?(path) } describe 'for buildings' do let(:path) { 'spec/import/buildings.csv' } let(:generated_csv) do CSV.open(path, 'wb') do |csv...
true
e7bc3f8ffb1cf41762db4ab00b6cb40c42e887d8
Ruby
johndewolf/piglatin_with_tdd
/app.rb
UTF-8
251
2.96875
3
[]
no_license
require './PigLatinTranslation' require './Word' require "pry" puts 'Please enter a phrase to be translated' phrase = gets.chomp phrase = PigLatinTranslation.new(phrase) phrase.split_array phrase.create_word_objects puts phrase.translated_words
true
ecf4273e6bce700f7fac5672380edec332df9874
Ruby
JordanStafford/Ruby
/PDP/Arrays /EX12.RB
UTF-8
270
3.796875
4
[]
no_license
#Write a Ruby program to create a new array with the elements in reverse order from a given an array of integers length def array_checking_function(numbers) reversed = numbers[2], numbers[1], numbers[0] return reversed end print array_checking_function([1, 5, 98])
true
1c5c6a04b76f796cb538053f04fbe381e4706c29
Ruby
fearoffish/rehabilitate
/lib/rehabilitate/plugins/scp.rb
UTF-8
1,151
2.703125
3
[]
no_license
require 'rehabilitate/plugin' require 'uri' require 'net/ssh' require 'net/scp' class Scp < Rehabilitate::Plugin def upload(options) location = parse_upload_string(options.location) remote_dir = "#{location[:dir]}/#{options._base_backup_name}" log "Connecting to #{location[:host]} with user: #{location[:...
true
992d8142e389d0982dd0d1add606f7c4bb5424ff
Ruby
BrentPalmer/Intro-to-Programming-Exercises
/loopsanditerators_exercises/exercise_4.rb
UTF-8
108
3.453125
3
[]
no_license
def countdown(num) if num <= 0 puts "Done!" else puts num countdown(num - 1) end end countdown(10)
true
aa38a6c3fbbf772f7b4e0e8f218cb7d5a24a6b73
Ruby
cheezenaan/procon
/atcoder/agc024/a.rb
UTF-8
126
3.0625
3
[]
no_license
a, b, c, k = gets.split.map(&:to_i) MAX = 10 ** 18 if (a - b).abs > MAX puts "Unfair" else puts (a - b) * (-1) ** k end
true
32e65fbf72aa865b29be2634fcbb1449a7b13740
Ruby
dnswann/ruby-challenges
/ruby_challenges/always_three3.rb
UTF-8
138
3.71875
4
[]
no_license
# use 3 lines and single variable puts "Give me a number" number_one = gets.to_i print (number_one + 5) * (2 - 4) / (2 - number_one) + 1
true
057b9c90b4fc36bb5af579fdfc396b4ac75df53c
Ruby
yous/acmicpc-net
/problem/1008/ruby-1.8.short.rb
UTF-8
90
2.71875
3
[]
no_license
# encoding: utf-8 a,b=gets.split;p a.to_f/b.to_f # a, b = gets.split # p a.to_f / b.to_f
true
3edd54f500d20f50f5ee51675764dee432aa1922
Ruby
heroku/legacy-cli
/lib/heroku/command/labs.rb
UTF-8
4,039
2.546875
3
[ "MIT" ]
permissive
require "heroku/command/base" # manage optional features # class Heroku::Command::Labs < Heroku::Command::Base # labs # # list experimental features # #Example: # # === User Features (david@heroku.com) # [+] dashboard Use Heroku Dashboard by default # # === App Features (glacial-retreat-5913) #...
true
7cffb1639db535ce271477b74d580b03cf540d4c
Ruby
lfriedrichs/ruby-oo-object-relationships-kickstarter-lab-seattle-web-012720
/lib/backer.rb
UTF-8
370
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Backer attr_accessor :name def initialize(name) @name = name end def back_project(project) ProjectBacker.new(project, self) end def backed_projects ProjectBacker.all.collect { |project_backer| project_backer.project if project_backer.backer == self ...
true
022d1227a4e6d71e238107a2473261cdf3d24984
Ruby
gonzalo-m/maze-solver
/maze.rb
UTF-8
13,824
3.484375
3
[]
no_license
#!/usr/local/bin/ruby #------------------------------------------------------------------------------ # Maze Solver #------------------------------------------------------------------------------ HEADER = 1 CELL = 2 PATH = 3 $simple_maze_format = "" $invalid_output = "" $invalid_maze = false def parse(file) # head...
true
f6ccd5e0f580e710888cfe58982a1532ef971c1d
Ruby
jsonreeder/aa-homeworks
/W1D5/stack.rb
UTF-8
449
3.296875
3
[]
no_license
class Stack def initialize @contents = [] end def add(el) @contents << el end def remove @contents.pop end def show p @contents end end def stack_tests puts "Initialize stack" stack = Stack.new puts "\nAdd 4 to stack" stack.add(4) stack.show puts "\nAdd q to stack" stac...
true
0a5e052c689486af75da68814896f10bf155d7bb
Ruby
SCCP2016/ruby_mid_answer
/8/8_2.rb
UTF-8
1,533
4.09375
4
[]
no_license
# 手続き型の解答。理解しにくい male = STDIN.gets.split female = STDIN.gets.split # あふれた分の人は結婚できないので、苗字を書き換える人を少ない方に合わせる n = (male.size > female.size) ? female.size : male.size # 文字がキャピタルかどうかを真偽値で返す関数 def is_upper?(ch) ('a'.ord <= ch.ord && ch.ord <= 'z'.ord) ? false : true end # 入力文字列を苗名に分割する関数 def split_name(name) # 名前の部...
true
abf1ddb2cb9c332308274fe93db711e7d469580a
Ruby
qaisjp/adventofcode
/2021/day09/main.rb
UTF-8
3,771
3.296875
3
[]
no_license
# frozen_string_literal: true # typed: true # AoC class AoC def initialize(data) @grid = data.map {_1.chars.map(&:to_i)} @row_size = @grid.first.size end def adjacents(y, x, coords: false, &blk) _coords = [ [y-1, x], [y+1, x], [y, x-1], [y, x+1], ] results = [] ...
true
3d11acff1960c84430099340e3351156989fcdd3
Ruby
pokrpokr/little_demo
/main.rb
UTF-8
2,297
2.71875
3
[]
no_license
require File.expand_path('../read_data', __FILE__) require File.expand_path('../query_data', __FILE__) require File.expand_path('../oa_get_binding', __FILE__) class Main def initialize(type) # type: [:FY, :JP, :JD, :DX] case type when :FY file_path = Config::FY_PATH new_file_path = Config::FY_NEW_PATH ...
true
653a93df5443404822ee83891aa2298e02f6ca36
Ruby
kevinfalank-devbootcamp/rspec_bank_drill
/account_spec.rb
UTF-8
2,773
3.0625
3
[]
no_license
require "rspec" require_relative "account" describe Account do let(:account) { Account.new("0123456789") } let(:invalid_account) { Account.new("0123456789", "BADINPUT") } describe "#initialize" do context "with valid input" do it "creates a new Account with the account number" do account.sho...
true
5dfd339cacab100449507aa272c519b43135169f
Ruby
User4574/Advent-of-Code-2019
/day01/part2
UTF-8
303
3.53125
4
[]
no_license
#!/usr/bin/env ruby def fuel_required(mass) fuel_queue = [mass] loop do new_fuel = (fuel_queue.last / 3) - 2 return (fuel_queue.sum - mass) if new_fuel <= 0 fuel_queue << new_fuel end end input = $stdin.readlines.map(&:strip).map(&:to_i) puts input.map{ |x| fuel_required(x) }.sum
true
5215f4f809d2ef0e6829c888fe5bafbfacfdfed9
Ruby
diaandco/oops
/lib/oops/tasks.rb
UTF-8
3,752
2.609375
3
[ "MIT" ]
permissive
require 'oops/opsworks_deploy' require 'aws-sdk-s3' require 'rake' module Oops class Tasks attr_accessor :prerequisites, :additional_paths, :includes, :excludes, :format def self.default_args { prerequisites: ['assets:clean', 'assets:precompile'], additional_paths: [], includes...
true
6193909f1de520e172986f7732f05c1814928dad
Ruby
toyokazu/jwk-tool
/bin/jwk_tool
UTF-8
1,889
2.71875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # -*- coding: utf-8 -*- require 'rubygems' unless defined?(gem) #here = File.dirname(__FILE__) #$LOAD_PATH << File.expand_path(File.join(here, '..', 'lib')) require 'json/jwt' require 'optparse' class JwkTool attr_accessor :options def output_usage_and_exit(parser = @parser) $stderr.puts p...
true
3dfbfce713bfc5dbc7f633288c91345b0645adfd
Ruby
suesunmi/tictactoe
/lib/game.rb
UTF-8
1,215
3.5625
4
[]
no_license
require 'board' require 'human_player' require 'unbeatable_player' module TicTacToe class Game def whats_next(preference, string_board, position) @board = TicTacToe::Board.new(string_board) if string_board == "_________" && preference == "2" player_a = TicTacToe::HumanPlayer.new("X", @board)...
true
1fa013b58a76ac890f5a791a6fd1b9d1ebcdbdcb
Ruby
mediagreenhouse/spontaneous
/lib/spontaneous/extensions/string.rb
UTF-8
1,115
2.78125
3
[ "MIT" ]
permissive
# encoding: UTF-8 module Spontaneous module Extensions module String def /(path) File.join(self, path.to_s) end def or(alternative) return alternative if empty? self end alias_method :'|', :or def value(format = :html) self end ...
true
1f336f79d0fffd0a2648cb61f744db81b059f20f
Ruby
jasmarc/kmeans
/lib/coordinate.rb
UTF-8
920
3.1875
3
[]
no_license
class Coordinate < Array attr_accessor :data, :cluster def Coordinate.centroid(coordinates) centroid = Coordinate.new(coordinates.first.size) { 0 } coordinates.each do |coordinate| centroid.add(coordinate) end centroid.map! { |x| x/coordinates.size.to_f } centroid.sphere! return cen...
true
3db8f68712d6ac6f6cedec85f5f8d9810c3b3a73
Ruby
wozwas/JP-Text-Adventure
/app/navigation.rb
UTF-8
360
3.671875
4
[]
no_license
def current_room(x,y) current_position = [x, y] if current_position[0] == 0 && current_position[1] == 0 puts "You're at the start, what direction do you go?" elsif current_position[0] == 1 && current_position[1] == 1 #add rooms following this convention else puts "You're in a dark hallway, where do...
true
b18a8d3caf53fbb7f82aff749c01893d7150c49c
Ruby
acareaga/module_one
/week1/super_fizz.rb
UTF-8
1,064
4.0625
4
[]
no_license
def is_divisible_by_seven?(input) input % 7 == 0 end def is_divisible_by_five?(input) input % 5 == 0 end def is_divisible_by_three?(input) input % 3 == 0 end (1..1000).each do |number| if is_divisible_by_three?(number) && is_divisible_by_five?(number) && is_divisible_by_seven?(number) print "SuperFizzBuz...
true
4d9c8a64aefcc95355dbd96962cb49616269e59a
Ruby
andreasbanelli/projet_exo_ruby
/04_pig_latin/pig_latin.rb
UTF-8
243
2.875
3
[]
no_license
#write your code here def pig_latin(word) if word =~ (/\A[aeiou]/i) word = word + 'ay' elsif word =~ (/\A[^aeiou]/i) match = /\A[^aeiou]/i.match(word) word = match.post_match + match.to_s + 'ay' end word end
true
db2ab5fef47d478d5bdc57305a4c82fe2a73171b
Ruby
bolthar/thunkgen
/lib/thunkgen.rb
UTF-8
446
2.984375
3
[]
no_license
require File.join(File.dirname(__FILE__), "printer.rb") require File.join(File.dirname(__FILE__), "paragraph_factory.rb") printer = Printer.new paragraph_factory = ParagraphFactory.new #paragraphs (rand(5) + 2).times do print printer.build_sentences(paragraph_factory.get_paragraph.get_phrases) print "\n\n" end ...
true
18542b45c9fbdcd03066937793c74eaeec347366
Ruby
shogo-08020318/awesome_events
/app/models/event.rb
UTF-8
1,709
2.625
3
[]
no_license
class Event < ApplicationRecord # event.rbの場合 # アソシエーション :関連付け名, class_name: クラス名 # eventモデルはuserモデルと「user」という関連付けの名前で紐づく # bolongs_to :user, class_name: 'User' # eventモデルはuserモデルと「owner」という関連付けの名前で紐づく belongs_to :owner, class_name: 'User' # こっちが子供、親のDNAを受け継いだファイル has_many :tickets, dependent: :destroy...
true