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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
523ae47ac1d4c2158eaf5b269809bbf0b00f1e19 | Ruby | samwize/fastlane | /fastlane_core/spec/fastlane_runner_spec.rb | UTF-8 | 1,510 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Commander::Runner do
describe '#handle_unknown_error' do
class CustomError < StandardError
def preferred_error_info
['Title', 'Line 1', 'Line 2']
end
end
class NilReturningError < StandardError
def preferred_error_info
nil
end
en... | true |
f9f4a376d6767055ce1ddd490ccfd47ca0004502 | Ruby | artsy/bearden | /app/models/slack_bot.rb | UTF-8 | 478 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class SlackBot
def self.post(message)
new(message).post
end
def initialize(message)
@message = message
end
def post
options = default_options.merge(text: @message)
client.chat_postMessage options
end
private
def client
@client ||= Slack::Web::Client.new
end
def channel
R... | true |
a03b3d69eac0f4c5c59579971488af2924dcbf7a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/allergies/4b6a24cf78264601ab31160fbcd8bc0e.rb | UTF-8 | 573 | 3.28125 | 3 | [] | no_license | class Allergies
attr_reader :score
LOOKUP = [["cats", 128], ["pollen", 64], ["chocolate", 32], ["tomatoes", 16],
["strawberries", 8], ["shellfish", 4], ["peanuts", 2], ["eggs", 1]]
def initialize(score)
@score = score
end
def allergic_to?(item)
list.include?(item)
end
def list
... | true |
c28e284a8b5580d4dc35805cb35fb176c8adfd12 | Ruby | asarialtun/sinatra_number_guess | /web_guesser.rb | UTF-8 | 740 | 3.265625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
number = rand(100)
#@guess = ""
@message = ""
get '/' do
@guess = params["guess"].to_i if params["guess"]
message = construct_message(@guess,number) if @guess
erb :index, :locals => {:number => number, :guess => @guess,:message => message}
end
def construct_messag... | true |
232b0e3f0d3b401b4d731896f0b8641ff141b4bb | Ruby | alexmgr/RunTracer | /ruby/iterative_reducer.rb | UTF-8 | 4,475 | 2.734375 | 3 | [] | no_license | # Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2010.
# License: The MIT License
# (See README.TXT or http://www.opensource.org/licenses/mit-license.php for details.)
require 'rubygems'
require 'beanstalk-client'
require 'msgpack'
require 'oklahoma_mixer'
# As traces come in, maintain an iteratively redu... | true |
ab77b5537c48c65e5b86922b46f7275fbb592c17 | Ruby | khnaero/odin_project | /learn_ruby/03_simon_says/simon_says.rb | UTF-8 | 448 | 4.0625 | 4 | [] | no_license | #write your code here
def echo(word)
"#{word}"
end
def shout(word)
"#{word.upcase}"
end
def repeat(word, num=2)
[word] * num * " "
end
def start_of_word(word, num)
word[0..(num - 1)]
end
def first_word(phrase)
phrase.split(' ')[0]
end
def titleize(title)
words = title.split.map do |word|
if %w(the ... | true |
d471fc25c8aedc6e731a216cb3b0725cb6b72d49 | Ruby | jaesypg/ar-student-schema | /app/models/student.rb | UTF-8 | 320 | 2.890625 | 3 | [] | no_license | require_relative '../../db/config'
class Student < ActiveRecord::Base
# implement your Student model here
def name
"#{self.first_name} #{self.last_name}"
end
def age
now = Time.now.utc.to_date
now.year - self.birthday.year - (self.birthday.to_date.change(:year => now.year) > now ? 1 : 0)
end
end | true |
68a1dc07d256f5ddcfa3996763392c522e7261fc | Ruby | nikhgupta/handlisted | /app/models/merit/badge_rules.rb | UTF-8 | 1,638 | 2.796875 | 3 | [] | no_license | # Be sure to restart your server when you modify this file.
#
# +grant_on+ accepts:
# * Nothing (always grants)
# * A block which evaluates to boolean (recieves the object as parameter)
# * A block with a hash composed of methods to run on the target object with
# expected values (+votes: 5+ for instance).
#
# +grant... | true |
badf8ed7e53912daae3b32ae14c277b3fbab942e | Ruby | aemrich/ttt-6-position-taken-rb-q-000 | /lib/position_taken.rb | UTF-8 | 317 | 3.65625 | 4 | [] | no_license | # code your #position_taken? method here!
def position_taken?(board, position)
if board[position] == " "
then false
elsif board[position] == ""
then false
elsif board[position] == nil
then false
elsif board[position] == "X"
then true
elsif board[position] == "O"
then true
end
end | true |
668c1b77df34852aa3dcd98a2e001b0d7e87add6 | Ruby | ewoutquax/weatherapp | /lib/adafruit/sensor_reader.rb | UTF-8 | 443 | 2.515625 | 3 | [] | no_license | module Adafruit
module SensorReader
def self.invoke
reading_temperature_pressure = `/srv/python/Adafruit_Python_BMP/api.py`.split("\n")
reading_temperature_humidity = `/srv/python/Adafruit_Python_DHT/examples/api.py`.split("\n")
{
temperature: reading_temperature_pressure[0],
pr... | true |
d2a6cde4e7558ccbfc4bf7875ad8a9df3c71ce21 | Ruby | benjlcox/drug_wars | /lib/api/city.rb | UTF-8 | 221 | 3.09375 | 3 | [] | no_license | class City
attr_reader :name
attr_accessor :drugs
def initialize(name, drugs)
@name = name
@drugs = drugs
end
def new_day
@drugs.each_pair do |name, drug|
drug.change_price
end
end
end
| true |
5079f35aa54f6bcd925db975a94ca6cc2dd4be33 | Ruby | empressofflowers/my-each-onl01-seng-ft-041320 | /my_each.rb | UTF-8 | 204 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
#fruit_basket = ["mango", "peach", "orange", "apple"]
def my_each(array)
n = 0
while n < array.length
yield (array[n])
n = n + 1
end
array
end
#my_each(array)
| true |
2a4cf3ba629f5398cbd8f0bb52d8a9be13fe8a00 | Ruby | jobitoalv/Terminal_App | /Classes/confirmation.rb | UTF-8 | 1,479 | 3.53125 | 4 | [] | no_license | require_relative 'dog'
require_relative '../classes/method/header'
class Booking
attr_reader :booking, :service, :date, :add_on
def initialize(booking, service, date, add_on=nil)
@service = service
@date = date
@add_on = add_on
@booking = booking
end
def display_book... | true |
6cdf1cdd02d617f9e4ae348982b12672bdcc8c4d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/dcc34914e4f645209f5bb24bbfe6abca.rb | UTF-8 | 1,232 | 3.484375 | 3 | [] | no_license | class Complement
def self.of_dna(dna_strand)
DNAStrand.new(dna_strand).rna_complement
end
def self.of_rna(rna_strand)
RNAStrand.new(rna_strand).dna_complement
end
end
class DNAStrand
attr_reader :strand
def initialize(strand)
@strand = strand
end
def rna_complement
strand.split(//).... | true |
1b0c55fb0cbd30bfe2efc80833b9943650bb7d21 | Ruby | engineyard/fragrant | /lib/fragrant/address_manager.rb | UTF-8 | 2,198 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'ipaddr'
require 'json'
module Fragrant
AddressRangeExhausted = Class.new(StandardError)
class AddressManager
attr_accessor :data_location, :allocated_addresses
attr_accessor :address_range, :address_map
def initialize(data_location, address_range)
self.data_location = data_location
... | true |
a5d1ad9347972709c93d3c9a463da34fbf2ee82f | Ruby | ari-skyler/badges-and-schedules-onl01-seng-ft-050420 | /conference_badges.rb | UTF-8 | 424 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def batch_badge_creator(names)
names.collect do |name|
"Hello, my name is #{name}."
end
end
def badge_maker(name)
"Hello, my name is #{name}."
end
def assign_rooms(names)
room = 0
names.collect do |name|
room+=1
"Hello, #{name}! You'll be assigned to room #{room}!"
end
end
def printer(names)
... | true |
a9e0e2b835452326e47c25d639dfe1a15f6dbcea | Ruby | fmlharrison/learn_to_program | /ch14-blocks-and-procs/even_better_profiling.rb | UTF-8 | 406 | 3.34375 | 3 | [] | no_license | def profile block_description, &block
#this method take a code a sees how long it takes to run.. in seconds
#the block_description is the name of the code
#&block is the code's block truned into a proc.
profiling = true
if profiling
start_time = Time.new
block.call
duration = Time.new - start_time... | true |
2e82c5f8466e308bb0e29764f21ea36f92e3783a | Ruby | enukane/Solution-for-PE | /SOLVED/prob17.rb | UTF-8 | 1,800 | 3.859375 | 4 | [] | no_license | $num_to_word = {
0 => "and",
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
9 => "nine",
10=> "ten",
11=> "eleven",
12=> "twelve",
13=> "thirteen",
14=> "fourteen",
15=> "fifteen",
16=> "sixteen",
17=> "seventeen",
18=> "eigh... | true |
039a553b3570e9d7462645f4c24d9a1793121a59 | Ruby | mandarandriam/ruby-vendredi | /exo_10.rb | UTF-8 | 187 | 3.390625 | 3 | [] | no_license | print "Peut-on avoir votre date de naissance s'il vous plaît? "
date_de_naissance = gets.chomp.to_i
operation = 2017 - date_de_naissance
puts "Votre âge, en 2017 est de #{operation}"
| true |
e05d41eb5ddd58113f61f54807afa03cecb18d6c | Ruby | Vutienbka/Ruby | /DoWhile.rb | UTF-8 | 54 | 3.09375 | 3 | [] | no_license | a = 10
loop do
puts a
a -= 1
break if a < 0
end
| true |
ba7e7d11116de0c5ba1dd57fdb17f66c4b103d45 | Ruby | alu0100003956/LPP_T_36_p4 | /lib/complejos.rb | UTF-8 | 1,079 | 3.46875 | 3 | [] | no_license | #! usr/bin/ruby
#definición de una clase complejos para trabajar con numeros complejos
class Complejos
attr_reader :real, :imaginaria
def initialize(real, imaginaria)
@real,@imaginaria = real, imaginaria
end
def to_s
"#{@real}+#{@imaginaria}i"
end
def +(other)
if (other.is_a? Complejos)
Complejos.new(@... | true |
ded2dfcefb9f602c7957d7d015f93898c50a53ae | Ruby | nuiver/help-for-hire | /db/seeds.rb | UTF-8 | 4,561 | 2.53125 | 3 | [] | no_license | lawn_mowing = Task.create ( { name: "Lawn Mowing", category: "Gardening" } )
hedge_trimming = Task.create ( { name: "Hedge Trimming", category: "Gardening" } )
fertilizing = Task.create ( { name: "Fertilizing", category: "Gardening" } )
weeding = Task.create ( { name: "W... | true |
dc75f10c07bf21685943cbaa2ddd37860c1bec4d | Ruby | nayow/tests-ruby | /lib/03_basics.rb | UTF-8 | 671 | 3.4375 | 3 | [] | no_license | def who_is_bigger(a,b,c)
hash = {'a': a, 'b': b, 'c': c}
if a && b && c then return "#{hash.key(hash.values.max)} is bigger"
else return "nil detected"
end
end
def reverse_upcase_noLTA(str)
return str.gsub(/[lta]/i,'').reverse.upcase
end
def array_42(arr)
arr.each {|x| if x==42 then return tru... | true |
b0b01475eec825ed25d691cdc25cdb12c75df434 | Ruby | Byronlee/SalesTax | /lib/salestax/basket_item.rb | UTF-8 | 227 | 2.640625 | 3 | [
"MIT"
] | permissive | module Salestax
class BasketItem
include RateCalculable
attr_accessor :goods, :amount, :price
def initialize(goods, amount=1, price)
@goods, @amount, @price = goods, amount, price
end
end
end
| true |
6917c6fd2faaf032af93c92b9ecb2a8239174116 | Ruby | standardgalactic/slideshow | /slideshow-models/attic/markup/mediawiki.rb | UTF-8 | 1,178 | 2.609375 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | # encoding: utf-8
module Slideshow
module MediawikiEngines
def setup_mediawiki_engine
return if @mediawiki_engine_setup
logger.debug 'require wikicloth -- load mediawiki library'
require 'wikicloth' # default mediawiki library
@mediawiki_engine_setup = true
rescue LoadError... | true |
c6f916fc4ed6f693489def30707b52d72dc9e35b | Ruby | afiore/tripleloop | /spec/tripleloop/util_spec.rb | UTF-8 | 3,009 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Tripleloop::Util do
subject { Tripleloop::Util }
describe ".with_nested_fetch" do
context "when supplied argument is an array" do
it "extends it with the NestedFetch module" do
subject.with_nested_fetch({}).should respond_to(:get_in)
end
end
context ... | true |
98d20c0d82aea87adae298c798277b4f0a263191 | Ruby | aczid/ruby_patterns | /behavioral/memento.rb | UTF-8 | 887 | 3.765625 | 4 | [] | no_license | #!/usr/bin/ruby
# This example demonstrates the memento pattern in the Ruby language.
class Originator
def initialize
@state = self.inspect
end
def set_memento(memento)
@state = memento.get_state
end
def create_memento
return Memento.new(@state)
end
end
class Memento
def initialize(... | true |
b501832ba37e1f590efcf392bafe58c76b391e1c | Ruby | vikas-reddy/misc-code | /Azri/submissions/Chakrapani_Week2_assignments/chatserver.rb | UTF-8 | 2,104 | 3.21875 | 3 | [] | no_license | require 'socket'
### Changeable variables ###
port = 6789
count_history = 30 # Number of messages to store in history & print
### --------------------###
#### Arrays to maintain connection/user/thread Details and Last 30 messages ####
client_connections = []
client_threads = {}
past_history = []
### Starting a Serv... | true |
272a4aa5352a110890ef1d84231976c7d7d6545c | Ruby | sabtain93/rb_101_small_problems | /debugging/08.rb | UTF-8 | 1,683 | 3.890625 | 4 | [] | no_license | =begin
The given code prompts the user to set their own password, and then prompts
them to log in with that password, but throws an error.
The problem here is that we try to access the local variable `password` from
within the `set_password` method without passing it in as an argument. The
method has it's own discreet... | true |
a30e85900777e7a2fee3dd21281e74a7aae614d8 | Ruby | garethlatwork/quickbase_client_extras | /examples/cookbookfiles/recordAndFieldIterator.rb | UTF-8 | 647 | 2.6875 | 3 | [] | no_license |
require 'QuickBaseClient'
# change "username" "password" to your QuickBase username and password
qbc = QuickBase::Client.new("username","password")
qbc.doQuery("6ewwzuuj")
puts "\n --- QuickBase Formula Functions Reference ---\n\n"
recordNumber = 1
qbc.eachRecord(qbc.records){|record|
puts "\n --- ... | true |
fb1e4b7fb12906861ea7c583add483db76921257 | Ruby | EliseP08/ruby | /exo_09.rb | UTF-8 | 177 | 3.328125 | 3 | [] | no_license | puts "Quel est votre prénom ?"
user_firstname = gets.chomp
puts "Merci, quel est votre nom ?"
user_lastname = gets.chomp
puts "Bonjour, #{user_firstname} #{user_lastname} " | true |
625652fbf49cac3668b8d782944e2b36bfe2e6c5 | Ruby | aklives/collections_practice_vol_2-dumbo-web-career-040119 | /collections_practice.rb | UTF-8 | 1,218 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def begins_with_r tools
value = true
tools.each do |t|
if t.scan(/\w/)[0] != "r"
value = false
end
end
value
end
def contain_a tools
arr = []
tools.each do |t|
for i in 0..tools.length-1
if t.scan(/\w/)[i] == 'a'
arr << t
end
end
end
arr
end
def first_wa tools
t... | true |
be9b6371c44c21fba5361a74bc29b5f6e69f5ae9 | Ruby | Kmbsamaurice/odin-project-basic-ruby-projects | /caeser-cipher/spec/caeser-cipher-spec.rb | UTF-8 | 714 | 3.390625 | 3 | [] | no_license | require "../lib/caeser-cipher.rb"
describe "#caeser-cipher" do
it "shifts letters 3 places to the right" do
expect(caeser_cipher("def", 3)).to eql("ghi")
end
it "shifts letters 3 places to the left" do
expect(caeser_cipher("def", -3)).to eql("abc")
end
it "wraps around the letter ... | true |
8ebb7a2722a161b6f3ff835c3efcaffd19dd4be0 | Ruby | TakahiroSuzukiqq/CFA-weather-challenge | /weather-challenge.rb | UTF-8 | 1,965 | 3.765625 | 4 | [] | no_license | #####################################################
require "terminal-table"
require "paint"
#####################################################
class Question
def initialize(question)
@question = question
@days = ["Monday", "Tuesday", "Wednesday", "Tursday", "Friday", "Saturday", "Sunday"]
end
attr_acc... | true |
db7b1f075c3605310614db37f0b0e19dc526ccd3 | Ruby | GillianShanks/ecosystem_classes | /River.rb | UTF-8 | 349 | 3.546875 | 4 | [] | no_license | class River
attr_reader :name
def initialize(name, fish)
@name = name
@fish = fish #array
end
def fish_count()
return @fish.count()
end
# def add_fish(fish)
# @fish << fish
# end
def lose_fish(fish)
@fish.delete(fish)
end
def bear_hunts(bear, fish)
bear.eats_fish(fish)
... | true |
c359c7a939bbdcab48ddb7caecdca8af1c1b1706 | Ruby | rocket-coverall/100075 | /GamePacket.rb | UTF-8 | 1,513 | 3.484375 | 3 | [] | no_license | class GamePacket # class for outgoing game packets
def initialize param = {}
@type = param[:type]
@body = ""
end
def type
@type
end
def add_utf8 param
@body += [param.length].pack('n')+param
end
def add_long param
@body += [param].pack('N')
end
def add_byte param
@body +=... | true |
58d159114e41ae5913943c7fa795fa573533639a | Ruby | sannidhigowda/sannidhi | /backend/Ruby/animal2.rb | UTF-8 | 285 | 3.0625 | 3 | [] | no_license | class Animal
def dog_sound
puts"whoff-whoff"
end
def lion_sound
puts"roar"
end
def elephant_sound
puts"triuph"
end
def rabbbit_sound
puts"squeaks"
end
end
class Amphibians < Animal
end
dog=Amphibians.new
puts dog.dog_sound
puts dog.lion_sound
putsdog.elephant_sound
| true |
25b03e6a3801c1b4e1df6183f9eaa7cfb322828b | Ruby | croelanjr/Ruby-UPC2014-Unidad05 | /juegos_bolivarianos.rb | UTF-8 | 3,723 | 3.40625 | 3 | [] | no_license | =begin
A raíz de los recientes juegos Bolivarianos en nuestro país, se necesita implementar una aplicación
de software que ayude a los organizadores a realizar algunas tareas importantes. Para ello se le ha
solicitado lo siguiente:
a) Desarrollar un subprograma que determine el país que obtuvo mayor cantidad de meda... | true |
1e96920a333a070a8c29057d70b6f21a3e121de7 | Ruby | eeeli24/building_blocks | /stock_picker.rb | UTF-8 | 562 | 3.28125 | 3 | [] | no_license | def stock_picker prices
best_days = []
best_value = 0
days_indexes = []
prices.each do |first_day|
first_day_index = prices.index(first_day)
range = prices[first_day_index..-1]
range.each do |second_day|
if second_day - first_day > best_value
best_value = second_day - first_day
... | true |
a059d070205572c1afe7a87b9367874d420d15ed | Ruby | ksandy95/contributions | /iteration_3.rb | UTF-8 | 2,848 | 2.921875 | 3 | [] | no_license | require 'pry'
require 'csv'
class GameTeam
attr_reader :game_id,
:team_id,
:hoa,
:won,
:settled_in,
:head_coach,
:goals,
:shots,
:hits,
:pim,
:pp_opportunities,
:p... | true |
b829e06c61ee755e8bc9c732f2ec212697262854 | Ruby | mkrogemann/poller-json | /lib/matchers/json/json_path_has_value.rb | UTF-8 | 363 | 2.578125 | 3 | [
"MIT"
] | permissive | module Matchers
module JSON
class JSONPathHasValue
include JSONPath
def initialize(json_path, json_value)
@json_path = json_path
@json_value = json_value
end
def matches?(document_s)
json_hash = ::JSON.parse(document_s)
value_on_path(json_hash, @json_path)... | true |
13898cf3385275da8b80acfa6b99c57845079be0 | Ruby | auranet/asapccf | /lib/asap/utility/date_time_formatter.rb | UTF-8 | 526 | 2.875 | 3 | [] | no_license | require 'date'
module ASAP
module Utility
class DateTimeFormatter
def self.in_words(date_time)
self.in_words_without_year(date_time) + ', ' + date_time.year.to_s
end
def self.in_words_without_year(date_time)
TimeFormatter.standard(date_time) + ' on ' + DateFormatt... | true |
26a6ae7d089e182281eff4a1a3e5a210b02be41d | Ruby | mazamachi/hatenastar_tweet | /tweet.rb | UTF-8 | 2,266 | 2.953125 | 3 | [] | no_license | require 'rubygems'
require 'twitter'
require 'bitly'
load("./hotentry_star.rb")
class Tweet
attr_accessor :tweets
def initialize
@cli = Twitter::REST::Client.new do |config|
config.consumer_key = '******************************'
config.consumer_secret = '******************************'
... | true |
07912aa1bb00c1e20f103e91fea1a4d7441a47ac | Ruby | htekayadi/toy_robot_simulator | /lib/toyrobot/robot.rb | UTF-8 | 596 | 3.203125 | 3 | [] | no_license | module ToyRobot
# Robot's state class
class Robot
include ToyRobot::Logging
attr_accessor :position, :placed
def initialize
@position = nil
@placed = false
end
def place(x, y, face)
@position = Position.new(x, y, Direction.find(face))
@placed = true
end
def ... | true |
771aa0a397f62f4dfa8c01990f95425f2308ea80 | Ruby | bugsnag/bugsnag-ruby | /spec/utility/circular_buffer_spec.rb | UTF-8 | 2,211 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
require 'spec_helper'
require 'bugsnag/utility/circular_buffer'
RSpec.describe Bugsnag::Utility::CircularBuffer do
describe "#initialize" do
it "contains no items" do
buffer = Bugsnag::Utility::CircularBuffer.new
expect(buffer.to_a).to eq([])
end
end
describe "#max_items"... | true |
eb9e2c88cb0fe520162bdf24202a5b6d914d7d06 | Ruby | zk-ruby/zookeeper | /cause-abort.rb | UTF-8 | 2,541 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'zookeeper'
require File.expand_path('../spec/support/zookeeper_spec_helpers', __FILE__)
class CauseAbort
include Zookeeper::Logger
include Zookeeper::SpecHelpers
attr_reader :path, :pids_root, :data
def initialize
@path = "/_zktest_"
@pids_root = "#{@path}/pids"
@dat... | true |
0d3a82460fccc961d273422feed5954ba18d216b | Ruby | msoanes/project_euler | /02_even_fibonacci_numbers.rb | UTF-8 | 516 | 3.5625 | 4 | [] | no_license | def even_fibonacci_sum(maximum)
running_total = 2
latest_fibonacci_numbers = [1, 2]
loop do
3.times do
latest_fibonacci_numbers = next_fibonacci_pair(latest_fibonacci_numbers)
end
if latest_fibonacci_numbers.last > maximum
break
end
running_total += latest_fibonacci_numbers.last
... | true |
fb75f3daeae7d883c769a44d7177ed56be526e04 | Ruby | kaneki-ken01/playground | /solutions/uri/1007/1007.rb | UTF-8 | 102 | 2.578125 | 3 | [
"MIT"
] | permissive | a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
puts "DIFERENCA = #{'%d' % (a * b - c * d)}"
| true |
fd3934073b6c7857f8a21ceba7ccb6382541f525 | Ruby | evanrinehart/furry-dubstep | /acid.rb | UTF-8 | 3,078 | 2.84375 | 3 | [] | no_license | require 'json'
require 'fileutils'
class Acid
class LoaderError < StandardError; end
def initialize log_path, &block
@methods = {}
@read = lambda{|x| x}
@show = lambda{|x| x}
@init = lambda{ nil }
@log_path = log_path
self.instance_eval &block
begin
@state = load_log @log_path... | true |
c84eeb24cc06a40a71983c93eaa65ed86b0454a3 | Ruby | baccigalupi/aqua | /lib/aqua/store/couch_db/attachments.rb | UTF-8 | 7,311 | 2.71875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Aqua
module Store
module CouchDB
# Attachments is a Hash-like container with keys that are attacment names and values that are file-type
# objects. Initializing and adding to the collection assures the types of both keys and values. The
# collection implements a lazy-loading scheme, suc... | true |
c64f2c07d4a12d08049b63dea62684674390fc9c | Ruby | anwarmamat/cmsc330 | /ruby/Ruby_Lecture_4/my_collect.rb | UTF-8 | 165 | 3.546875 | 4 | [] | no_license | def my_collect(a)
b = Array.new(a.length)
0.upto(a.length-1) { |i|
b[i] = yield(a[i])
}
return b
end
b = my_collect([5, 6, 7]) { |x| x*2 }
puts b.inspect | true |
f12d2c64f961b8aa15e76151877db9ceb78d629c | Ruby | romigos/2021_RUBY_RUSH | /34_step_method.rb | UTF-8 | 181 | 3.25 | 3 | [] | no_license | puts 'I am a string'
array = ['James Bond', 'Brad Pitt', 'Dr. Who', 'House MD', 'Madonna']
puts array.to_s
array.pop
puts array.to_s
array.pop 2
puts array.to_s
time = Time.now
puts time | true |
75b1fa7b6378fa6885f1e79e8b47bbed5db4d100 | Ruby | aldhsu/algorithms | /second_lowest_number.rb | UTF-8 | 1,271 | 3.890625 | 4 | [] | no_license | class SecondLowestNumber
attr_accessor :digits, :break_point, :swap_index
# #1. Find highest index swap
# #2. Find lowest number at index
def initialize(integer)
@digits = integer.to_s
@break_point = -1 # where to stop looking and where to swap
@swap_index = nil # where to swap from
end
def f... | true |
6add69252fa1e56cf804fb27d24fe2a71ff75155 | Ruby | Srossmanreich/phase-0 | /week-9/ruby-review-3/r-r.rb | UTF-8 | 1,421 | 3.984375 | 4 | [
"MIT"
] | permissive | # OO Basics: Student
# I worked on this challenge [by myself, with: ].
# This challenge took me [#] hours.
# Pseudocode
# Initial Solution
students = {}
class Student
attr_accessor :scores, :first_name
def initialize(first_name,scores) #Use named arguments!
@first_name = first_name
@scores = score... | true |
d19503c3b80e644b1053c2added8f5ed329af067 | Ruby | akash121kumar/Training | /Ruby/hashes_method.rb | UTF-8 | 2,142 | 4.0625 | 4 | [] | no_license | # grades = {'akash'=> 10, 'vikas' => 7}
# puts grades['akash']
# grades = Hash.new
# print grades.class
# grades["vijay"]= 10
# print grades
# grades.each{|key,values| puts "key is #{key} and value is #{values}"}
# books = {}
# books[:matz] = "The ruby language"
# books[:black] = "The well grounded Rubyist"
# print bo... | true |
4919b864e48eed2eda8e6c681d96526e318fecd6 | Ruby | lbernal713/MIS4397-LuisBernal | /Assignments/Learn Ruby the Hard Way/ex.4.rb | UTF-8 | 675 | 3.40625 | 3 | [] | no_license | cars = 100 # initialize
space_in_a_car = 4.0 # initialize
drivers = 30 # initialize
passengers = 90 # initialize
cars_not_driven = cars - drivers # cars not being used
cars_driven = drivers # cars that will be driven
carpool_capacity = cars_driven * space_in_a_car # capacity
average_passengers_per_car = passengers / c... | true |
91ec27cfa9762a8898e63662d7a7493cc8860147 | Ruby | 4rlm/dbc_onsite | /2.1_public-vs-private-interfaces/spec/bank_account_spec.rb | UTF-8 | 1,043 | 2.90625 | 3 | [] | no_license | require_relative '../bank_account'
describe BankAccount do
let(:account) { BankAccount.new("bob", "Checking", 333666999) }
it "has a readable account_number" do
expect(account.account_number).to eq("######999")
end
it "has a readable customer_name" do
expect(account.customer_name).to eq("BOB")
end
... | true |
9101b4a443b0c7e591c5d1eca587a8d958a0b099 | Ruby | andibachmann/ad_dir | /lib/ad_dir/group.rb | UTF-8 | 4,046 | 2.828125 | 3 | [
"MIT"
] | permissive | module AdDir
# **`AdDir::Group`** models a 'Group' entry in an Active Directory.
#
# For basic CRUD operations see {AdDir::Entry}. In additon to these
# {AdDir::Group} offers methods to list and managed {AdDir::User}
# relationships.
#
# ## List users belonging to a group
#
# * **`members`** list of m... | true |
9f98f2e3d2ba97780d3cdccef8b7480a57a7e20f | Ruby | afleisch/study_hall | /introduction.rb | UTF-8 | 411 | 3.046875 | 3 | [] | no_license |
#Saving my friend's name
puts "Hello, what's your name?"
name = gets.chomp
#Saving number of completed assignments
puts "How many prework assignments have you completed?"
assignments = gets.chomp
puts "Hello #{name}. My name is Ashley."
puts "I see you've completed #{assignments}. I have completed all of them." ... | true |
54725e68878c1a55998027bb5dfa1dc800baa4c5 | Ruby | singram/euler | /problem28/problem28.rb | UTF-8 | 607 | 4.03125 | 4 | [
"MIT"
] | permissive | # Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:
# 21 22 23 24 25
# 20 7 8 9 10
# 19 6 1 2 11
# 18 5 4 3 12
# 17 16 15 14 13
# It can be verified that the sum of the numbers on the diagonals is 101.
# What is the sum of the numbers on the ... | true |
dcf32d10afe9bd8c3a694d2f57b091bcb0a16dcd | Ruby | dguptaruby/JungleCodersDemo | /lib/v_card_handler.rb | UTF-8 | 1,525 | 2.578125 | 3 | [] | no_license | require 'multiple_vcard'
# Add new module for Vcard
module VCardHandler
def self.include(klass)
klass.extend ClassMethods
klass.send(:include, InstanceMethods)
end
# Add module for instance methods
module InstanceMethods
def v_card_multiple(contacts)
card = Vpim::Vcard::Maker.make2 do |maker|
... | true |
08efaf15a4732f8b969833c557d0f11369bad95c | Ruby | googleapis/google-cloud-ruby | /google-cloud-bigtable/lib/google/cloud/bigtable/value_range.rb | UTF-8 | 7,548 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | true |
965f355d0c58d6debff4c3807ac69609a1ed39d5 | Ruby | tommylees112/match-market | /lib/tasks/odds.rake | UTF-8 | 653 | 2.640625 | 3 | [] | no_license | namespace :odds do
task seed: :environment do
OUTCOME = ["Home", "Away", "Draw"]
tommy = User.find(1) #_by_email("thomas.lees@chch.ox.ac.uk")
hamish = User.find(3) #_by_email("hachall@hotmail.com")
adrian = User.find(2) #_by_email("walkerrrrrrr@gmail.com")
USER = [tommy, hamish, adrian]
def g... | true |
87d3f2722b88bfa88ac737df166fef025e81892f | Ruby | justinw827/oo-cash-register-nyc-web-080618 | /lib/cash_register.rb | UTF-8 | 734 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class CashRegister
attr_accessor :total, :discount, :title
def initialize(discountIn = 0.0)
@total = 0.0
@discount = discountIn
@itemList = []
@priceList = []
end
def add_item(titleIn, priceIn, quantityIn=1)
for i in 1..quantityIn
@total += priceIn
@itemList.push... | true |
8786ebfd47f91c7447906ad5c5795354714f52dd | Ruby | hildebrandosegundo/cursoruby | /herança.rb | UTF-8 | 175 | 2.71875 | 3 | [] | no_license | class Pessoa
attr_accessor :nome
private
def telefone
end
end
class PessoaFisica < Pessoa
attr_accessor :cpf
end
pessoa = PessoaFisica.new
puts pessoa.nome = "hilde"
| true |
74b6e3ac3ac3d66ca2b90a24acdef6db0db9282a | Ruby | johnhattori/shelter_w_classes | /main.rb | UTF-8 | 2,004 | 3.625 | 4 | [] | no_license | require "pry"
require_relative "shelter"
require_relative "pet"
require_relative "client"
shelter = nil
s1 = Shelter.new("414 Brannan St.", {}, {})
c1 = Client.new("John", "m", 49)
c2 = Client.new("Guy", "m", 25)
c3 = Client.new("Sumeet", "m", 28)
c4 = Client.new("Connie", "f", 21)
p1 = Pet.new("Tomale", "cat", "m",... | true |
6cbb2d2d36a28bff07af7eb4778d00e09ae41ced | Ruby | dev-asadhameed/Salesloft-API-Integration | /app/services/string_matcher.rb | UTF-8 | 912 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
require 'fuzzystringmatch'
class StringMatcher
attr_reader :records, :errors, :matching_strings, :fuzzy_string_matcher
def initialize(records)
@records = records
@errors = []
@matching_strings = {}
@fuzzy_string_matcher = FuzzyStringMatch::JaroWinkler.create(:pure)
... | true |
d312f7e2628e9e2a43c635bf526b5330666f26c9 | Ruby | ogawatti/hiddeste | /app/models/event.rb | UTF-8 | 949 | 2.546875 | 3 | [] | no_license | class Event < ActiveRecord::Base
attr_accessible :date, :description, :name, :organizer_id, :place
has_many :user_events, :dependent => :destroy
has_many :users, :through => :user_events
has_many :notices, :order => 'created_at DESC', :dependent => :destroy
validates :name, :presence => true, :length => {:m... | true |
96f384e27e947dd6bd58ad665a59a4a13c269e46 | Ruby | europ/lunch | /lunch/app/controllers/restaurants/RestauraceAPizzerieNaPlace.rb | UTF-8 | 484 | 2.828125 | 3 | [] | no_license | require 'nokogiri'
require 'restclient'
class RestauraceAPizzerieNaPlace
def initialize
@url = 'https://www.pizzerienaplace.cz/denni-menu/'
@css_selector = '.widget-body'
end
def load
{
id: self.class.to_s,
name: 'Restaurace a Pizzerie Na Place',
url: @url,
content: parse(sc... | true |
2605e6d028f5d4ca77151839807abddb215ea4ef | Ruby | kasia-kaleta/project_1_shop_inventory_app | /models/brands.rb | UTF-8 | 1,184 | 3.203125 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Brand
attr_reader :id
attr_accessor :name, :info, :img
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@info = options['info']
@img = options['img']
end
def save()
sql = "INSERT INTO brands (name, inf... | true |
a81af3b4e9f80471022ad91588fa683906f44238 | Ruby | jake-007/rxruby | /test/rx/concurrency/test_scheduled_item.rb | UTF-8 | 1,167 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
require 'test_helper'
class DummyScheduler
end
class TestScheduledItem < Minitest::Test
def setup
@state = []
@item = Rx::ScheduledItem.new(DummyScheduler.new, @state, 5) do... | true |
58fb1b9d7543834a7f049508df00164a506b5e68 | Ruby | fdreith/square_array | /square_array.rb | UTF-8 | 182 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each {|x| new_array << x ** 2}
new_array
end
# don't use any built-in array methods other than
# .each (e.g. .collect, .inject). | true |
9de157a516d8a433d04c54ec1c570fc24578d920 | Ruby | dfl/open_flash_chart | /lib/open_flash_chart/pie.rb | UTF-8 | 663 | 2.59375 | 3 | [
"MIT"
] | permissive | module OpenFlashChart
class PieValue < Base
def initialize(value, label, args={})
@value = value
@label = label
super args
end
def set_label(label, label_color, font_size)
self.label = label
self.label_colour = label_color
self.font_size = font_size
end
... | true |
b8683a3fb105629809a29adbd19477ec9c194bc3 | Ruby | kjjgibson/Morokufy | /lib/hip_chat/room_notification.rb | UTF-8 | 1,956 | 2.671875 | 3 | [] | no_license | module HipChat
class RoomNotification
include ActiveModel::Validations
include ActiveModel::Serialization
# Valid values for the 'color' attribute
module Color
YELLOW = 'yellow'
GREEN = 'green'
RED = 'red'
PURPLE = 'purple'
GRAY = 'gray'
RANDOM = 'random'
end
... | true |
f483dda605622b72fdd0879fb1e3f673ba06ab2e | Ruby | terut/goodluck | /app/notifier.rb | UTF-8 | 3,753 | 3 | 3 | [
"MIT"
] | permissive | require 'hipchat'
require 'faraday'
module Goodluck
class Notifier
attr_accessor :repo, :url, :environment
def self.build(repo, url, environment)
case ENV["NOTIFIER"]
when "slack"
SlackNotifier.new(repo, url, environment)
when "hipchat"
HipChatNotifier.new(repo, url, enviro... | true |
fccc8f3b13e4dea5ed183ac764bbf0744445a635 | Ruby | gkarolyi/what-the-hell | /app/services/tmdb.rb | UTF-8 | 2,461 | 2.703125 | 3 | [] | no_license | require "open-uri"
require "benchmark"
class Tmdb
class << self
def top_actors(movie_id, top_n = 4)
movie_cast(movie_id).sort { |b, a| a["popularity"] - b["popularity"] }
.first(top_n)
end
def movie_details(movie_id)
details = read_and_parse(movie_url(movie_id))
... | true |
0a392bff10aee76b94a30a4b55d5303dde9e69d1 | Ruby | thatkahunaguy/sample_app | /app/models/user.rb | UTF-8 | 2,189 | 2.828125 | 3 | [] | no_license | class User < ActiveRecord::Base
# dependent destroy below ensures if the user is destroyed so are the microposts
has_many :microposts, dependent: :destroy
# validate presence of name - note the code below is the same as
# validates(:name, {presence: true}) - parens optional and {} opt on hash last arg
validates... | true |
498f6bac16653c63c327b6384c448c5601edb64d | Ruby | tgxworld/coursemology2 | /spec/libraries/time_bounded_spec.rb | UTF-8 | 3,011 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
RSpec.describe 'time_bounded', type: :model do
class TimeBoundedTest < ActiveRecord::Base
end
temporary_table(:time_bounded_tests) do |t|
t.time_bounded
end
with_temporary_table(:time_bounded_tests) do
before(:context) do
[
[nil, nil],
[nil, 1.day],
... | true |
9e0460d8221957628d5c3cb7493dbed429b2a33b | Ruby | spigo/MI-RUB | /Semestralka/lib/Knapsack.rb | UTF-8 | 2,431 | 3.40625 | 3 | [] | no_license |
class Array
def power_set
yield [] if block_given?
self.inject([[]]) do |ps, elem|
r = []
ps.each do |i|
r << i
new_subset = i + [elem]
yield new_subset if block_given?
r << new_subset
end
r
end
end
end
class Knapsack
KnapsackItem = Struct.new(:name, :weight, :value)
def knap... | true |
7d9e0f0b641190de8bc7371efe9d792673ef5c12 | Ruby | sidapa/super_settings | /lib/super_settings/rule_key_parser.rb | UTF-8 | 566 | 2.875 | 3 | [
"MIT"
] | permissive | module SuperSettings
# RuleKeyParser parses rule keys. It takes in either a symbol
# or an array of symbols and parses through them, returning
# an array of symbols for registration
class RuleKeyParser
attr_accessor :keys
def initialize(params)
arr_params = Array(params)
valid_params = %w(St... | true |
e979e2ecc8dfdf6751f4cd4999ad47461bddc528 | Ruby | progpyftk/learn_to_code_with_ruby_udemy | /Section 12/count_values.rb | UTF-8 | 137 | 3.4375 | 3 | [] | no_license | custom_count (my_hash, number)
count = 0
my_hash.each do |key, value|
count += 1 if value == number
end
count
end | true |
811fb681b61e33c29afecd6bca752b0af01afc14 | Ruby | CarlosCanizal/blackjack_web | /main.rb | UTF-8 | 6,961 | 2.96875 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
set :sessions, true
helpers do
def start_game
suits = ["clubs", "diamonds", "hearts", "spades"]
values = ["A","2","3","4","5","6","7","8","9","10","Q","K"]
deck = suits.product(values)
decks = [deck,deck,deck,deck]
end
def show_cards(hand)
cards = ""
... | true |
5d4b2ce129bfbf8979eae586c4a30b0893ecd95f | Ruby | jinp6301/appacademy-exercises | /w1d3/merge_sort.rb | UTF-8 | 544 | 3.515625 | 4 | [] | no_license | def merge_sort(array)
if array.length < 2
return array
end
left, right = split_array(array)
result = combine(merge_sort(left), merge_sort(right))
end
def split_array(array)
middle = array.length/2
[array.take(middle), array.drop(middle)]
end
def combine(array1, array2)
if array1.empty? || array2.em... | true |
c5cda2a79431975f255d08c663f4877e8690e500 | Ruby | olistik/rsc-arena | /lib/rsc-arena/bot.rb | UTF-8 | 757 | 2.984375 | 3 | [
"MIT"
] | permissive | module Rsc::Arena
class Bot
attr_accessor :chips, :card, :bet
attr_reader :name
include Comparable
def initialize(name, klass)
@name, @bot = name, klass.new
@card = nil
@bet = 0
@chips = 0
end
def chips=(amount)
@chips = amount
@bot.chips = amount
end... | true |
da4d90e22b221a0a5d3dda011f5809c43954085a | Ruby | rorycforster/project_euler | /problem9.rb | UTF-8 | 1,002 | 4 | 4 | [] | no_license | def special_pythagorean_triplet(a, b, c)
if a < b
if b < c
if (a**2) + (b**2) == (c**2)
if (a + b + c) == 1000
puts "This is the special pythagorean triplet"
else puts "This is not the special pythagorean triplet"
end
end
end
end
end
def pyth_triplet(num)
if num.is... | true |
f66c92e5627010211acd4279410be2948cd4e34b | Ruby | ahmedelmahalawey/sablon | /test/html/node_properties_test.rb | UTF-8 | 4,109 | 2.625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require "test_helper"
class NodePropertiesTest < Sablon::TestCase
def setup
# struct to simplify prop whitelisting during tests
@inc_props = Struct.new(:props) do
def include?(*)
true
end
end
end
def test_empty_node_properties_converison
# test empty p... | true |
35862442f7aa901ca6ba769341786bf941a154b0 | Ruby | wribln/pmodbase | /app/models/base_item_list.rb | UTF-8 | 4,627 | 2.71875 | 3 | [] | no_license | # BaseItemList is shown on the base page having NO_OF_COLUMNS_ON_BASE_PAGE
# columns (defined in config/initializers/basic_settings.rb)
class BaseItemList
# return all features and associated headings in an array to be passed on
# to the BaseController; the array is multi-dimensional, the first index
# is over ... | true |
4d958a96bed27a725750969954ab83fcc04282f0 | Ruby | elaineparie/triangle-classification-v-000 | /lib/triangle.rb | UTF-8 | 764 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Triangle
attr_accessor :length_1, :length_2, :length_3
def initialize(length_1, length_2, length_3)
@length_1 = length_1
@length_2 = length_2
@length_3 = length_3
end
def kind
if @length_1 == 0 || @length_2 == 0 || @length_3 == 0
raise TriangleError
elsif @length_1 < 0 || @length_2 < 0 || @length_3 ... | true |
be755949733618fb3c887ff1f51f28960f59439b | Ruby | udaykadaboina/rabbitmq-tutorial | /send.rb | UTF-8 | 398 | 2.984375 | 3 | [] | no_license | require 'bunny'
# connect to RabbitMQ server
conn = Bunny.new
conn.start
# create a channel, where most of the API for getting things done resides
ch = conn.create_channel
# declare a queue, then pubhish a msg to the queue:
q = ch.queue("hello")
ch.default_exchange.publish("Hello world! from Bunny World!", :routing_ke... | true |
f23c615cdeb3eb8b20037bfd81d44a7a84466a07 | Ruby | ThoughtGang/BGO | /lib/bgo/application/commands/image-create.rb | UTF-8 | 3,178 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
# :title: Bgo::Commands::CreateImage
=begin rdoc
BGO command to create a new Image object.
Copyright 2013 Thoughtgang <http://www.thoughtgang.org>
=end
require 'bgo/application/command'
require 'bgo/application/commands/shared/data_model_options'
require 'bgo/application/commands/shared/pipeline'
... | true |
8a4e3e8bfc12257213640461b0a4c4bea2308dc9 | Ruby | bravoaggie/Electron | /features/step_definitions/edittimesheet_steps.rb | UTF-8 | 1,325 | 2.5625 | 3 | [] | no_license | require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "app", "models", "employee"))
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
module WithinH... | true |
a866a61009e395cf9864272a808acad0fa53af01 | Ruby | trikitrok/careerbuilder-2013-nov | /lib/bottles.rb | UTF-8 | 437 | 3.296875 | 3 | [] | no_license | require './lib/beer_verse'
class BottlesSong
def sing
verses(99, 0)
end
def verses(starting, ending = 0)
starting.downto(ending).map { |n| verse(n) }.join("\n") + "\n"
end
def verse(starting_bottle_count)
number = starting_bottle_count.to_bottlenum
"#{number} of beer on the wall, #{number.t... | true |
a4a71fe15c5c157c724b4810d14b9d6eadb8f684 | Ruby | treacher/payslip_generator | /lib/payslip_generator/employee_readers/csv_reader.rb | UTF-8 | 389 | 2.6875 | 3 | [] | no_license | module PayslipGenerator
module EmployeeReaders
class CsvReader < CSV
def each(&block)
super { |row| yield(convert(row)) }
end
def convert(row)
{
first_name: row[0],
last_name: row[1],
salary: BigDecimal.new(row[2]),
super_rate: row[3].to_f... | true |
fcdd49fb86117571e24eaf7632650f4867abb035 | Ruby | dhoffens/week-1 | /day-1/student_cities.rb | UTF-8 | 237 | 3.421875 | 3 | [] | no_license | cities = [ "boca raton", "bronx", "miami", "bloomington" ]
cities_capitalize = cities.map do |city|
if city.include? " "
city.split(" ").each do |c|
c.capitalize!
end.join(" ")
else
city.capitalize
end
end
p cities_capitalize | true |
bba4bd4101c72a86cc2f84cfbc8ebb5e33614ab0 | Ruby | TechnicallyAustin/reverse-each-word-online-web-pt-120919 | /reverse_each_word.rb | UTF-8 | 131 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def reverse_each_word(sentence = "")
new_arr = sentence.split(" ")
new_arr.collect { |element| element.reverse}.join(" ")
end
| true |
b79d25ea14a61de15979e22dde14bfb1e8c35e5d | Ruby | irevived1/ruby-object-initialize-lab-wdf-000 | /lib/dog.rb | UTF-8 | 227 | 3.0625 | 3 | [] | no_license | class Dog
def initialize(names,breeds="Mut")
@name = names
@breed = breeds
end
def name= (names)
@name = names
end
def breed= (breeds)
@breed = breeds
end
def name
@name
end
def breed
@breeds
end
end
| true |
d6f5d6ef3093c8ab644d3d0da4162a18c84d5631 | Ruby | takayuki-ochiai/CodePractice | /RubyPractice/repeat_practice/itodenwa2.rb | UTF-8 | 166 | 3.171875 | 3 | [] | no_license | n = 16
pair = Array.new(n / 2 + 1)
pair[0] = 1
1.upto(n/2) do |i|
pair[i] = 0
i.times do |j|
pair[i] += pair[j] * pair[i - j - 1]
end
end
puts pair[n/2]
| true |
11eae715fdac06cc1a6e1edbf38c2e5664ee6ca9 | Ruby | stumpy224/grid_pool | /app/models/game.rb | UTF-8 | 2,182 | 2.6875 | 3 | [] | no_license | class Game
attr_accessor(
:game_id,
:bracket_position_id,
:game_state,
:game_is_live,
:game_over,
:round,
:team_on_top_seed,
:team_on_top_name_short,
:team_on_top_name_full,
:team_on_top_score,
:team_on_top_is_winner,
:team_on_bottom_seed,
:team_on_bottom_name_short... | true |
e4ef8f9c616825cc591449dce74df46f5e578ff6 | Ruby | maegus/Learn | /Book/Introduction-To-Algorithms/direct_address.rb | UTF-8 | 175 | 2.984375 | 3 | [] | no_license | class DirectAddressTable
def initialize
@table = []
end
def search(k)
@table[k]
end
def insert(x)
@table[x] = x
end
def delete(x)
@table[x] = nil
end
end
| true |
439e9dae296c15d613c498da70447b8d5a0172cd | Ruby | kirirotha/sinatra-mvc-lab-hou01-seng-ft-071320 | /models/piglatinizer.rb | UTF-8 | 1,131 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class PigLatinizer
attr_accessor :phrase
def initialize
@phrase = phrase
end
def piglatinize(phrase)
split_phrase = phrase.split(" ")
piglat_phrase = []
split_phrase.each do |word|
letters = word.split("")
vowels = ["a", "e", "i", "o... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.