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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ba99006fbd8c9c9d457b3dcfd6d7cde4ac4b0643 | Ruby | davekessener/V80 | /assembler/s.rb | UTF-8 | 4,788 | 2.546875 | 3 | [] | no_license | require_relative 'tokenize'
require_relative 'parser'
module V80
class Assembler
OPS = {
'+' => ->(a, b) { a + b },
'-' => ->(a, b) { a - b },
'*' => ->(a, b) { a * b },
'/' => ->(a, b) { a / b },
'<<' => ->(a, b) { a << b },
'>>' => ->(a, b) { a >> b }
}
def initialize
@lineno = 0
@lin... | true |
177d8c4f1fe90c1b8fa043e59b014a6be138a8a1 | Ruby | adr5240/LongboardStore | /app/models/order.rb | UTF-8 | 1,189 | 2.703125 | 3 | [] | no_license | # == Schema Information
#
# Table name: orders
#
# id :integer not null, primary key
# user_id :integer
# subtotal :integer not null
# tax :integer not null
# shipping :integer not null
# total :integer not null
... | true |
bd82dfaedc364ee6ab3796acb6570c7a8deaac75 | Ruby | Htunny/oystercards_v2 | /lib/oystercard.rb | UTF-8 | 779 | 3.40625 | 3 | [] | no_license | require_relative 'station'
require_relative 'journey'
class Oystercard
attr_reader :balance, :in_journey, :history
MAXIMUM_BALANCE = 90
FARE = 2.50
def initialize
@balance = 0
@in_journey = false
@history = []
end
def in_journey?
@in_journey
end
def top_up(amount)
fail "Maximum... | true |
61c307d6f99227aab59de9853bc3fc00597885a9 | Ruby | useruby/hnbot | /lib/setting.rb | UTF-8 | 1,106 | 2.765625 | 3 | [] | no_license | # A property-value store
class Setting
include MongoMapper::Document
key :name, String, :required => true
key :value, String
key :ptyp, String
def self.setval(name, value)
name = (caller[1] =~ /`([^']*)'/ and $1) if name == :method
kv = {:value => value.to_s, :ptyp => value.class.to_s}
prop =... | true |
91e5429060e4730e6e9ef3aff328177896a280dc | Ruby | Lycoris/Project-Euler | /011-020/019.rb | UTF-8 | 241 | 3.453125 | 3 | [] | no_license | # http://projecteuler.net/problem=19
#
#
require 'date'
def counting_sundays
a = 0
i = Date.new(1900, 12, 1)
1200.times {|k|
i = i >> 1
if i.sunday? == true then
a += 1
end
}
return a
end
puts "Answer: #{counting_sundays}"
| true |
52f80b2064e1462231a79133c577b8507fcd53c0 | Ruby | cielavenir/procon | /atcoder/tyama_atcoderAGC009C.rb | UTF-8 | 118 | 3.015625 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
x,y=gets.split.map &:to_i;p [[x,y,0],[-x,y,1],[x,-y,1],[-x,-y,2]].map{|a,b,c|a<=b ? b-a+c : 1e10}.min
| true |
45f5472fce1c284cb1c3bda149a96f6ca75f56a6 | Ruby | hwanderlust/cartoon-collections-dumbo-web-051418 | /cartoon_collections.rb | UTF-8 | 444 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(array)
array.each_with_index do |obj,i|
puts "#{i+1}. #{obj}"
end
end
def summon_captain_planet(array)
array.map! do |x|
x.capitalize+"!"
end
array
end
def long_planeteer_calls(array)
array.any? do |call|
call.length > 4
end
end
def find_the_cheese(cheese_array)
c... | true |
7054e0b68d31aff09df48ff1cfdc8779b9051824 | Ruby | smarchante1/hotel | /spec/reservation_manager_spec.rb | UTF-8 | 4,825 | 3.078125 | 3 | [] | no_license | require_relative 'spec_helper.rb'
require 'date'
describe "Reservation Manager" do
before do
@frontdesk = Hotel::ReservationManager.new
end
it "should create an instance of the reservation Manager" do
expect(@frontdesk).must_be_instance_of Hotel::ReservationManager
end
it "displays all available ... | true |
fbecc4f636dddf167fbf78d166a8bdd2a631f0e4 | Ruby | alphonsotran/phase-0-tracks | /ruby/puppy_methods.rb | UTF-8 | 831 | 4.3125 | 4 | [] | no_license | class Puppy
def fetch(toy)
puts "I brought back the #{toy}!"
toy
end
def speak(num)
counter = 0
while counter < num
puts "woof"
counter += 1
end
end
def roll_over
puts "*Rolls over*"
end
def dog_years(human_yrs)
human_yrs * 7
end
def pee_itself
puts "*We... | true |
bfa52ca7a9b8679b840f30007fd1c17a3629d8e6 | Ruby | dantecrovetto/ciclos | /desafios/cuenta_regresiva.rb | UTF-8 | 168 | 3.03125 | 3 | [] | no_license | cuenta_regresiva = ARGV[0].to_i
puts "Contando desde #{cuenta_regresiva}..."
i = 0
while(i <= cuenta_regresiva)
puts cuenta_regresiva
cuenta_regresiva -= 1
end
| true |
c1071a47c7b4385b80a88fa51cc8ed82eda822ac | Ruby | joethecoderr/code_challenge | /PORO/models/visits.rb | UTF-8 | 1,275 | 2.546875 | 3 | [] | no_license | require 'active_record'
require 'yaml'
require 'httparty'
dbconfig = YAML::load_file(File.join(__dir__, '../config/database.yml'))["development"]
ActiveRecord::Base.establish_connection(adapter: "mysql2", :host => dbconfig['hostname'], :username => dbconfig['username'], :password => dbconfig['password'], :databas... | true |
e1eaf047ea8afe60b470747966feba715a479dd9 | Ruby | sarynm12/backend_prework | /day_5/hashes.rb | UTF-8 | 1,952 | 4.1875 | 4 | [] | no_license | # create a mapping of state to abbreviation
states = {
'Orgeon' => 'OR',
'Florida' => 'FL',
'California' => 'CA',
'New York' => 'NY',
'Michigan' => 'MI'
}
# create a basic set of states and some cities in them
cities = {
'CA' => 'San Francisco',
'MI' => 'Detroit',
'FL' => 'Jacksonville'
}
# add some m... | true |
c0853de535a2d3c20cfc36da140fc3a1aeb9d6b7 | Ruby | pheen/codewars | /src/4kyu/hash.flattened_keys.rb | UTF-8 | 491 | 3.09375 | 3 | [] | no_license | class Hash
def flattened_keys(parent_key = nil, result = {})
self.each do |key, value|
if value.is_a?(Hash)
inherited_key = strymbol(parent_key, key)
value.flattened_keys(inherited_key, result)
else
result[strymbol(parent_key, key)] = value
end
end
result
end
... | true |
19507f45b382aed61d32256a420a9ce437150d26 | Ruby | murohi-siyabako/furima-32110 | /spec/models/user_spec.rb | UTF-8 | 4,424 | 2.625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe '会員情報入力' do
context '新規登録がうまくいく時' do
it "nicknameとemail、passwordとpassword_confirmationが存在すれば登録できる" do
expect(@user).to be_valid
end
end
context '新規登録がうまくいかない時' do... | true |
bd06b38d20ef7d53141b69941c96746d3e92f010 | Ruby | gustavoguimaraes/todos | /todo_31/palindromes.rb | UTF-8 | 769 | 4.03125 | 4 | [] | no_license | # A palindrome is a string that is written the same forward as it is in reverse. Write a method to return the longest palindrome in a given string.
def longest_palindrome(str)
stage = []
pali = []
counter = 0
until counter == str.length
temp = []
str.split(//)[counter..-1].each do |char|
... | true |
46d2fae4865bf18c84e03cb226d7cd679489b3dc | Ruby | jltackett2/RubyBasicEx | /ReadingDocs/exercises.rb | UTF-8 | 1,048 | 3.859375 | 4 | [] | no_license | #Reading Documentation Exercises
#Where to find docs?
# -- you find Ruby documentation at Ruby-Doc.org
#where can you find the while loop in the docs?
# -- https://docs.ruby-lang.org/en/2.6.0/syntax/control_expressions_rdoc.html#label-while+Loop
# -- its found under control expressions in the core library
#What is t... | true |
f0a462941de45f0381ab7b0827735ccadd72209a | Ruby | Linus-Cson-Ferdinand-Bostrom/Uppgifter | /25_first_character/lib/first_character.rb | UTF-8 | 71 | 2.875 | 3 | [] | no_license | def first_character (blah)
result = blah[0]
return result
end
| true |
bad2d2e66c6374bb128884c5ead745b001f6039b | Ruby | yongchol/rubyOnRails | /ruby/parentheses.rb | UTF-8 | 484 | 3.875 | 4 | [] | no_license | #encoding=utf-8
def par_check(str)
par_array = str.split('')
count = 0
par_array.each do |p|
if p == "("
count += 1
elsif p == ")"
count -= 1
end
if count < 0
break
end
end
if count == 0
return true
else
return false
end
end
while t... | true |
d99d2e8044d94bfd5ddbd780fe07c9f0b4c32af2 | Ruby | jamez01/em-irc | /lib/em-irc/commands.rb | UTF-8 | 12,969 | 2.75 | 3 | [
"MIT"
] | permissive | module EventMachine
module IRC
# Client commands
# @see http://tools.ietf.org/html/rfc2812 RFC 2812
module Commands
# Set connection password
# @see http://tools.ietf.org/html/rfc2812#section-3.1.1 3.1.1 Password message
def pass(password)
send_data("PASS #{password}")
end
... | true |
9a61f6c13680296ab8be7c41e71de3e25f47d8f9 | Ruby | jsmmr/ruby_table_structure | /lib/table_structure/utils.rb | UTF-8 | 777 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module TableStructure
module Utils
class Proc < ::Proc
attr_reader :options
def initialize(**options, &block)
@options = options
super(&block)
end
end
class TypedProc < Proc
def initialize(types:, **options, &block)
@types = ... | true |
19e206f7dd8c620e7f1b90bda6e04decfae0bc17 | Ruby | maximus12793/random_ruby | /tester_1.rb | UTF-8 | 522 | 3.25 | 3 | [] | no_license | # number of trials
t = gets.chomp.to_i
n = []
t.times do |i|
n[i] = gets.chomp.split('').map(&:to_i).to_a
end
puts "#{n}"
a = n[0].length
nct = 0
@place = 1
# n[0..4].reverse!
# puts "place 1 #{n[1].reverse!}"
# puts "size: #{n[1].size}"
# puts "place 2: #{n[1][2]}, place 0-3: #{n[0][0..3].reverse!}"
puts "#{n[0]... | true |
ecc6b0fe3ecd6f9ea3e2f137ad385f0c254f69fc | Ruby | Mloweedgar/eloquent_ruby_code | /03/ex_each_index_word_len.rb | UTF-8 | 259 | 2.84375 | 3 | [] | no_license | require '../code/doc3'
class Document
# A bit more idomatic, but not much ##(main
def average_word_length
total = 0.0
words.each_index { |i| total += words[i].size }
total / words.size
end ##main)
end
| true |
51cfbc53674f0becbf16eb185865d52b28d5a804 | Ruby | jratanadawong/robot_battle | /lib/item.rb | UTF-8 | 154 | 3.265625 | 3 | [] | no_license | class Item
attr_reader :name, :weight, :damage
def initialize(name, weight, damage=0)
@name = name
@weight = weight
@damage = damage
end
end | true |
8dbe46fd48af50974a6d4fa56c9091a2dc76b5c5 | Ruby | knoxknox/ce250-course | /materials/12/pgm12_10.rb | UTF-8 | 1,378 | 3.234375 | 3 | [] | no_license | # 10
class MultisetAsArray < Multiset
def initialize(n)
super
@array = Array.new(@universeSize)
for item in 0 ... @universeSize
@array[item] = 0
end
end
attr_accessor :array
public :array
protected :array=
end
# 11
class MultisetAsArray < Multiset
def insert(item)
@array[item]... | true |
d8649130a7300b52f5b4809e4ce05ca2dc9f7372 | Ruby | FGalvao77/myCodesInRuby | /Aula_11_rubyAvancado_II.rb | UTF-8 | 9,188 | 3.953125 | 4 | [] | no_license | # Ruby Avançado II
# Assunto da aula
# Nesta segunda parte da aula de conteúdos avançados na linguagem Ruby, você aprenderá a
# utilizar expressões regulares, realizar funções matemáticas, trabalhar com data e hora,
# tratar chamadas de métodos que não existem, o que é a variável self e outros tipos de
# métodos ... | true |
14b8a384d775545868fb8b570e24dbc4c43d9b14 | Ruby | muffinista/eliza | /script.rb | UTF-8 | 6,405 | 2.890625 | 3 | [] | no_license | #
# this code is modified from https://github.com/andwi/Eliza
#
# This implementation of the Eliza chatterbot is inspired by
# Charles Hayden's Java code at http://www.chayden.net/eliza/Eliza.html
class Script
attr_accessor :debug_print
def initialize(source)
if source.kind_of? IO
parse source
els... | true |
794d8623f68de125c0e008f0146f50a839864a5b | Ruby | karsonkalt/onrotation_server | /db/seeds/03_bookmarks.rb | UTF-8 | 882 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative '02_tracklists'
def create_bookmarked_tracks
puts "Generating BookmarkedTracks\n"
User.all.each do |user|
rand(3..4).times do
loop do
@track = Track.find_random
break if @track.identified?
end
bookmark = BookmarkedT... | true |
dbd4950dfa3185ccfa04fefdebcfc4b15ecbe1eb | Ruby | Will-Bath/OysterCard | /lib/journey.rb | UTF-8 | 649 | 3.34375 | 3 | [] | no_license | class Journey
attr_accessor :entry_station, :exit_station
MIN_CHARGE = 1
MAX_CHARGE = 6
def initialize
@entry_station
@exit_station
@min_fare = MIN_CHARGE
@max_fare = MAX_CHARGE
end
def fare
if @entry_station == nil || @exit_station == nil
return @max_fare
elsif @entry_stati... | true |
3b2f6cffb50d24975d299b1b086d801a36cdbd4c | Ruby | pbrisbin/rabbit | /lib/threaded-each.rb | UTF-8 | 519 | 3.515625 | 4 | [] | no_license | module ThreadedEach
# yields to block for each item in a separate thread, waits for all
# threads to end and returns an array of results. order is
# non-deterministic by nature.
def threaded_each(&block)
results = []
spawned = []
self.each do |x|
th = Thread.new do
results << block.ca... | true |
ccf89d38ee965e9c0f047abb584ec9b2d6b2dfa1 | Ruby | southpawgeek/perlweeklychallenge-club | /challenge-091/roger-bell-west/ruby/ch-1.rb | UTF-8 | 414 | 3.125 | 3 | [] | no_license | #! /usr/bin/ruby
def cn(n)
j=n.scan(/((.)\2*)/)
out=Array.new
j.each do |x|
out.push(x[0].length)
out.push(x[1])
end
return out.join
end
require 'test/unit'
class TestCn < Test::Unit::TestCase
def test_ex1
assert_equal('21321314',cn('1122234'))
end
def test_ex2
assert_equal('1233241... | true |
fd59d203d2a112dd9b62af2faa7440cec325fcf0 | Ruby | reteshbajaj/inject-challenge | /spec/rinject_spec.rb | UTF-8 | 872 | 2.84375 | 3 | [] | no_license | require 'rinject'
describe 'Inject method:' do
let(:arg) { 10 }
let(:array) {[1,2,3,4]}
context 'Retesh Injects' do
it 'takes an initial argument' do
expect(array.retesh_inject(arg) { |a,b| a }).to eq array.inject(arg) { |a,b| a }
end
it 'defaults to first element of the collection' do
... | true |
934ec730c023dc9dbb508e0f391885f727fa277f | Ruby | DimitryLenchevsky/Rubycourses | /lesson1/ideal_weight.rb | UTF-8 | 311 | 3.515625 | 4 | [] | no_license | puts "Введите ваше имя:"
name = gets.chomp.capitalize!
puts "Введите ваш рост:"
height = gets.chomp.to_i
ideal_weight = height - 110
if ideal_weight < 0
puts "Ваш вес уже оптимальный"
else
puts "#{name}, ваш идеальный вес #{ideal_weight}."
end | true |
d7fe0532830cb21535f0068de9fbdfba6d96cd33 | Ruby | matthew-deluge/chess | /lib/display.rb | UTF-8 | 1,116 | 3.71875 | 4 | [] | no_license | # frozen_string_literal: true
# Display Module for Chess Game
module Display
def print_board(board)
(8).downto(1) do |row_number|
row = []
board.node_array.reverse.each { |square| row.push(square) if square.coord[1] == row_number }
print_row(row, row_number)
end
puts " 1 2 3 4 5 6... | true |
8926f8bbe8ce695538e042f169aa81d357e6c8db | Ruby | Arrows78/sprint-notifier | /main.rb | UTF-8 | 8,290 | 2.796875 | 3 | [] | no_license | require "erb"
require "date"
require "pathname"
$tickets_list = []
email_body = {
title: "Career Services Sprint Update",
sprint_end_date: "#{(Time.now).strftime("%B")} #{Time.now.day}, #{Time.now.year}",
edito: "“Hi everybody,<br>This week, we'll have Aurélie, Erik, Florent, Renaud, Sacha and Vlatka work... | true |
8db7c59ec4766127c514dc9fd86440a15f73103f | Ruby | taracdia/learningRuby | /returns.rb | UTF-8 | 57 | 2.609375 | 3 | [] | no_license | def cube(num)
return num ** 3, 70
5
end
puts cube(3)
| true |
409d669ca8e346eb85727d09b9bf2eb670dcc73b | Ruby | TheresaCampbell/math_game | /game.rb | UTF-8 | 931 | 3.796875 | 4 | [] | no_license | require './game.rb'
require './player.rb'
require './question.rb'
require './turn.rb'
require './turn_manager.rb'
class Game
def initialize
@player1 = Player.new("Player 1")
@player2 = Player.new("Player 2")
@players = [@player1, @player2]
@turn_manager = Turn_Manager.new(@players)
end
def game... | true |
0d40ae76bf5ee0cbad43f80babdfb0f3f4c8f846 | Ruby | scenzhang/aaprep | /rspec-2/lib/00_silly_blocks.rb | UTF-8 | 197 | 3.1875 | 3 | [] | no_license | def reverser(&prc)
strs = prc.call
strs = strs.split(" ")
strs.map(&:reverse).join(" ")
end
def adder(val=1, &prc)
prc.call + val
end
def repeater(n = 1, &prc)
n.times { prc.call }
end
| true |
23496109dd1ac035b51540750a89012064f2f122 | Ruby | sallypikachu/Bounding_Box | /lib/bounding_area.rb | UTF-8 | 218 | 3.015625 | 3 | [] | no_license | require_relative 'bounding_box'
class BoundingArea
attr_reader :boxes
def initialize(boxes)
@boxes = boxes
end
def boxes_contain_point? (x, y)
boxes.any? { |box| box.contains_point?(x, y) }
end
end
| true |
201c614ad2235f7af823fb8407f890d3340bc37f | Ruby | prabhakarbattula/learning | /triangle_display.rb | UTF-8 | 639 | 4 | 4 | [] | no_license | system("clear")
puts "Give a number to draw a triangle with that many stars?"
triangle = gets.to_i
puts "Type U for upright triangle and I for inverted triangle"
choice = gets.chomp
angle = triangle
system("clear")
while choice != "U" and choice != "u" and choice != "I" and choice != "i" do
system("clear")
put... | true |
eca59b4ebae96b37ea92c340bd035ab866a6714b | Ruby | rsupak/appacademy2020 | /SoftwareEngineeringFundamentals/bootcamp_project/lib/bootcamp.rb | UTF-8 | 939 | 3.640625 | 4 | [] | no_license | class Bootcamp
attr_accessor :name, :slogan, :teachers, :students
def initialize(name, slogan, student_capacity)
@name = name
@slogan = slogan
@student_capacity = student_capacity
@teachers = []
@students = []
@grades = Hash.new { |h, k| h[k] = [] }
end
def hire(teacher)
@teachers ... | true |
8fd13d5fad4e40b00cda018623742a9af754dd61 | Ruby | RodriguezLucha/week_repos | /W2D3/poker/spec/hand_spec.rb | UTF-8 | 502 | 3.03125 | 3 | [] | no_license | require 'hand'
RSpec.describe Hand do
subject(:hand) {Hand.new([:card1, :card2, :card3, :card4, :card5])}
let(:card1) {Card.new(1, :heart)}
let(:card2) {Card.new(2, :club)}
let(:card3) {Card.new(3, :diamond)}
let(:card4) {Card.new(4, :heart)}
let(:card5) {Card.new(5, :spade)}
describe "#initialize"... | true |
66556b247f5b77fd6311e24cfbb7d7256e31d8da | Ruby | mcat56/koroibos2 | /app/serializers/olympian_serializer.rb | UTF-8 | 288 | 2.796875 | 3 | [] | no_license | class OlympianSerializer
attr_reader :name, :age, :team, :sport, :total_medals_won
def initialize(olympian)
@name = olympian.name
@age = olympian.age
@team = olympian.team.country
@sport = olympian.sport.name
@total_medals_won = olympian.total_medals
end
end
| true |
f08dc9c7387cec3a4f3156ae34133d70bcf9e812 | Ruby | hayatosa/0215sample | /0204git_hukushu.rb | UTF-8 | 330 | 3.328125 | 3 | [] | no_license | skills = ["pass","heading","sliding"]
skills.each do |skill|
puts "私の得意技は#{skill}です"
puts "----------------------"
end
skills
score = gets.chomp.to_i
if score >= 3
puts "私のチームの勝ちです"
elsif score > 0 && score <= 2
puts "いい試合をしました"
else
puts "残念でした"
end
| true |
298e0dd26891b796fbc8531cf2b4f2cd77ddea20 | Ruby | trojek/project-euler-problems | /29.rb | UTF-8 | 315 | 3.609375 | 4 | [] | no_license | # Euler project 29
class Problem29
def generate_combinations
array = []
a_limit = 100
b_limit = 100
for i in 2..a_limit
for j in 2..b_limit
array.push(i**j)
end
end
array = array.uniq
puts array.size
end
end
p29 = Problem29.new
puts p29.generate_combinations
| true |
05c827ff857efcdf0bd25b61afe5e9fff86c963a | Ruby | Taylor-Williams/triangle-classification-v-000 | /lib/triangle.rb | UTF-8 | 635 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Triangle
# triangle code
attr_accessor :angles, :kind
def initialize(one, two, three)
@angles = [one, two, three].sort
if @angles[0] <= 0 || @angles[1] <= 0 || @angles[2] <= 0 || @angles[2] >= @angles[1] + @angles[0]
raise TriangleError
elsif @angles[0] == @angles[1] && @angles[0] == @angl... | true |
8e6f5869c02b9d5e76f6517177fabbacaabf4bf4 | Ruby | ftvision/LeetCode | /ruby/Q118.rb | UTF-8 | 261 | 3.265625 | 3 | [
"MIT"
] | permissive | # @param {Integer} num_rows
# @return {Integer[][]}
def generate(num_rows)
ans = []
tmp = [1]
num_rows.times {|x|
ans = ans + [tmp]
tmp += [1]
x.downto(1) {|y|
tmp[y] += tmp[y-1]
}
}
return ans
end | true |
d3b727b4de07181893fb88d8c66d440674e6b738 | Ruby | TransSpeciesMafia/ledremote | /ruby/glimmer.rb | UTF-8 | 572 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
require './lib/setup'
wait_for_boot
C=[80,255,0]
PINK = [0, 255, 59]
GOLD = [255, 80, 0]
class Glimmer < Effect
def initialize app
@app = app
@multiplier = 0.2
end
def call
pixels = @app.call
@multiplier -= 0.0001
pixels = pixels.each_slice(3).each_with_index.map do |r... | true |
31782abcd7926849aaf7be1a1589c94de1caa643 | Ruby | krismac/course_notes | /week_02/weekend_homework/solution/room.rb | UTF-8 | 591 | 3.75 | 4 | [] | no_license | class Room
attr_reader :name, :songs, :guests
def initialize(name, songs)
@name = name
@songs = songs
@guests = []
end
def number_of_guests()
return @guests.length()
end
def number_of_songs()
return @songs.length()
end
def check_in_guest(guest)
@guests.push(guest)
end
d... | true |
2acdb0c200f9a555e3e912b03b14701f9c123f78 | Ruby | PhilHuangSW/Leetcode | /remove_duplicates_from_sorted_array_2.rb | UTF-8 | 2,750 | 4.15625 | 4 | [] | no_license | #################### REMOVE DUPLICATES FROM SORTED ARRAY ####################
# Given a sorted array *nums*, remove the duplicates **in-place** such that each element appears only once and returns the new length.
# Do not allocate extra space for another array, you must do this by **modifying the input array** **in-p... | true |
d5c50611ac4a4197ca1708b84d9139f7c782c3ff | Ruby | matapaska/vet_practice_booking_app | /models/owner.rb | UTF-8 | 1,548 | 3.28125 | 3 | [] | no_license | require_relative('../db/sql_runner.rb')
class Owner
attr_accessor :name, :phone, :address
attr_reader :id
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@phone = options['phone']
@address = options['address']
end
def save()
sql = "INSERT INTO owne... | true |
2e1cfae31ad996fba4a8f4c44d626beddabbedf1 | Ruby | larssbr/AI_ovinger | /Documents/UCSB_classes/papersphere-master/papersphere/app/helpers/reading_lists_helper.rb | UTF-8 | 2,240 | 2.9375 | 3 | [] | no_license | module ReadingListsHelper
OWNER = :access_owner
READWRITE = :access_readwrite
READONLY = :access_readonly
NONE = :access_none
def self.get_shared_lists(user)
groups = user.groups.all
return [] if groups.empty?
group_ids = []
groups.each do |group|
group_ids << group.id
end ... | true |
75d1ae4cf4b30b0e4b718218e7166110375916e2 | Ruby | jotkafomat/bank_tech_test | /playground_aka_feature_test.rb | UTF-8 | 725 | 3.015625 | 3 | [] | no_license | require 'date'
require_relative './lib/transaction.rb'
require_relative './lib/bank_account.rb'
require_relative './lib/deposit.rb'
require_relative './lib/withdrawal.rb'
require_relative './lib/statement.rb'
# date formatter
# date = Time.now
# p date.strftime("%d/%m/%Y")
# p date
#User_Story#1
my_new_account = BankA... | true |
41ad36c3d2b1558dc198f252098d48a612cd70d9 | Ruby | danhjoo7/school-domain-sf-web-091619 | /lib/school.rb | UTF-8 | 552 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_reader :name
attr_accessor :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(student_name,grade)
@roster[grade] = [] unless @roster.include?(grade)
@roster[grade] << student_name
end
def grade(student_grade)
... | true |
00675ed795c35c22632d95333418f0816de18798 | Ruby | slabounty/Old-Time-Banjo-Tab-List | /dbMigration/001_BanjoTabMigration.rb | UTF-8 | 1,466 | 2.609375 | 3 | [] | no_license | # dbMigration/001_BanjoTab.rb
#
# This is the "new" way to do migrations by using the Class.new form.
# It means that a new class name is not required and so there is no chance
# of creating a second class in the migration files that is the same as the
# first causing problems.
Class.new(Sequel::Migration) do
def... | true |
f1384b735e3572a4a8fcaff0c93297d0cb84b339 | Ruby | kschmit90/ruby-katas | /day1/spec/string_calculator_spec.rb | UTF-8 | 1,440 | 3.625 | 4 | [] | no_license | require_relative './spec_helper'
require_relative '../string_calculator.rb'
describe StringCalculator do
it 'should return 0 if the string is empty' do
s = ""
expect(StringCalculator.add(s)).to eql(0)
end
it 'should return the the number as an integer if only one number is in the string' do
s = ... | true |
d9a6e3f6e846bbfd29a0612209a629a5f6c9a209 | Ruby | GetsuKami-Hao/my_ruby | /program/058_method_missing.rb | UTF-8 | 423 | 2.953125 | 3 | [] | no_license | class A
@@attributes = {}
class << self
def method_missing(method_name, *params)
method_name = method_name.to_s
# p method_name # => name=
# p params
if method_name =~ /=$/
@@attributes[(method_name.sub('=',''))] = params.first
# p params.first
else
p method_name... | true |
4f3447e0d2d8cb82b0ab274e609fffb603ead873 | Ruby | NFairbairn/todo-ruby-basics-prework | /lib/ruby_basics.rb | UTF-8 | 286 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
num1 / num2
end
def assign_variable(value)
name = value
end
def argue(argument)
argument
end
def greeting(greeting, name)
end
def return_a_value
"Nice"
end
def last_evaluated_value
"expert"
end
def pizza_party(pizza = "cheese")
"#{pizza}"
end
| true |
2e02ca1080bcb464d222231aefdb2e21fc299b77 | Ruby | meganraec/ruby-objects-has-many-lab-v-000 | /lib/post.rb | UTF-8 | 296 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Post
attr_accessor :title, :author
def initialize(title)
@title = title
@author = author
end
# Returns the name of the author for the post on which the method is called; returns nil if no author is named.
def author_name
self.author ? self.author.name : nil
end
end
| true |
56566161f3b444a2651ab48f8333564fa39ffdd0 | Ruby | carden-code/black_jack | /deck.rb | UTF-8 | 748 | 3.65625 | 4 | [] | no_license | # Класс Deck(Колода карт):
# Наполняет колоду картами.
# Перемешивает колоду.
# Раздаёт карты.
class Deck
attr_reader :cards
# Создаются карты и добавляются в @cards образуя колоду из 52 карт.
def initialize
@cards = []
Card::SUITS.each do |suit|
Card::VALUES.each do |rank|
@cards << Card.n... | true |
84a4e6b689b41b4eaf60400658d687c9efd68e19 | Ruby | mailmaldi/UMBC | /Blackjack/Shoe.rb | UTF-8 | 1,373 | 4.09375 | 4 | [] | no_license | SUITE = [2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A"]
# simply *4 to get 1 full deck and *4*n to get n decks and then .shuffle a few times
class Shoe
attr_accessor :num_decks , :deck, :deck_index, :max_deck_mod , :cards
def initialize()
@num_decks = 1 # Number of card decks
@deck_index = 0 # starting i... | true |
46ed26e34f0c3159b24c48cd29ad5128e994960a | Ruby | jens-na/sketchdown | /lib/sketchdown/document.rb | UTF-8 | 1,657 | 2.84375 | 3 | [
"MIT"
] | permissive | module Sketchdown
class Document
attr_reader :input
attr_reader :options
attr_reader :figures
# Initializes a new sketch document with the given plain text
# information
#
# input - the plain text diagram which should be rendered
# options - the additional options to set or override... | true |
22dd614e38dc00b49cfe2093f6349cf52fbeb85a | Ruby | szrapnel/rachunki-tracker | /test/models/operator_postpone_test.rb | UTF-8 | 1,467 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class OperatorPostponeTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
# test "ok_to_show false" do
# now = TimeService::get_now
# puts now
# o=OperatorPostpone.new
# o.days = 7
# o.save
# puts o.created_at
# puts now > o.created_at... | true |
438d6279b79d6a98a58652e39722c238aa2f4109 | Ruby | RocHack/skedge | /spec/query/query_spec.rb | UTF-8 | 10,122 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
describe "Querying" do
include QueryingConcern
before do
@csc = Department.create(short:"CSC", name:"Computer Science")
@ant = Department.create(short:"ANT", name:"Anthropology")
@mth = Department.create(short:"MTH", name:"Mathematics")
end
def assert_query_error(text)
q... | true |
9ba5df40bcb629271810eb08e36c65bf27dc1bd6 | Ruby | carrot-u/assignments-2019 | /assignment-2-ruby/ruiqu/tiny_instacart.rb | UTF-8 | 1,085 | 3.421875 | 3 | [] | no_license | # TODO
# orders, drivers, batches, order_items, payments
# Compose a simple terminal program using one or more of the common objects from Instacart (orders, drivers, batches, order_items, payments, etc)
# Design a desired workflow. ex. The entire flow of a driver from accepting a batch to delivery
# Using the tools ... | true |
8d20c7eb74cbe6a1f748d26acf58cdafc2ef77ab | Ruby | nanma80/euler_project | /p101_125/p121/main.rb | UTF-8 | 333 | 2.84375 | 3 | [] | no_license | require '../../common'
round_count = 15
sum = 0
(0..round_count).each do |red_count|
break if red_count * 2 >= round_count
(1..round_count).to_a.combination(red_count) do |combi|
if combi.empty?
sum += 1
else
sum += combi.inject(:*)
end
end
end
p (round_count + 1).factorial / sum
# (1.... | true |
6b135da2a3283804e2e360d7b5fcb067adc2e308 | Ruby | indepat/Intro-Programming | /5_Loops and Iterators/Exercise_Loops_and_Iterators.rb | UTF-8 | 231 | 4.03125 | 4 | [] | no_license | #Use the each_with_index method to iterate
#through an array of your creation that prints
#each index and value of the array.
array = ["bob", "McIntosh", "Bruce"]
array.each_with_index {|name,index| puts "#{index + 1}. #{name}"}
| true |
32c957dc11cd976546f5f06c3e11feb842ad69d2 | Ruby | MarioRuiz/slack-smart-bot | /lib/slack/smart-bot/commands/general/share_messages.rb | UTF-8 | 3,149 | 2.609375 | 3 | [
"MIT"
] | permissive | class SlackSmartBot
#todo: reaction type not added yet since RTM doesn't support it. See if we can add it as an event
def share_messages(user, from_channel, to_channel, condition)
save_stats(__method__)
if has_access?(__method__, user)
#todo: add a @shared variable to control not to be shared more tha... | true |
7993b39a7e7560969c1e66eb28455494b3bcadbf | Ruby | tra38/algorithms-phase4 | /spec/queue_spec.rb | UTF-8 | 1,408 | 3.328125 | 3 | [
"MIT"
] | permissive | require_relative '../queue.rb'
RSpec.describe "MyQueue" do
before(:each) do
@queue = MyQueue.new
end
it "should have no value when initialized" do
expect(@queue.peel).to eq(nil)
end
it "can enqueue an element into the queue" do
@queue.enqueue("empire")
expect(@queue.peel).to eq("empire")
... | true |
ff697aea7e51eb56c49552ef637c222d83a20d1d | Ruby | ViniciusBaptista/LearningRuby | /python-brasil/EstruturaSequencial/terceiro.rb | UTF-8 | 49 | 2.5625 | 3 | [] | no_license | def sum(numero1, numero2)
numero1 + numero2
end | true |
2eee0035c6c2cdb9bea923148cf436a528ed36ea | Ruby | miguelbermudez/Daily-Phobia | /app.rb | UTF-8 | 1,558 | 2.734375 | 3 | [] | no_license | require 'CSV'
class PhobiaApp < Sinatra::Base
set :haml, :format => :html5
configure do
set :daily_phobia, { phobia: nil, phobia_descr: nil, crt: nil }
set :phobia_list, CSV.open('phobia_list.txt', 'r', col_sep: "\t").to_a.drop(1)
end
def load_phobias
print "\nLoading phobia file...\n"
cs... | true |
4e2de93d4a589b6161ab5abbeac803c4c781a574 | Ruby | soccerman1953/sample_app | /public/string_class.rb | UTF-8 | 529 | 3.859375 | 4 | [] | no_license | #!/usr/bin/env ruby
Class String
def shuffle
self.split('').shuffle
end
end
if __FILE__ == $0
puts " "
puts "The code I developed is as follows:"
puts " Class String"
puts " def shuffle"
puts " self.split('').shuffle"
puts " end"
puts " end"
puts " "
puts "I am now... | true |
26ba05f23a8007714bbcae5c41208767f5b73413 | Ruby | jasonayre/rpg_codetest | /lib/rbrpg/renderer.rb | UTF-8 | 1,768 | 3.203125 | 3 | [
"MIT"
] | permissive | require 'matrix'
require 'colored'
module Rbrpg
class Renderer
attr_reader :game
def initialize
@game_state_observer = GameStateObserver.new
@game = ::Rbrpg::Game.current
end
def screen
[
RepeatingRow.new("-"),
Row.new("- CURRENT TURN: #{'#'.yellow} #{game.current_t... | true |
d1e13dff880f7d6923f621ab7e672c922af18877 | Ruby | clemenshelm/chillbill-recognizer | /spec/calculations/currency_calculation_spec.rb | UTF-8 | 2,568 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../lib/calculations/currency_calculation'
describe CurrencyCalculation do
it 'detects currency code which appear most often in bill' do
# Missing label - needs Ft.
PriceTerm.create(
text: '9900',
left: 0.6596858638743456,
right: 0.68488219... | true |
9b705833f3dea5044e75a8f57c6b1b3497444392 | Ruby | msit18/Cape-Town | /Old Citivan App/smsdatabase.rb | UTF-8 | 14,191 | 2.578125 | 3 | [] | no_license | """
First Citivan code written by Wajeeha Ahmad and Tawanda Zimuto
"""
require 'rubygems'
require 'net/http'
require 'json'
#This is the HTTP request for CouchDB class
module Couch
class Server
def initialize(host, port, options = nil)
@host = host
@port = port
... | true |
8b118af15aeca4650a750cfac1aaeda7c2b109d3 | Ruby | hatsu38/atcoder-ruby | /abc152/a.rb | UTF-8 | 280 | 3.34375 | 3 | [] | no_license | # frozen_string_literal: true
### 例
# N
# a_1 b_1
# ...
# a_N b_N
# h,w = gets.chomp.split(' ').map(&:to_i)
# strs = h.times.map{ gets.chomp.split('') }
# problem a
# input
# 3 3
# output
# Yes
n, m = gets.chomp.split.map(&:to_i)
if n == m
puts 'Yes'
else
puts 'No'
end
| true |
7010e312143f79a66a1facfcb24deb51ce2c2084 | Ruby | timrandg/Problem_79 | /test/test_problem_79.rb | UTF-8 | 720 | 2.984375 | 3 | [] | no_license | $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
#requires all files in the lib folder
Dir.glob(File.dirname(__FILE__) + '/../lib/*'){|file| require file}
require "test/unit"
class TestParse < Test::Unit::TestCase
def test_can_parse_num_file_into_rows
data = Parse.new("../test_list.txt")
assert_equ... | true |
1b9a53876170be7d20443ee70571f9fbe92b5831 | Ruby | sugar-for-pirate-king/project-euler | /ruby/problem2.rb | UTF-8 | 680 | 3.875 | 4 | [
"MIT"
] | permissive | #
# Solution to Project Euler problem 2
# Copyright (c) Philip Lambok.
# All right reserved
#
class Problem2
def initialize; end
def execute
total_number, prev_number, next_number = 0, 1, 2
collection_number = [prev_number, next_number]
while total_number < 4_000_000
total_number = prev_number... | true |
85feac5510834b320e315f5c743ac782a1415881 | Ruby | averysmith65/launch_school | /subscription_course/rb101_rb109_small_problems/easy_1/how_many.rb | UTF-8 | 259 | 3.046875 | 3 | [] | no_license | vehicles = [
'car', 'car', 'truck', 'car', 'SUV', 'truck',
'motorcycle', 'motorcycle', 'car', 'truck'
]
def count_occurrences(array)
counts = Hash.new 0
array.each do |word|
counts[word] += 1
end
puts counts
end
count_occurrences(vehicles)
| true |
3c0692044b1a82a029284b8e347ff54c1091a471 | Ruby | rhardih/aoc | /2022/11p1.rb | UTF-8 | 12,610 | 4.1875 | 4 | [] | no_license | =begin
--- Day 11: Monkey in the Middle ---
As you finally start making your way upriver, you realize your pack is much
lighter than you remember. Just then, one of the items from your pack goes
flying overhead. Monkeys are playing Keep Away with your missing things!
To get your stuff back, you need to be able to pr... | true |
4ca1173fd725b82453b5a6ef6f286eadbf028332 | Ruby | dangerousbeans/guardian_slurper | /guardian.rb | UTF-8 | 2,449 | 2.71875 | 3 | [] | no_license |
# $: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'nowa_api'
require 'guardian-content'
require 'yaml'
# Load articles from the guardian API and put them on ingenia
CONFIG = YAML.load_file("config/apis.yml") unless defined? CONFIG
#
# Setup
#
class Guardian
def initalize
# Set A... | true |
a9d6bfec467ad9d1a64f588c1d4c02f54fda7136 | Ruby | ksk5280/exercism | /ruby/rna-transcription/rna_transcription.rb | UTF-8 | 567 | 3.09375 | 3 | [] | no_license | class Complement
VERSION = 2
def self.of_dna(nucleotide)
nucleotide.each_char do |input|
valid = "GCAT"
raise ArgumentError, "Invalid input" unless
valid.include?(input)
end
nucleotide.upcase.gsub(/[GCAT]/, "G" => "C", "C" => "G", "A" => "U", "T" => "A")
end
def self.of_rna(nucl... | true |
5086a4f4003697bb28ad9a8326f29b348c08c1ef | Ruby | JanKoszewski/Event-Reporter | /command.rb | UTF-8 | 2,140 | 3.15625 | 3 | [] | no_license | $LOAD_PATH << './'
require 'csv'
require 'elements'
require 'data_parser'
require 'help'
require 'queue'
require 'search'
module EventReporter
class Command
ALL_COMMANDS = {"load" => "loads a new csv data file. Usage is: [ load ] <file.csv>",
"help" => "shows a list of available commands. Us... | true |
a1f8fd16dae7f0bf3f435726ed9d8ec76c69d8e8 | Ruby | dev-knights/dev-knights.github.io | /Rakefile | UTF-8 | 4,235 | 2.875 | 3 | [
"MIT"
] | permissive | require "rubygems"
require "bundler/setup"
require "stringex"
## -- Config -- ##
posts_dir = "_posts" # directory for blog files
drafts_dir = "_drafts" # directory for blog files
new_post_ext = "markdown" # default new post file extension when using the new_post task
new_page_ext = "markdown"
n... | true |
d5cf6e43c05aab7256ce8795375e91b0907d6ded | Ruby | lkang-pdx/garnet | /lib/luna_gem.rb | UTF-8 | 1,908 | 2.671875 | 3 | [] | no_license | require 'httparty'
require 'json'
require_relative 'roadmap'
class LunaGem
include HTTParty
include Roadmap
def initialize(email, password)
response = self.class.post(api_url("sessions"), body: {"email": email, "password": password})
puts response.code
raise "Error" if response.code == 404
@auth... | true |
1deedecae53640d83f5f2b8f43241349d664840c | Ruby | giusepped/palindrome_numbers | /counter.rb | UTF-8 | 420 | 3.15625 | 3 | [] | no_license | require_relative './lib/palindrome_counter.rb'
Dir.glob('**/*.txt') do |test_file|
counter = PalindromeCounter.new
range_numbers = File.foreach(test_file).first(2)
start = range_numbers[0].chomp
finish = range_numbers[1]
palindrome_count = counter.count(start.to_i, finish.to_i)
puts "File checked: #{test_f... | true |
3c3d2b67a9c7804be172caba37d62b12294023a0 | Ruby | timpalpant/bioruby-genomic-file | /lib/bio/genomics/assembly.rb | UTF-8 | 1,361 | 3.015625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# Assembly.rb
# BioRuby
#
# Created by Timothy Palpant on 5/25/11.
# Copyright 2011 UNC. All rights reserved.
#
require 'bio/genomics/data_set'
module Bio
module Genomics
class Assembly < DataSet
attr_reader :name, :len_file
# Initialize a new assembly
def initialize(name, len_f... | true |
7f7756e19525ff6e42f0b7f459588304b71a9376 | Ruby | lukemcfarlane/web_workers_demo | /lib/server.rb | UTF-8 | 1,107 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'ufo_sighting_data'
require 'json'
class Server
def call(env)
@req = Rack::Request.new env
page, per_page, pages, total_count = pagination
rows = data.slice((page - 1) * per_page, per_page)
meta = {
page: page,
per_page: per_page,
pages: pages,
total_count: total_count... | true |
b8408dd46bd7755d31e38f2e23ed63a4249ea7e0 | Ruby | joubin/gitlabhq | /app/services/git/wiki_push_service/change.rb | UTF-8 | 1,621 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"CC-BY-SA-4.0"
] | permissive | # frozen_string_literal: true
module Git
class WikiPushService
class Change
include Gitlab::Utils::StrongMemoize
# @param [Wiki] wiki
# @param [Hash] change - must have keys `:oldrev` and `:newrev`
# @param [Gitlab::Git::RawDiffChange] raw_change
def initialize(wiki, change, raw_ch... | true |
2272ce5311b37491a9fecfe5965ab0d13e951fa1 | Ruby | jasylwong/boris_bikes | /spec/docking_station_spec.rb | UTF-8 | 1,701 | 3.203125 | 3 | [] | no_license | require 'docking_station'
describe DockingStation do
it { is_expected.to respond_to(:release_bike) }
it { is_expected.to respond_to(:dock)}
it 'allows a capacity of 30 to be set' do
expect(DockingStation.new(30).capacity).to eq 30
end
describe "#release_bike" do
it 'releases a bike when a bike is... | true |
008ae5bdf75d3840d710795bf25d89282c4a349e | Ruby | xinxinw1/ruby-factor | /factor.rb | UTF-8 | 2,875 | 3.421875 | 3 | [] | no_license | require "readline"
require "timeout"
# https://www.ruby-forum.com/topic/104941
def run(s, sec = 10)
begin
pipe = IO.popen(s, 'r')
rescue Exception => e
mess = e.inspect === "Interrupt" ? e.inspect : e.message
raise "Failed to start process: #{mess}"
end
begin
Timeout::timeout(sec) do
a... | true |
3bd1a3b0a8e3e333211c6d6184fdb3c849906d25 | Ruby | emboss/applied-crypto.rb | /code/07d_aes_cbc.rb | UTF-8 | 444 | 2.84375 | 3 | [] | no_license | require 'openssl'
# Let's have a look at the padding!
data = "Applied Crypto.rb"
cipher = OpenSSL::Cipher.new("aes-128-cbc")
cipher.encrypt
key = cipher.random_key
iv = cipher.random_iv
encrypted = cipher.update(data) + cipher.final
p encrypted
puts encrypted.size
decipher = OpenSSL::Cipher.new("aes-128-cbc")
dec... | true |
dfe8e202037b27f29b90a2c93c5971d4901404af | Ruby | globewalldesk/battleship_v3 | /lib/ship.rb | UTF-8 | 728 | 2.984375 | 3 | [] | no_license | class Ship
attr_accessor :type, :coords, :coord_count, :unhit, :sunk, :valid_coords
# :board probably won't be needed
def initialize(type)
@type = type
@coords = [] # placeholder for later construction
@valid_coords = false # until proven true
construct_ship_details
end
def construct_ship_de... | true |
fd36a5b64ddb8193b2f943fc43af78ecb579ecf9 | Ruby | Kris17/week_1 | /hello_spec.rb | UTF-8 | 457 | 2.84375 | 3 | [] | no_license | require "rspec"
require "./hello"
describe "'Hello, World' app" do
context "greet()" do
it "should return 'Hello, World!' if it gets 'World' as an argument" do
greet('World').should == "Hello, World!"
end
it "should return 'Hello, Azamat!' if it gets 'Azamat' as an argument" do
greet('Azamat').sho... | true |
b32e492aad564ef859cd76cde04a4907d63ac11f | Ruby | christopheralcock/haiku_machine | /1_page.rb | UTF-8 | 1,383 | 4.0625 | 4 | [] | no_license | class Hash
def shuffle
Hash[self.to_a.sample(self.length)]
end
def shuffle!
self.replace(self.shuffle)
end
end
def add_to(phrases)
puts "please give me a phrase that you wish to include in your poem"
phrase = gets.chomp.downcase.to_sym
puts "please tell me how many syllables you consider that p... | true |
00675d126f7aa83bb534d6e4ac396c36e26c0b47 | Ruby | MLee21/Enigma | /lib/off_set_calculator.rb | UTF-8 | 426 | 3.296875 | 3 | [] | no_license | class OffSetCalculator
attr_accessor :date
def initialize(date = Time.now.strftime("%m%d%y"))
@date = date
end
def format_to_numeric_form
@date.to_i
end
def square_the_formatted_date
square_of_date = (format_to_numeric_form ** 2).to_s.chars
end
def take_last_four_digits
last_four = sq... | true |
3c76269809f4c0c241c4a08785e7c0941fe3b87d | Ruby | justinko/baseball_stats | /lib/baseball_stats/stats/stat.rb | UTF-8 | 558 | 2.703125 | 3 | [] | no_license | module BaseballStats
module Stats
class Stat
module Formatter
def player_name
"#{self[:name]} (#{self[:player_id]})".ljust(37)
end
end
def self.default(option_name, value)
define_method(option_name) { value }
end
def initialize(options = {})
... | true |
5dae519b0f1e37e68f10353446ebd5c52b78f3b3 | Ruby | Domitalk/debugging-practice-debugging-with-pry-lab-dumbo-web-102819 | /fix_using_tests/turtles_all_the_way_down.rb | UTF-8 | 494 | 3.15625 | 3 | [] | no_license |
def turtles
[
{name: "Donatello", weapon: "bo-staff", traits: ["serious", "leader"]},
{name: "Michaelangelo", weapon: "nunchuks", traits: ["party dude"]},
{name: "Raphael", weapon: "sais", traits: ["cool", "rude"]},
{name: "Leonardo", weapon: "katanas", traits: ["loves being a turtle"]}
... | true |
3c1c24f1d6edea880840bb126266c2a52a1514a6 | Ruby | Strike-F8/Doctor | /person.rb | UTF-8 | 2,057 | 2.578125 | 3 | [] | no_license |
class Person
@@first_names = ["Ermelindaf",
"Kacyf",
"Altaf",
"Shakitaf",
"Reitaf",
"Jovitaf",
"Lucreciaf",
"Cedricm",
"Leonoraf",
"Latoyaf",
"Lacym",
"Jodif",
"Barbaraf",
"Reyesm",
"Dessief",
"Josefm",
"Kentm",
"Jaquelinef",
... | true |
d48663d2cb4eb367cfcc90c79a74385105687db6 | Ruby | basicsaki/wunder | /spec/wunder/promotional/rule/basket_rule_spec.rb | UTF-8 | 2,894 | 2.5625 | 3 | [
"MIT"
] | permissive | require "wunder_helper"
RSpec.describe Promotional::Rule::BasketRule do
let(:value) { BigDecimal(10) }
let(:name) { Faker::GameOfThrones.character }
let(:product_code) { 0o01 }
let(:product) { Product.new(product_code, name, 100) }
let(:basket) { Basket.new }
let(:basket_rule) { described_class.new(value,... | true |
f8f07722cb9d05ca0e6fe3a3d9fcb5791ac32c20 | Ruby | ssbasil/greeting-cli-cb-gh-000 | /lib/greeting.rb | UTF-8 | 141 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code the #greeting method here!
def greeting(name = ["Bobby", "Sally"])
puts "Hello #{name}. It's nice to meet you."
end
name = "Bobby"
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.