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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
38b75ff68aa21ff5aa3da35441507f7c11931c72 | Ruby | Timbinous/practice | /libraries/resque/word_analyzer.rb | UTF-8 | 218 | 2.953125 | 3 | [] | no_license | class WordAnalyzer
@queue = 'some_queue_name'
def self.perform(from_queue)
puts "About to do some heavy duty analysis on #{from_queue}"
sleep 3
puts "Finished with analysis on #{from_queue}"
end
end
| true |
2166bcb0962e702fa0de664ec2d2a7baad54ff17 | Ruby | moonfox/2-broke-girls | /app/format_subtitle.rb | UTF-8 | 2,605 | 2.625 | 3 | [] | no_license | require 'iconv'
class FormatSubtitle
class << self
def remove_timeline
item = ARGV[0]
source_file = File.readlines(File.expand_path("../original/broke_girls_#{item}.txt", __FILE__))
find_session_start = source_file.find_index("19\n")
if find_session_start.nil?
find_session_start = ... | true |
81185fac01001cc4d92723c46adbee38b552cc8e | Ruby | Taishawnk/programming-univbasics-3-labs-with-tdd-online-web-prework | /calculator.rb | UTF-8 | 885 | 4.09375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | puts "Simple Calculator"
25.times{ print "-"}
puts
puts "first number"
num_1 = gets.chomp
puts "second number"
num_2 = gets.chomp
puts "let's multiply both numbers and we get #{num_1.to_i * num_2.to_i}"
puts "let's divide both numbers and we get #{num_1.to_i / num_2.to_i}"
puts "let's substract both numbers and we get ... | true |
e120db1a982df6c5b576a41fe8a3f3d50b8acede | Ruby | sunainashrivastava/Ruby-Assignments | /class.rb | UTF-8 | 104 | 3.265625 | 3 | [] | no_license | class FirstClass
def hello
puts "Hello Ruby!"
end
end
object = FirstClass.new
object.hello
| true |
e5e635e4d605d24e7bffcab15fc3bf8130d15838 | Ruby | amckemie/Walking-With-The-Dead-Dungeon-Game | /spec/commands/use_item_spec.rb | UTF-8 | 11,660 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
describe WWTD::UseItem do
let(:db) {WWTD.db}
before(:each) do
db.clear_tables
@room = db.create_room(name: 'Bedroom', description: 'test', quest_id: 1)
@player = db.create_player(username: 'Ashley', password: 'eightletters', description: "Test player", room_id: @room.id)
@jack... | true |
25e4e532c5c8456cfc2bd02176bddcb9bbaf9455 | Ruby | jminterwebs/flatiron-bnb-methods-v-000 | /app/models/listing.rb | UTF-8 | 1,123 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Listing < ActiveRecord::Base
belongs_to :neighborhood
belongs_to :host, :class_name => "User"
has_many :reservations
has_many :reviews, :through => :reservations
has_many :guests, :class_name => "User", :through => :reservations
validates :address, presence: true
validates :listing_type, presence: ... | true |
d2fc62c6d531977105ee64cdb50ba10b05382b9c | Ruby | sulaimancode/bank_tech_test | /spec/account_spec.rb | UTF-8 | 788 | 2.703125 | 3 | [] | no_license | require 'account'
describe Account do
TRANSACTION_AMOUNT = 1000
let(:account) { described_class.new }
let(:transaction) { double :transaction, amount: TRANSACTION_AMOUNT }
before do
allow(transaction).to receive(:account_balance=)
allow(transaction).to receive(:type=)
end
describe '::new' do
i... | true |
45dddb9c20787fb25bb5b80d5be2060c5305ceb8 | Ruby | bsdave/ruby-parallel-forkmanager | /lib/parallel/forkmanager/serializer.rb | UTF-8 | 1,503 | 3.046875 | 3 | [] | no_license | require "yaml"
require_relative "error"
module Parallel
class ForkManager
# TODO: Maybe make this into a factory, given the number of case statements
# switching on type. This is a "shameless green" if you use Sandi Metz's
# terminology.
class Serializer
##
# Raises a {Parallel::ForkMana... | true |
abca139ab18486e28a22bf5ebf5329e20a224a30 | Ruby | sjmog/dnd_engine | /lib/item.rb | UTF-8 | 181 | 2.65625 | 3 | [] | no_license | class Item
attr_reader :type, :armor_check_penalty
def initialize(opts = {})
@type = opts.fetch(:type, :misc)
@armor_check_penalty = opts[:armor_check_penalty]
end
end | true |
db47cc614fbfc5cd520ad79c9ee042d8157deecd | Ruby | daneb/codedtrue.com | /column_to_sql.rb | UTF-8 | 473 | 3.1875 | 3 | [] | no_license | # Converts a column format file into a SQL string for use in an "IN"
# For example: select * from x where y IN ({result})
#
if ARGV.empty?
puts "Please provide a column spaced file to convert to a SQL string"
else
sql_string = ""
column_file = ARGV.last
file = File.open(column_file)
file.each do |column_item|
... | true |
3cdd7d8ea8b3ae0bee364e2f97bef7a650784fcf | Ruby | TapasTech/InvestCooker | /lib/concerns/limit_frequency.rb | UTF-8 | 1,097 | 2.5625 | 3 | [] | no_license | concern :LimitFrequency do
def limit_frequency(key:, time: nil)
return if $redis_object.get(key).present?
$redis_object.set(key, 'processing')
yield
ensure
if time.present?
$redis_object.expire(key, time)
else
$redis_object.del(key)
end
end
included do
def self.limit_... | true |
d6d951cdd0bd40eb11c7611c9857512c0e814f5e | Ruby | jongillies/barnyard | /barnyard_harvester/lib/barnyard_harvester/generic_queue.rb | UTF-8 | 1,950 | 2.84375 | 3 | [
"MIT"
] | permissive | module BarnyardHarvester
class GenericQueue
def initialize(args)
@queueing = args.fetch(:queueing) { raise "You must provide :queueing" }
case @queueing
when :sqs
require "aws-sdk"
@sqs_settings = args.fetch(:sqs_settings) { raise "You must provide :sqs_settings" }
... | true |
aa2294df03a03753420bb80afdc6c6dbb172ea04 | Ruby | Jing1107/wdi30-classwork | /wdi30-ruby/05-ruby/class.rb | UTF-8 | 972 | 3.53125 | 4 | [] | no_license | require 'pry'
class Actor
def award_speech
"I would like to thank my parents and my agent. We did it baby"
end
def deny_allagations
"I deny that and I was drunk and I don't remember"
end
end
class MarxBrother
attr_accessor :name, :instrument, :vice #Macro -writes the getter and setter for you
# ... | true |
2cc192393689332532a8804ae6e8c28658f66b87 | Ruby | minnonong/Codecademy_Ruby | /01. Introduction to Ruby/01_12.rb | UTF-8 | 115 | 3.359375 | 3 | [] | no_license | # 01-12 Naming Conventions
# 변수 이름은 소문자로 시작하고 단어는 _로 구분함.
name = "Eric"
| true |
01079e1e30d194bfcbe52fa9b4cf61b077ef0da3 | Ruby | spejamchr/code | /first_programs/stuff.rb | UTF-8 | 166 | 2.875 | 3 | [] | no_license | number = 1
start_time = Time.new
1000000.times do
number = number * 2
end
puts number.to_s.length
processing_time = Time.new - start_time
puts
puts processing_time
| true |
857e11df8f6d81d0812f01da78ffb445a40640b1 | Ruby | dnhc/Introduction-to-Regular-Expressions | /Character_Class_Shortcuts/ex3.rb | UTF-8 | 751 | 3.84375 | 4 | [] | no_license | # Write a regex that matches any four digit hexadecimal number that is both
# preceded and followed by whitespace. Note that 0x1234 is not a hexadecimal
# number in this exercise: there is no space before the number 1234.
# Hello 4567 bye CDEF - cdef
# 0x1234 0x5678 0xABCD
# 1F8A done
# There should be four matches (2... | true |
4048d7a621e99f19c65bf0b25f0fe7a12c1fb572 | Ruby | AskBid/school-domain-online-web-sp-000 | /lib/school.rb | UTF-8 | 433 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
attr_reader :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(stud, grade)
@roster[grade] = [] if ! @roster[grade]
@roster[grade] << stud
end
def grade(grade)
@roster[grade]
end
def sort
@roster.each {|k, arr|
# puts '--------------'
# put... | true |
eec18822a61285b3f4cdb791cd43cb20b672aa4c | Ruby | rootstrap/rs-code-review-metrics | /app/services/builders/review_turnaround.rb | UTF-8 | 986 | 2.53125 | 3 | [] | no_license | module Builders
class ReviewTurnaround < BaseService
def initialize(review_request)
@review_request = review_request
end
def call
::ReviewTurnaround.create!(review_request: @review_request,
value: calculate_turnaround,
pull_req... | true |
99211d23632ae45bef425c1f77ce0fc94d07e0aa | Ruby | nico24687/open_mic | /lib/joke.rb | UTF-8 | 331 | 2.890625 | 3 | [] | no_license | class Joke
attr_reader :id,
:question,
:answer
def initialize(attributes)
@id = attributes[:id]
@question = attributes[:question]
@answer = attributes[:answer]
end
# def id
# @id
# end
# def question
# @question
# end
# def answer
# @answer
#... | true |
80f2a923338765d8056d73e00c5388db1c0b6421 | Ruby | sshaw/itunes_store_transporter | /lib/itunes/store/transporter/output_parser.rb | UTF-8 | 2,415 | 2.859375 | 3 | [
"MIT"
] | permissive | require "itunes/store/transporter/errors"
module ITunes
module Store
module Transporter
class OutputParser
##
# This class extracts error and warning messages output by +iTMSTransporter+. For each message
# is creates an instance of ITunes::Store::Transporter::TransporterMessage
... | true |
92c64e817773e5cae9ac5a78224c5e172abfa8db | Ruby | daniel-schroeder-dev/tts-ruby | /w1/wk_2_hw1.rb | UTF-8 | 366 | 4.78125 | 5 | [] | no_license | # Write a program that takes a string argument and:
# outputs the string in reverse
# outputs the string in all caps
# tells you the length of the string
puts "Type any sentence:"
sentence = gets.chomp
puts "The sentence reversed is #{sentence.reverse}"
puts "The sentence in all caps is #{sentence.upcase}"
puts "The... | true |
b32f719bc1d46ee1fe4aa4ab3289a44123c13a5c | Ruby | aballal/oystercard | /feature_spec/feature9_spec.rb | UTF-8 | 221 | 3.203125 | 3 | [] | no_license | # Step 13
# In order to know how far I have travelled
# As a customer
# I want to know what zone a station is in
require_relative '../lib/station.rb'
station = Station.new("Kings Cross",1)
p station.name
p station.zone
| true |
726cf0ab2f4ec53210241badb2376cdbb3c9f1c8 | Ruby | jaynetics/immutable_set | /benchmarks/new.rb | UTF-8 | 892 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative './shared'
benchmark(
caption: '::new with 5M Range items',
cases: {
'stdlib' => ->{ S.new(0...5_000_000) },
'gem' => ->{ I.new(0...5_000_000) },
'gem w/o C' => ->{ P.new(0...5_000_000) },
}
)
benchmark(
caption: '::new with 100k Range items',
cases: {
'stdlib' =... | true |
bf13ae5a8251028cc810ff32e5370f03e762465d | Ruby | cadwallion/em-ruby-irc | /lib/em-ruby-irc/IRC-User.rb | UTF-8 | 329 | 2.8125 | 3 | [] | no_license | module IRC
class User
attr_reader :name
attr_accessor :hostmask, :user_data
attr_writer :logged_in
def initialize(name, hostmask=nil)
@name = name
@hostmask = String.new
@hostmask = hostmask unless hostmask.nil?
@logged_in = false
@user_data = nil
end
def logged_in?
@logged_in
end... | true |
52c112e0e34a438cee35f3711ee011122b82002e | Ruby | Pablo-Merino/mail-parser | /lib/mail_parser/address.rb | UTF-8 | 280 | 2.84375 | 3 | [] | no_license | module MailParser
class Address
attr_accessor :name
attr_accessor :address
EMAIL_REGEX = /^(.+) <(.+)>$/i
def initialize(string)
matches = EMAIL_REGEX.match(string)
@name = matches[1]
@address = matches[2]
end
end
end | true |
994f63607c774163578e43aea033b7e178f18365 | Ruby | joelmac/number-sensei-rails-4 | /db/seeds/gamification.seeds.rb | UTF-8 | 1,074 | 3.125 | 3 | [] | no_license | # experience level curve
ExperienceLevel.delete_all
ExperienceFunction.delete_all
levels = 20
xp_for_first_level = 100
xp_for_last_level = 200000
BB = Math.log(1.0 * xp_for_last_level / xp_for_first_level) / (levels - 1)
AA = 1.0 * xp_for_first_level / (Math.exp(BB) - 1.0)
puts "Coefficients A=#{AA}, B=#{BB}"
exper... | true |
f5d97bde7638faf44ff80d46d502edfef0eba096 | Ruby | macbury/ralyxa | /lib/ralyxa/register_intents.rb | UTF-8 | 1,322 | 2.78125 | 3 | [
"MIT"
] | permissive | require_relative './skill'
module Ralyxa
class RegisterIntents
DEFAULT_INTENTS_DIRECTORY = './intents'.freeze
def initialize(intents_directory, alexa_skill_class)
@intents_directory = intents_directory
@alexa_skill_class = alexa_skill_class
end
def self.run(intents_directory = DEFAULT_I... | true |
5411b5567b7f18c3ce502547a92bfc04c88df06c | Ruby | MadBomber/experiments | /ruby_misc/net_ssh_multi_test.rb | UTF-8 | 2,426 | 2.625 | 3 | [] | no_license | ##############################################
###
## File: net_ssh_multi_test.rb
## Desc: Just testing
#
require 'net/ssh'
Net::SSH.start('10.0.52.139', 'dvanhoozer', :password => ENV["xyzzy"]) do |ssh|
# capture all stderr and stdout output from a remote process
output = ssh.exec!("hostname"... | true |
ecebbfe3c53d0916d6f76e25b4012d69c56f8334 | Ruby | mfoody72/WDI_SYD_7_Work | /w01/d01/michael/roman_numerals.rb | UTF-8 | 370 | 3.890625 | 4 | [] | no_license | def to_roman(number)
string = "I" * number
string.gsub("I" * 1000, "M").
gsub("I" * 900, "CM").
gsub("I" * 500, "D").
gsub("I" * 400, "CD").
gsub("I" * 100, "C").
gsub("I" * 90, "CX").
gsub("I"*50,"L").
gsub("I"*40,"LX").
gsub("I"*10,"X").
gsub("I"*9,"XI").
gsub("I"*5,"V... | true |
d148087488ca86ab344bd6ac32eac68340b179f7 | Ruby | cristianrasch/c2010-scrapper | /lib.rb | UTF-8 | 1,907 | 2.921875 | 3 | [
"MIT"
] | permissive | ###
### Methods
###
def usage
"
Censo 2010 Scrape Tool: Usage
ruby scrape.rb [option]
* option: Viviendas, Poblacion, Hogares
"
end
def scrape_viviendas
scrape(VIVIENDAS_ID)
end
def scrape_hogares
scrape(HOGARES_ID)
end
def scrape_poblacion
scrape(POBLACION_ID)
end
def scrape_xls(base_path, p... | true |
f3dc94f87ef110265dd8679b13299c43c01277a8 | Ruby | myokoym/bricks_meet_balls | /lib/bricks_meet_balls/bar.rb | UTF-8 | 737 | 3.15625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "gosu"
require "bricks_meet_balls/util"
require "bricks_meet_balls/z_order"
module BricksMeetBalls
class Bar
include Util
def initialize(window)
@window = window
@width = @window.width * 0.3
@height = @window.height * 0.01
@x1 = @window.width * 0.5
@y1 = @window.heig... | true |
48ea896e11b0f22bdfa6e86c53df68674f0f572b | Ruby | thefotios/uberconfig | /lib/uberconfig.rb | UTF-8 | 806 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'logging'
module UberConfig
class Config
include Logging
attr_reader :configs, :values
def initialize(*configs)
logger.debug "Initializing"
@values = {}
@configs = []
configs.each do |cfg|
add_config(cfg)
end
end
def add_conf... | true |
cf8caa6d7b04bcd2e6ee58331b7bae2f779f8411 | Ruby | kpenn44/Ruby-Programming | /BlackJack_Exercise.rb | UTF-8 | 7,513 | 3.59375 | 4 | [] | no_license | #---------------------------------------------------------------------------
#
# Script Name: BlackJarck.rb
# Version: 1.0
# Author: Kelvin Penn
# Date: April 2010
#
# Description: This ruby game is a computerized version of the casino card
# game in which the player competes against the dealer (i.e., computer) in
# a... | true |
381195b9e4ff3071433fb1e0fdd4ddbb2fad49cf | Ruby | IanVaughan/site-stats | /stats.rb | UTF-8 | 346 | 2.53125 | 3 | [] | no_license | require 'sinatra'
require 'json'
stats = { nmt: 4807, mods: 35221, interactions: 211330, sites: 7601, members: 11987246 }
counter = Thread.new(stats) do |s|
loop do
s[:nmt] += 4
s[:mods] += 3
s[:interactions] += 1
s[:sites] += 0
s[:members] += 4
sleep 1
end
end
get '/' do
content_type ... | true |
95f552302b816d8cc21931d52c74d9686ff64165 | Ruby | TamerL/searchable_docs | /spec/document_spec.rb | UTF-8 | 1,191 | 2.640625 | 3 | [] | no_license | require 'rspec/autorun'
require './src/document'
RSpec.describe Document do
describe '.initialize' do
# initialize is a class method
before do
@document = Document.new('./doc1.txt')
end
it 'has a name' do
expect(@document.name).to eq('doc1.txt')
end
it 'has a path' do
... | true |
a4a6143d71cd1a5cc0ca94e38e91b4ffc99903bc | Ruby | nhashmi/a-nice-nest | /app/models/ranking.rb | UTF-8 | 888 | 2.671875 | 3 | [] | no_license | class Ranking < ActiveRecord::Base
belongs_to :user
def self.load_rankings(user)
if user.rankings.all.length == 0
total_residents = user.other_residents.to_i + 1
total_residents.times do
user.rankings.create
end
@rankings = user.rankings.all
return @rankings
end
end
... | true |
5ee0dfbcbad33570a65e0e70cefde60f9ccf4433 | Ruby | hopsoft/hero | /test/observer_test.rb | UTF-8 | 1,044 | 2.546875 | 3 | [
"MIT"
] | permissive | require File.expand_path("../test_helper", __FILE__)
class ObserverTest < PryTest::Test
test "should support add_step" do
step = lambda {}
o = Hero::Observer.new(:example)
o.add_step(:one, step)
assert o.steps.length == 1
assert o.steps[0].first == :one
assert o.steps[0].last == step
end
... | true |
576f80dcafdd91ad9a4f7dd740965cff037109d6 | Ruby | jfredett/advent2020 | /lib/toboggan.rb | UTF-8 | 271 | 3.0625 | 3 | [] | no_license | class Toboggan
attr_reader :run, :fall, :position
attr_accessor :performance
def initialize(run, fall)
@position = [0,0]
@run = run
@fall = fall
end
def slide!
@position = [self.position[0] + self.run, self.position[1] + self.fall]
end
end
| true |
2b6e2b58b502201f80f83c9e83faaf032a584a84 | Ruby | caueguedes/design_patterns_ruby | /behavioral/8_strategy_example.rb | UTF-8 | 960 | 3.828125 | 4 | [] | no_license | class Strategy
def execute(_a, _b)
raise NotImplementedError, "#{self.class} has not implemented method #{__method__}"
end
end
class ConcreteStrategyAdd < Strategy
def execute(a, b)
a + b
end
end
class ConcreteStrategySubtract < Strategy
def execute(a, b)
a - b
end
end
class ConcreteStrategyM... | true |
718bf343ace98486ab71eee8370ad46754026390 | Ruby | zencoder/zenflow | /spec/zenflow/helpers/ask_spec.rb | UTF-8 | 4,691 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Zenflow do
describe "prompt" do
before do
Zenflow.stub(:LogToFile)
$stdin.stub(:gets).and_return("good")
end
it "displays a prompt" do
Zenflow::Query.should_receive(:print).with(">> How are you? ")
Zenflow::Ask("How are you?")
end
it "disp... | true |
0df5ccb8cf8303cb40b819aa5e59b2ba1bc1ff62 | Ruby | manofsteele/W4D2 | /ninetyninecats/app/models/cat.rb | UTF-8 | 372 | 2.515625 | 3 | [] | no_license | class Cat < ApplicationRecord
validates :birth_date, :color, :name, presence: true
validates :sex, presence: true, inclusion: {in: ["M", "F"]}
COLORS = ["red", "black", "calico", "grey", "white", "blue"]
def age
birth_year = self.birth_date.year
this_year = Date.today.year
return this_ye... | true |
d81fb160f70e72ad5192eef64bbc548c59ddb091 | Ruby | lelilia/job-prep | /leetCode/merge-sorted-array.rb | UTF-8 | 1,779 | 3.796875 | 4 | [] | no_license | # https://leetcode.com/problems/merge-sorted-array/
# @param {Integer[]} nums1
# @param {Integer} m
# @param {Integer[]} nums2
# @param {Integer} n
# @return {Void} Do not return anything, modify nums1 in-place instead.
def merge(nums1, m, nums2, n)
return nums1 if n == 0
k = m + n - 1
i = m - 1
j = n - 1... | true |
b19e6395901c33fb621118f9cc6ec09ee1418c1c | Ruby | dmaster18/learn-co-sandbox | /ruby_past_practice/bartender.rb | UTF-8 | 820 | 3.765625 | 4 | [] | no_license | class Bartender
attr_accessor :name
BARTENDERS = []
def initialize(name)
@name = name
BARTENDERS << self
end
def self.all
BARTENDERS
end
def intro
"Hello, my name is #{@name}!"
end
def make_drink
@cocktail_ingredients = []
choose_liquor
choose_mixer
choos... | true |
8fef43adc7ee054140160c37a042a34a1dc743bc | Ruby | Bluezzy/101 | /101-109first_attempt/easy9.rb | UTF-8 | 1,748 | 4 | 4 | [] | no_license | def greetings(name, skill)
"Hello #{name.join(' ')} ! We are glad to have a #{skill[:title]} \n
#{skill[:occupation]} here !"
end
def doubled?(number)
number = number.to_s
number_of_digits = number.size
center_index = (number_of_digits / 2)
left_part = number[0..center_index-1]
right_part = number[cent... | true |
5491d106501bb36c8ae076522e31d86917762378 | Ruby | AnansiOmega/mod-1-mini-challenge-oo-one-to-many | /models/menu_item.rb | UTF-8 | 410 | 3.34375 | 3 | [] | no_license | require 'pry'
class MenuItem
attr_accessor
attr_reader :dish_name, :price, :restaurant
@@all = []
def self.all
@@all
end
def initialize(restaurant,dish_name,price)
@restaurant = restaurant
@dish_name = dish_name
@price = price
@@all << self
end
... | true |
4bdedbab0d6af5781fdac5a7de85dafcadde9b7e | Ruby | rsupak/aa-online | /Richard_Supak_Hotel_Project/lib/hotel.rb | UTF-8 | 847 | 3.515625 | 4 | [] | no_license | require_relative "room"
class Hotel
attr_accessor :rooms
def initialize(name, rooms)
@name = name
@rooms = rooms.each { |k, v| rooms[k] = Room.new(v) }
end
def name
@name.split.map(&:capitalize).join(' ')
end
def room_exists?(room_name)
rooms.key?(room_name)
end
def check_in(person, ... | true |
abb52e99011b8479251f5552076b50f3b0f601b5 | Ruby | mpereira/bell | /lib/bell/user_report.rb | UTF-8 | 2,157 | 2.921875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Bell
class UserReport
include Bell::Util::String
def initialize(phone_bill, user_name)
@phone_bill = phone_bill
@user_name = user_name
end
def user
Bell::User.find(:name => @user_name)
end
def calls
@phone_bill.calls.inject([]) do |calls, ca... | true |
8845287991b6dce2583efbade5cddf16afc611aa | Ruby | bluepostit/active-record-intro-628 | /db/seeds.rb | UTF-8 | 519 | 2.921875 | 3 | [] | no_license | # This is where you can create initial data for your app.
require 'faker'
# Restaurant.destroy_all
puts 'Creating restaurants...'
tour_d_argent = Restaurant.new(name: "La Tour d'Argent", address: 'Paris')
tour_d_argent.save!
chez_gladines = Restaurant.new(name: "Chez Gladines", address: 'Marseille')
chez_gladines.sa... | true |
7896e9c5d10ab83f36f7d52b069742287995a927 | Ruby | masterzora/tawny-cdk | /lib/cdk/viewer.rb | UTF-8 | 23,040 | 2.609375 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | require_relative 'cdk_objs'
module CDK
class VIEWER < CDK::CDKOBJS
DOWN = 0
UP = 1
def initialize(cdkscreen, xplace, yplace, height, width,
buttons, button_count, button_highlight, box, shadow)
super()
parent_width = cdkscreen.window.getmaxx
parent_height = cdkscreen.window.get... | true |
0fc6ded8ddd3f3f9670fdcaad520f9cdcf200f19 | Ruby | gipsh/miradetodo-scrapper | /test.rb | UTF-8 | 284 | 2.9375 | 3 | [] | no_license | require 'base64'
s = "aHR0c!ArEovL29rLnJ1L3ZpZGVvLzE2MTg5O!ArEExNjE1N!ArEUN"
puts "original string [#{s}]"
t = s.split("!Ar")
for i in 1..t.size-1
puts "#{i}. #{t[i]}"
t[i][0] = (t[i][0].ord - 1).chr
end
puts t.join
puts "Download link is: #{Base64.decode64(t.join)}"
| true |
c0a23b036385512ab6b68a93c16dc9749267012f | Ruby | edwardloveall/bestiary | /lib/bestiary/parsers/space.rb | UTF-8 | 626 | 2.875 | 3 | [
"LicenseRef-scancode-ogl-1.0a",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Bestiary::Parsers::Space
attr_accessor :creature
def self.perform(creature)
new(creature).perform
end
def initialize(creature)
@creature = creature
end
def perform
return if parent_element.nil?
text = parent_element.text
feet(text)
end
def parent_element
@parent ||= beg... | true |
fe771b759dbe19773078070f05fd0225501b79b0 | Ruby | ChenWeiLee/CWSVM | /pattern.rb | UTF-8 | 914 | 3.203125 | 3 | [
"MIT"
] | permissive |
require './kernels'
class Pattern
attr_accessor :features # 數據特徵值
attr_accessor :expectation # 期望輸出值
attr_accessor :alpha
def initialize(data_features, expectation_target, alpha_value = 0)
@features = data_features.to_a # Why needs to_a ?
@expectation = expectation_target.to_f
@alpha ... | true |
a72074a779f469a4d40930fc6515644e6b488eb1 | Ruby | aravindh-browserstack/greed.dice.game | /game.rb | UTF-8 | 3,877 | 3.578125 | 4 | [] | no_license | require './player'
include Player
require './diceset'
include DiceSet
module Game
class GameClass
def initialize(num_players)
raise ArgumentError unless num_players > 1
@players = []
@player_score = {}
@dice = Dice.new
count = 1
num_players.times {
p = PlayerClass... | true |
ce02748bdbf411f41653c85d55b2aac26c60f4cd | Ruby | JakeMKelly/phase-0-tracks | /ruby/santa.rb | UTF-8 | 1,766 | 3.53125 | 4 | [] | no_license | class Santa
attr_reader :ethnicity, :age
attr_accessor :gender
def initialize(gender, ethnicity)
puts "Initializing Santa instance..."
@gender = gender
@ethnicity = ethnicity
end
def gender_ethnicity(gender, ethnicity)
puts "#{@gender}, #{@ethnicity}"
end
def speak
puts "Ho, ho, ho! H... | true |
a653be7e37dd7432844c0ebd04fd46ae4bb57934 | Ruby | atsubi/oekakinosato | /cgi-bin/decide_answer.rb | UTF-8 | 171 | 2.671875 | 3 | [] | no_license | #!/root/.rbenv/shims/ruby
# -*- coding: utf-8 -*-
player_mun = [ 1, 2, 3, 4 ]
p = player_mun.sample
puts p
fp = File.open("answer.txt", "w")
fp.print "#{p}"
fp.close
| true |
0f463e94314a14c94d687d6d184c70200b69475a | Ruby | tblarel/W3D2 | /AA_questions/question_like_orm.rb | UTF-8 | 1,597 | 2.828125 | 3 | [] | no_license | require_relative 'users_orm'
require_relative 'questions_orm'
class QuestionLike
attr_accessor :user_id, :question_id
def self.all
data = QuestionsDatabase.instance.execute ("SELECT * FROM question_likes")
data.map { |datum| QuestionLike.new(datum) }
end
def self.likers_for_question_id(search_questio... | true |
f50d1f723ad11a5380e7d409806381f1d442acc6 | Ruby | Frosty21/w6d1 | /math-game/round.rb | UTF-8 | 1,347 | 4.09375 | 4 | [] | no_license | # starts the round with Player1 as player to starts
# <TODO> set initialize current_player as a puts choice option question
class Round
def initialize(player1, player2)
@player1 = player1
@player2 = player2
@current_player = @player1
end
# sets number1 and number2 for each player between 1-20
# ran... | true |
0d6edd63fffbec9bf2bfcee55c95c2a278ce0f55 | Ruby | terra-yucco/ruthenium | /test/controllers/recipe_controller_test.rb | UTF-8 | 1,864 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class RecipeControllerTest < ActionController::TestCase
# 楽天APIを利用してピックアップレシピが取得できる
test "should get pickup via rakuten api" do
get :pickup
assert_response :success
assert_not_nil assigns(:menu)
assert_not_nil assigns(:materials)
end
# カテゴリーを指定してレシピを取得できる
test "should ... | true |
dbe50364dc16d3d35d9c39c1443c3c6a09ce260e | Ruby | haugenc/oo-kickstarter-v-000 | /lib/project.rb | UTF-8 | 311 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Project
attr_accessor :title, :backers
def initialize(title)
@title = title
@backers = []
end
#///CLASS METHODS ///#
#///INSTANCE METHODS ///#
def add_backer(backer)
@backers << backer
backer.back_project(self) if backer.backed_projects.all? {|test| test != self}
end
end | true |
4c50d688af41b414cc8ecf2f7e74a64b13040ea0 | Ruby | LesnyRumcajs/advent-of-ruby-2019 | /src/day9.rb | UTF-8 | 344 | 2.984375 | 3 | [
"MIT"
] | permissive | require_relative 'components/intcodeparser'
intcode = File.read('res/day9.txt').split(',').map(&:to_i)
# part 1
computer = IntCodeParser.new(intcode.clone)
computer.calculate [1] until computer.finished?
p computer.output
# part 2
computer = IntCodeParser.new(intcode.clone)
computer.calculate [2] until computer.fini... | true |
165adb22d734a24c02cb33be2b7ec0e628c03436 | Ruby | dvguruprasad/movie_rec | /app/models/recommender.rb | UTF-8 | 1,121 | 3.0625 | 3 | [] | no_license | class Recommender
def self.recommend(user)
similar_users = Similarity.similar_to(user)
weighted_rating_sums = weighted_rating_sums(similar_users, user)
final_movie_ratings = {}
weighted_rating_sums.each do |movie_id, weighted_rating|
final_movie_ratings[movie_id] = weighted_rating / similarity... | true |
0c3dd3733734a4c7bd64fe2b63a5afe0cdc39605 | Ruby | pimenvibritania/ChatRoom | /alphabet.rb | UTF-8 | 1,442 | 3.734375 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# alphabet.rb
#
# this module grabs alphabet letters from the alphabet.yml file and allows
# you to print them out or builds and returns a hash map of their data.
require 'yaml'
module Alphabet
YAML_FILE = File.dirname(__FILE__) + '/alphabet.yml'
DOCUMENT = YAML.load_file(YAML_FILE)
def s... | true |
6034a8e2d658d40f0417e79e2ebd536032bfc509 | Ruby | microformats/microformats-ruby | /lib/microformats/time_property_parser.rb | UTF-8 | 7,411 | 2.515625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Microformats
class TimePropertyParser < ParserCore
def parse(element, base: nil, element_type:, format_class_array: [], backcompat: nil)
@base = base
@duration_value = nil
@date_value = nil
@time_value = nil
@tz_value = nil
@property_type = element_type
@fmt_clas... | true |
85ee7ff22c3df51879cfc30ab7224b708cb21440 | Ruby | somenugget/dry-stuff | /app/async_monads.rb | UTF-8 | 1,110 | 2.9375 | 3 | [] | no_license | require 'benchmark'
require 'dry/monads/task'
require './lib/blog/get'
class GetPhotoaAndAlbums
include Dry::Monads::Task::Mixin
def call
# Start two tasks running concurrently
albums = Task { fetch_albums }
photos = Task { fetch_photos }
# Combine two tasks
albums.bind do |albums_result|
... | true |
fd9802ea3be381f2c13bfefbaeb489d44b7acd89 | Ruby | javkhaanj7/ruby-challenges | /WordCount.rb | UTF-8 | 449 | 4.3125 | 4 | [] | no_license | #Using the Ruby language, have the function WordCount(str) take the str string parameter
#being passed and return the number of words the string contains (ie. "Never eat shredded wheat" would return 4).
#Words will be separated by single spaces.
#Correct Sample Outputs:
#Input = "Hello World" Output = 2
#Input = "on... | true |
da33c287cdddd7f03a1710f3c9d83ff62e96c050 | Ruby | josephbhunt/GosuShooter | /grid.rb | UTF-8 | 1,255 | 3.703125 | 4 | [] | no_license | # This is not functional yet.
# The intent of Grid is to brake the screen into a grid of squares. Then images can be assigned to the grid
# to create a background image or level environment like walls, etc.
# Each square should have a GridTile attached to it. The GridTile contains an image.
# This way the grid tiles ca... | true |
9c0b69705494994f30779b0098939351f5ab90fb | Ruby | justonemorecommit/puppet | /lib/puppet/pops/types/p_sensitive_type.rb | UTF-8 | 1,529 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | module Puppet::Pops
module Types
# A Puppet Language type that wraps sensitive information. The sensitive type is parameterized by
# the wrapped value type.
#
#
# @api public
class PSensitiveType < PTypeWithContainedType
class Sensitive
def initialize(value)
@value = value
end
def unwrap
@v... | true |
2d6b633a0ef897434d16b642c633a7863d8a0047 | Ruby | imperio0001/aula-gama | /challenge/game/game.rb | UTF-8 | 777 | 3.828125 | 4 | [] | no_license | class Game
def iniciar
# Introducao e Regras do jogo
puts "Luck Game"
puts "==============="
puts "Sera sorteado um numero,\n
sera que você consegue adivinhar?"
# Sorteia o númro
numero = sortear
puts "Numero sorteado!"
# Espera o usuário digitar um número
puts "Qual numero s... | true |
9337d0d56dc48c10701ca32125d39775f0e1fbc3 | Ruby | luckyfishlab/foundry | /lib/foundry/callback.rb | UTF-8 | 844 | 2.75 | 3 | [
"MIT"
] | permissive | require 'redis'
require 'uuid'
require 'json'
module Foundry
# Callback provides a mechanism to signal that a job
# is done
class Callback
attr_reader :uuid
def initialize
generator = UUID.new
@uuid = generator.generate
end
# Called by the producer's worker
def self.done(redis,... | true |
1769730316731ac2dc9105a3bf372fe0c1a7c0a8 | Ruby | abrennec/sose20_mc | /code/ruby_language_nutshell/25_errors.rb | UTF-8 | 850 | 4.1875 | 4 | [] | no_license |
lucky_nums = [4, 8, 15, 16, 23, 24]
#lucky_nums["dogs"]
begin
lucky_nums["dogs"]
num = 10 / 0
rescue => exception
puts "Errors" # catches any error that gets thrown
end
# to specify specific error blocks for specific exceptions
begin
lucky_nums["dogs"]
num = 10 / 0
rescue ZeroDivisionError # t... | true |
cb31380b4b2d000ef72b11f2622c707c0b21d71c | Ruby | jerryzlau/algorithms | /hackerrank/ransom_note.rb | UTF-8 | 288 | 3.359375 | 3 | [] | no_license | def ransom_note(magazine,ransom)
m_hash = Hash.new(0)
r_hash = Hash.new(0)
magazine.each {|word| m_hash[word] += 1}
ransom.each {|word| r_hash[word] += 1}
flag = 'Yes'
r_hash.each do |word, count|
if m_hash[word] < count
flag = 'No'
end
end
flag
end | true |
addcffedc9fb2a7068dfd545383420bf5c99a5b0 | Ruby | ajLapid718/HackerRank-30-Days-of-Code | /Day-06-Lets_Review.rb | UTF-8 | 736 | 4.09375 | 4 | [] | no_license | # Task
# Given a string, S, of length N that is indexed from 0 to N-1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line (see the Sample below for more detail).
# Sample Input:
# 2
# Hacker
# Rank
# Sample Output:
# Hce akr
# Rn ak
amount_of_test_cases = gets.to_i
STRING... | true |
cb6dfe8e45dedf39f1e75026adab574c876f0e3d | Ruby | samesystem/social_security_number | /spec/lib/social_security_number/country/dk_spec.rb | UTF-8 | 1,696 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe SocialSecurityNumber::Dk do
subject(:civil_number) { SocialSecurityNumber::Dk.new(number) }
describe '#validate' do
let(:number) { '1004932990' }
context 'when number is valid' do
it { is_expected.to be_valid }
end
context 'when number is valid with divider -... | true |
f8df3e7f3a50e77058d96e12e48e4bbe96e9536e | Ruby | timchen777/MEANstack2 | /README.rb | UTF-8 | 2,725 | 2.609375 | 3 | [
"ISC"
] | permissive | ================ MEAN stck NTU class 275=====================
1. Register
https://mlab.com/home
https://www.getpostman.com/
https://developers.facebook.com/
2. Install Node.js https://nodejs.org/en/
3 npm:
下載Node.js module或package來擴充app的功能
如:
Mongoose
Morgan:輸出HTTP request至console
body-parser:解析body
Express:幫忙建立website... | true |
68a83c73bd54adb86360b3ce6b4eda61cf00c1b7 | Ruby | Varunram/AlgoStuff | /codeforces/384-2/joinarr.rb | UTF-8 | 207 | 2.890625 | 3 | [] | no_license | n, k = gets.chomp.split(" ").map(&:to_i)
a = Array.new
a.insert(a.length, 1)
if n>1
for i in 2..n
b = a
a.insert(a.length, *b)
a.insert((a.length+1)/2, i)
end
puts a[k-1]
else
puts 1
end
| true |
8ec147b00762b8e1438e0f0d64a71be958d3cfb6 | Ruby | PShoe/warmups | /sept20.rb | UTF-8 | 734 | 3.578125 | 4 | [] | no_license | # Lunch Orders
#
require 'pry'
add_another_name = ""
orders = {}
until add_another_name == "n" do
puts "Name for order: "
name = gets.chomp
orders[name] = {}
orders[name][:items] = []
add_another_item = ""
until add_another_item == "n" do
puts "#{ name } wants to order: "
item = gets.chomp
ord... | true |
3864bf1b66492805eeebe7744d851dbed7eb99d8 | Ruby | Graciexia/Eight-Queens-problem | /eight_queens.rb | UTF-8 | 563 | 3.75 | 4 | [] | no_license | # previous version
COL = 0
ROW = 1
def show_queens(queens)
(0..7).each do |row|
(0..7).each do |col|
if queens.include? ([col,row])
print ' Q'
else
print ' .'
end
end
print "\n"
end
print "\n"
end
def in_line?(queens)
(0..6).each do |i|
((i+1)..7).each do |... | true |
1ff668eeb1b6004bc62c4ef2ea3bfac4b3e9505f | Ruby | jisraelsen/orm | /lib/extensions.rb | UTF-8 | 136 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | Object.class_eval do
def to_boolean
return [true, "true", 1, "1"].include?(self.class == String ? self.downcase : self)
end
end
| true |
71e8cd06aa2f81f571a1b29eacae3790c314a459 | Ruby | bassnode/liner_notes | /Liner Notes.app/lib/string.rb | UTF-8 | 131 | 3.03125 | 3 | [
"MIT"
] | permissive | class String
def titleize
self.split(' ').
map{ |part| part[0,1] = part[0,1].upcase; part }.
join(' ')
end
end
| true |
4372dc4948266aa5c2f4a66b9043f462b7f88941 | Ruby | solo123/tv_website | /app/models/type_text.rb | UTF-8 | 712 | 3.078125 | 3 | [] | no_license | class TypeText
include Singleton
def initialize
@tts = InputType.all
end
def get_text(type_name, type_value)
return '' unless type_value
tt = @tts.detect{|s| s.type_name == type_name.to_s && s.type_value == type_value.to_s}
if tt
tt.type_text
else
type_value
e... | true |
bebba93529c18703c01e8bdd8398052d39981078 | Ruby | kariounayoub/batch-439 | /01-Ruby/05-Regular-Expressions/Reboot1/calculator/interface.rb | UTF-8 | 1,188 | 4.09375 | 4 | [] | no_license | require_relative 'calculator'
def do_a_calcul
# afficher la phrase :"Enter a first number" (puts)
puts "> Enter a first number:"
print '> '
# on stock un nombre dans `first_number` (gets.chomp) (attention un nombre c'est un integer :-)
first_number = gets.chomp.to_i
# afficher la deuxieme phrase
puts "... | true |
9440a49c1bc946e803f01219a8c1e5d272c679ce | Ruby | jimm/patchmaster | /test/sorted_song_list_test.rb | UTF-8 | 517 | 2.625 | 3 | [] | no_license | require 'test_helper'
class SortedSongListTest < Test::Unit::TestCase
def test_sorting
ssl = PM::SortedSongList.new('')
%w(c a b).each { |name| ssl << PM::Song.new(name) }
%w(a b c).each_with_index { |name, i| assert_equal name, ssl.songs[i].name }
end
def test_pm_sorting
ssl = PM::SortedSongLi... | true |
7c11cc92a3be28c41eb7bf71541f5b16e911796d | Ruby | ZeeCoder/vk-elso-epizod | /game/Scripts/Window_ShopCommand.rb | UTF-8 | 1,567 | 3.09375 | 3 | [] | no_license | #==============================================================================
# ■ Window_ShopCommand
#------------------------------------------------------------------------------
# ショップ画面で、用件を選択するウィンドウです。
#==============================================================================
class Window_ShopComman... | true |
2950c04fb928d135a40c39a1cf81edc39899807c | Ruby | Hsiu-YiLin/ironhack | /week04/day19/timetrackerv3/db/seeds.rb | UTF-8 | 707 | 2.6875 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
3e7eb1bb117661cdd8d2a2e00768d52863285e5d | Ruby | dawnmiceli100/cipher | /cipher.rb | UTF-8 | 1,826 | 3.609375 | 4 | [] | no_license | class Cipher
attr_reader :key
ALPHABET = ("abcdefghijklmnopqrstuvwxyz")
def initialize(key=nil)
if key.nil?
generate_random_key
elsif key == ""
raise(ArgumentError)
else
key.each_char do |char|
if (char == char.upcase) || (char == " ") || ("0123456789".include? char)
... | true |
d99edc5f89058aaa73a8bc9b125c0c833a203c87 | Ruby | cjkula/cipher-lang | /spec/js_helper.rb | UTF-8 | 714 | 2.53125 | 3 | [] | no_license | Capybara.javascript_driver = :webkit
Capybara.default_driver = Capybara.javascript_driver
module JS
# used to contain helper classes that wrap JavaScript objects and provide a layer of
# abstraction against the language spec. Contained classes defined in helper files.
end
class JS::Base
def var
@var ||= 'w... | true |
29a2a921501fcb89370c77f08d20b32dc1ddccb1 | Ruby | kssajith/monopoly_game | /lib/game.rb | UTF-8 | 2,278 | 3.71875 | 4 | [] | no_license | class Game
def initialize(board, players)
@board = board
@players = players
end
def play
loop do
@players.each do |player|
dice_value = throw_dice
print "Player: #{player.id} Dice value: #{dice_value}\n"
@board.move(dice_value, player)
break if @board.last_cell_... | true |
ba97ff8dd1a6fe08e8822d2a2668a66c1eceab17 | Ruby | twlevelup/driver-green-and-lean | /lib/car.rb | UTF-8 | 1,917 | 3.609375 | 4 | [] | no_license | require_relative 'OutsideGridException'
require_relative 'InvalidCommandException'
require_relative 'grid'
class Car
attr_reader :x, :y, :orientation
def initialize(x, y, orientation)
if ![:north, :east, :south, :west].include?(orientation)
raise ArgumentError, 'Invalid orientation.'
end
validate_posi... | true |
73e280d087472d5e4f43b68f0eb69fc8e7d0b0f0 | Ruby | DouglasAllen/code-Metaprogramming_Ruby | /raw-code/PART_II_Metaprogramming_in_Rails/gems/builder-2.1.2/test/preload.rb | UTF-8 | 1,102 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
#---
# Excerpted from "Metaprogramming Ruby: Program Like the Ruby Pros",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that t... | true |
03ac6019f43f14d7af699812d0d089e008e36b2f | Ruby | antonzaharia/key-for-min-value-onl01-seng-pt-012220 | /key_for_min.rb | UTF-8 | 613 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
if name_hash.empty?
return nil
else
array = []
name_hash.each do |keys, value|
array << value
end
result = []
if array[0] < array[1] && array[... | true |
37d7bfb98abceef43d0d84ec716d80566c2b6527 | Ruby | JulianNicholls/ParserAndLexer | /spec/parser_spec.rb | UTF-8 | 8,273 | 3.390625 | 3 | [] | no_license | require_relative '../parser.rb'
require 'spec_helper.rb'
# Parser that allow access to its variables
class Parser
attr_reader :variables
end
describe Parser do
before :all do
@parser = Parser.new
end
describe 'Emptyness' do
it 'should not be allowed in .do_program' do
expect { @parser.do_progra... | true |
269465c8187fd4227effb81c662120639e0ca784 | Ruby | mu0s7afa/english-script | /test/unit/loop_test.rb | UTF-8 | 2,511 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
$use_tree=false
# $use_tree=true
require_relative '../parser_test_helper'
class LoopTest < ParserBaseTest
include ParserTestHelper
def _test_forever # OK ;{TRUST ME;}
init 'beep forever'
loops
parse 'beep forever' # OK ;{TRUST ME;}
end
def test_while_retur... | true |
d08e4e0c2cff4accf9b6d8b7a33bd9ff96322e1e | Ruby | NickSpangler/school-domain-onl01-seng-ft-072720 | /lib/school.rb | UTF-8 | 497 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
def initialize(name)
@name= name
@roster= {}
end
def roster
@roster
end
def add_student(name, grade)
if @roster[grade]
@roster[grade] << name
else
@roster[grade] = []
@roster[grade] << name
end
en... | true |
e7e924ff2679fa6a2bb82e698400e6971da83e6e | Ruby | ardama/LoLCritic | /app/models/flag.rb | UTF-8 | 991 | 3.015625 | 3 | [] | no_license | class Flag < ActiveRecord::Base
attr_accessible :body, :rawtime, :review_id, :time, :user_id, :minute, :second
belongs_to :review
belongs_to :user
# Converts raw input of time (string) into seconds (integer)
def convert_to_seconds()
regex = /(\d{1,2}):(\d{2})/
match = regex.match(self.rawtime)
minu... | true |
179d54af4e59ec4f962c758ef8c77c495a477369 | Ruby | sousou11190/tddworkshop | /fizzbuzz/fizzbuzz_test.rb | UTF-8 | 1,434 | 3.1875 | 3 | [] | no_license | # coding: utf-8
require 'test/unit'
require "./fizzbuzz"
class FizzBuzzTest < Test::Unit::TestCase
def setup
super
# 前準備
@fizzbuzz = FizzBuzz.new()
end
sub_test_case "その他の数の場合は文字列にして返す" do
def test_1を渡すと文字列1を返す
# 実行 & 検証
assert_equal("1", @fizzbuzz.convert(1))
end
def t... | true |
6023e97419b510267460c12c9b4543c97242ee62 | Ruby | paolov1928/deli-counter-ruby-apply-000 | /deli_counter.rb | UTF-8 | 1,492 | 4.46875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def line(input)
if input == []
puts "The line is currently empty."
else
puts "The line is currently: "+input.map.with_index { |person,index| "#{index+1}. #{person} " } .join("") .rstrip
end
end
#. Build a method that a new customer will use when entering the deli. The `take_a_num... | true |
8b56034897416c961104068b6c6204e0aed20bc4 | Ruby | jamis/sqlite-ruby | /test/tc_database.rb | UTF-8 | 9,576 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | $:.unshift "lib"
require 'sqlite'
require 'test/unit'
class TC_Database < Test::Unit::TestCase
def setup
@db = SQLite::Database.open( "db/fixtures.db" )
end
def teardown
@db.close
end
def test_constants
assert_equal "constant", defined?( SQLite::Version::MAJOR )
assert_equal "constant", d... | true |
e38d1e58c408fcea2dc3882bdd544c888a486025 | Ruby | Koyirox/s3_desafio_1estructurasDeControl | /2_Ciclos_Iterativos/2.1.rb | UTF-8 | 177 | 3.34375 | 3 | [] | no_license | =begin
2.1
En el siguiente código reemplaza la instrucción 'for' por 'times'.
for i in 1..10 do
puts i
end
=end
10.times do |i|
i+=1
puts i
end
| true |
f77457b10cabb0f37bfe65526ae0124f258e6905 | Ruby | Maheshkumar-novice/Hangman | /lib/game.rb | UTF-8 | 3,948 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative 'file-handler'
require_relative 'user'
require_relative 'word'
require_relative 'guess'
require_relative 'modules/game-output'
require_relative 'modules/print-hangman'
require 'yaml'
# Class Game - Game Driver & Operations
class Game
include GameOut... | true |
c82b2bc68bfb30e49f6a75dafceea8d433b49e87 | Ruby | Vidreven/rubitcointools | /lib/transaction.rb | UTF-8 | 9,435 | 2.796875 | 3 | [
"MIT"
] | permissive | require_relative 'specials'
require_relative 'hashes'
require_relative 'ecdsa'
require_relative 'scripts'
class Transaction
def initialize
@sp = Specials.new
@h = Hashes.new
@dsa = ECDSA.new
@k = Keys.new
@sc = Scripts.new
end
def deserialize(tx)
txcpy = tx.clone
obj = {ins: [], out... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.