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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
24a566d2a42aafcf479254c685888eae0ac979be | Ruby | Kleanthismits/book_api | /test/models/book_test.rb | UTF-8 | 4,359 | 2.828125 | 3 | [] | no_license | # rubocop:disable Metrics/ClassLength
require 'test_helper'
class BookTest < ActiveSupport::TestCase
def before_setup
super
@book = books(:one)
end
test 'should save valid book' do
assert book.save
assert_empty book.errors
end
test 'should not save book without title' do
book.title = ni... | true |
79c8b821add25d20ce3d477a44d5d5262f9a0c11 | Ruby | jsoong1962/my-select-nyc-web-080618 | /lib/my_select.rb | UTF-8 | 215 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
# your code here!
arr = []
i = 0
while i < collection.length
block = yield(collection[i])
if block == true
arr.push(collection[i])
end
i += 1
end
p arr
end
| true |
8123f38c85df470a7f7ceccf0ab56b4b68dd7bce | Ruby | SeanReid/bowling | /bowl.rb | UTF-8 | 500 | 3.453125 | 3 | [] | no_license | class Game
def initialize
@rolls = []
end
def roll(pins_knocked_down)
@rolls << pins_knocked_down
end
def score
score = 0
index = 0
10.times do
if frame(index) == 10
score += 10 + @rolls[index+2]
index += 2
elsif @rolls[index] == 10
score += 10 + fram... | true |
bee318e9b85f3db7e541633183b20d1c2835407a | Ruby | jasmine/jasmine-gem | /lib/jasmine/ruby_versions.rb | UTF-8 | 251 | 2.890625 | 3 | [
"MIT"
] | permissive | def ruby_version_less_than(target_version)
version_parts = RUBY_VERSION.split('.').map(&:to_i).zip(target_version)
version_parts.each do |(current_part, target_part)|
if current_part < target_part
return true
end
end
false
end
| true |
f6a6107899533a1154d9f32b813763c4ee72f6a9 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/2a0589f9689d4a4e89239c5fc9f828f6.rb | UTF-8 | 431 | 3.75 | 4 | [] | no_license | class Bob
def hey(phrase)
return 'Fine. Be that way!' if silence? phrase
return 'Woah, chill out!' if shouting? phrase
return 'Sure.' if question? phrase
'Whatever.'
end
def silence?(phrase)
phrase.strip.empty?
end
def shouting?(phrase)
stripped = phrase.gsub(/[^a-zA-Z]/, '')
!st... | true |
1cefaaf2380cca37b9d7e42c092d7486e81db6d4 | Ruby | josh-works/hp | /ss_calc.rb | UTF-8 | 1,754 | 3.671875 | 4 | [] | no_license | require 'pry'
require 'date'
class SsCalc
attr_reader :current_income, :birthday, :claim_date, :spousal_benefits
def initialize(current_income, birthday, claim_date, spousal_benefits)
@current_income = current_income ||= 0
@birthday = Date::strptime(birthday,"%m-%d-%Y")
@claim_date = claim_date ||= ... | true |
77aa6ac2949126145bcb2982b3fdd370320682ef | Ruby | ollie/k_means_pp | /spec/lib/k_means_pp_spec.rb | UTF-8 | 1,767 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'csv'
RSpec.describe 'Superman' do
it 'does it again' do
raw_data = File.read('./spec/resources/points.csv')
data = CSV.parse(raw_data).map do |row|
[row[0].to_f, row[1].to_f]
end
clusters = KMeansPP.clusters(data, 3)
clusters.each do |cluster|
expect(cluster.points.size... | true |
21d2e86468557dd78f8a8adcc4c28f1aedf59246 | Ruby | Griatch/misc | /musical_keys/test_java_midi.rb | UTF-8 | 610 | 2.53125 | 3 | [] | no_license | require 'java'
synth = javax.sound.midi.MidiSystem.getSynthesizer
synth.open
soundbank = synth.getDefaultSoundbank
synth.loadAllInstruments(soundbank)
@channel = synth.getChannels[0]
def play_note(note, duration, intensity=8)
@channel.noteOn(note, intensity)
sleep(duration.to_f / 1000)
@channel.noteOff(note, i... | true |
2d6054f92b596b1b0ed55d6741e17b43b1eb17d1 | Ruby | akshatpaul/motion-prime | /motion-prime/support/ui_view.rb | UTF-8 | 1,081 | 2.84375 | 3 | [] | no_license | class UIView
attr_accessor :name
def find name
subviews.each do |subview|
return subview if subview.name == name
end
nil
end
alias_method :subview, :find
def sibling name
if superview
superview.find name
else
nil
end
end
def closest name
view = sibling name... | true |
4bcf5a0491005d10e0d3ffe26e0f7eff83aef73f | Ruby | sajadtorkamani/ruby-katas | /spec/cheapest_quote_spec.rb | UTF-8 | 692 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../src/cheapest_quote'
describe 'cheapest_quote' do
it 'returns cheapest quote based on number of newspapers' do
expect(cheapest_quote(1)).to eq 0.10
expect(cheapest_quote(5)).to eq 0.49
expect(cheapest_quote(10)).to eq 0.97
expect(cheapest_quote(20)).... | true |
0aa36cbaea35f4f87a9c9d38d20d0c8c1224db7b | Ruby | nickscaglione/cartoon-collections-web-0916 | /cartoon_collections.rb | UTF-8 | 478 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)
dwarves.each_with_index do |dwarf, index|
puts "#{index+1} #{dwarf}"
end
end
def summon_captain_planet(calls)
calls.map do |call|
call.capitalize + "!"
end
end
def long_planeteer_calls(words)
words.any? do |word|
word.length > 4
end
end
def find_the_cheese(snack... | true |
36bcb279c88e3709953a1475d6dbcea720862425 | Ruby | duckpuppy/heroku | /lib/heroku/command/domains.rb | UTF-8 | 1,838 | 2.8125 | 3 | [
"MIT"
] | permissive | require "heroku/command/base"
module Heroku::Command
# manage custom domains
#
class Domains < Base
# domains
#
# list custom domains for an app
#
#Examples:
#
# $ heroku domains
# === Domain names for example
# example.com
#
def index
validate_arguments!
... | true |
ad36472040c1f7adbc1b19586b7f8b7bea8c6a0e | Ruby | NeoRyu/fightclub | /test/models/character_test.rb | UTF-8 | 2,434 | 2.765625 | 3 | [] | no_license | require 'test_helper'
class CharacterTest < ActiveSupport::TestCase
test "user should have balanced capabilities" do
character = characters :one
character.life_point = Character::MINIMUM_LIFE_POINT
character.attack_point = Character::MINIMUM_ATTACK_POINT
character.defence_point = Character::MINIMUM_... | true |
c2c301650c85887facaa0a93f81a87c7dc6329c1 | Ruby | mukund-kri/blog.mukund.net.in | /_plugins/archive.rb | UTF-8 | 941 | 2.625 | 3 | [] | no_license | # Generate and year/month categorized archive listing page
module Jekyll
class ArchivePage < Page
def initialize(site, base, dir)
@site = site
@base = base
@dir = dir
@name = "archives.html"
by_year = Hash.new
grouped = site.posts.docs.group_by {|post| post.date.year}
... | true |
52276db9b41e28583578811ae576f81e62dd1f6b | Ruby | nomadop/show_callback | /lib/behaviour/as_mouse.rb | UTF-8 | 363 | 2.546875 | 3 | [] | no_license | class AsMouse < Behaviour::Base
def action
@spirit.center_x = pos_x
@spirit.center_y = pos_y
end
def pos_x
tmp = [World.mouse.x, @spirit.half_width].max
[tmp, World::WORLD_WIDTH - @spirit.half_width].min
end
def pos_y
tmp = [World.mouse.y, @spirit.half_height].max
[tmp, World::WORLD_... | true |
13bc6445e39f1a63685d95d716eea8e8a25cda40 | Ruby | highwide/otsuri_simulator | /lib/person.rb | UTF-8 | 2,114 | 3.765625 | 4 | [] | no_license | require './lib/wallet'
require './lib/money'
class Person
attr_accessor :wallet, :coins_history
def initialize
@wallet = Wallet.new(
one: 4,
five: 1,
ten: 4,
fifty: 1,
hundred: 4,
five_hundred: 1,
thousand: 4,
five_thousand: 1,
ten_thousand: 4
) # 4999... | true |
ebe771f0158a9483cb97bebd1544186edd1eac7c | Ruby | 512dev/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 667 | 2.65625 | 3 | [] | no_license | puts 'Cleaning database...'
Restaurant.destroy_all
puts 'Creating restaurants...'
restaurants_attributes = [
{
name: "Epicure au Bristol",
address: "Chicago",
category: "french"
},
{
name: "La truffière",
address: "Los Angeles",
category: "french"
},
... | true |
a684868cc73f54053756d2c2929646d3e5b6d503 | Ruby | rtyenriques/ruby-music-library-cli-onl01-seng-pt-050420 | /lib/music_importer.rb | UTF-8 | 362 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path
def initialize(path)
@path = path
end
def files
Dir["#{path}/*"].collect { |filename| filename.gsub("#{path}/", "")}
end
def import # imports all files from the library. Instantiating a new song object for each file
files.each do |file|
Song.cre... | true |
139a5c634009fb609464444b3634cb32af35efcd | Ruby | GinGatt/IronhackAndBeyond | /Week5/Day3/PrepReview/CollectionExercise.rb | UTF-8 | 2,926 | 4.34375 | 4 | [] | no_license | class Home
attr_reader(:name, :city, :capacity, :price)
def initialize(name, city, capacity, price)
@name = name
@city = city
@capacity = capacity
@price = price
end
end
homes = [
Home.new("Nizar's place", "San Juan", 2, 42),
Home.new("Fernando's place", "Seville", 5, 47),
Home.new("Josh's... | true |
8b6e7dbb8051aa845a04e1788de443909d3e26d3 | Ruby | LeadsPlus/mls | /lib/tasks/utilities.rake | UTF-8 | 1,702 | 2.734375 | 3 | [] | no_license | namespace :houses do
desc "Change all the house daft_urls into daft_id's"
task :convert_daft_urls => :environment do
delay.convert_urls_to_ids
end
desc "Make up fake room numbers for all the houses in the DB"
task :fake_rooms => :environment do
fake_rooms
end
desc "Convert all the county names t... | true |
78fa72aae868fc2cf4e279e0b927014066cd3356 | Ruby | baphled/number2english | /spec/lib/number2english/padder_spec.rb | UTF-8 | 1,005 | 3.171875 | 3 | [] | no_license | require 'spec_helper'
class Number2English
describe Padder do
subject { described_class }
it 'returns an array with one integer' do
numbers = ['0']
expect(subject.pad(numbers)).to eql(['0'])
end
it 'takes numbers under 20 as a single integer' do
numbers = ['19']
expect(subje... | true |
2dd688a8cf8aaa421f3aec7b058a2cef6c21d6cd | Ruby | voxmedia/ad-server-proxy | /lib/fake_redis.rb | UTF-8 | 645 | 3.15625 | 3 | [
"BSD-3-Clause"
] | permissive | # Quick class to emulate redis when running in test mode
# Or if running without redis... horrible and inefficient
class FakeRedis
TTL = 5 #minutes;
def initialize
@store = {}
# emulate ttl
@last_deleted = Time.now
end
def exists(key)
response = @store.key? key
delete_if_ttl_expired
r... | true |
19d335ca2944b437a9039194e204cbd20b5b8e57 | Ruby | joshvh/ruote | /lib/openwfe/listeners/listener.rb | UTF-8 | 2,338 | 2.5625 | 3 | [
"MIT"
] | permissive | #--
# Copyright (c) 2007-2009, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy... | true |
5adf330a36f36f4319800708db96e875ef8759ae | Ruby | zencoder/rvideo | /lib/rvideo/inspector.rb | UTF-8 | 13,018 | 2.921875 | 3 | [
"MIT"
] | permissive | module RVideo # :nodoc:
class Inspector
attr_reader :filename, :path, :full_filename, :raw_response, :raw_metadata
attr_accessor :ffmpeg_binary
#
# To inspect a video or audio file, initialize an Inspector object.
#
# file = RVideo::Inspector.new(options_hash)
#
# Insp... | true |
017aed566e6c003387055c7fdbb7ef6db82e90e9 | Ruby | clustermass/cookhouse_stories | /app/models/ingredient.rb | UTF-8 | 760 | 2.59375 | 3 | [] | no_license | # == Schema Information
#
# Table name: ingredients
#
# id :bigint(8) not null, primary key
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Ingredient < ApplicationRecord
validates :name, presence: true
before_vali... | true |
c8158716bb096a934db807808bc1503bc5beafde | Ruby | thejoshlamb/brainforest | /app/models/product.rb | UTF-8 | 769 | 2.53125 | 3 | [] | no_license | class Product < ActiveRecord::Base
mount_uploader :image1, ProductImageUploader
mount_uploader :image2, ProductImageUploader
mount_uploader :image3, ProductImageUploader
mount_uploader :image4, ProductImageUploader
mount_uploader :image5, ProductImageUploader
belongs_to :user
has_many :reviews
has_many :user... | true |
f97266ac316a1f6cf4ddc47fe20808d7fb28b3a3 | Ruby | rails-on-services/iron_hide | /spec/cnfs/urn.rb | UTF-8 | 1,873 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Cnfs
class Urn
attr_accessor :txt, :partition_name, :service_name, :region, :account_id, :resource
# rubocop:disable Metrics/ParameterLists
def initialize(txt, partition_name, service_name, region = '*', account_id = '*', resource = '')
@txt = txt
@partit... | true |
e6ac3a5dec98237163c68f46490163154560375b | Ruby | rraven/mks_ruby_classes-1 | /car.rb | UTF-8 | 890 | 4 | 4 | [] | no_license | class Car
def initialize
@fuel = 10.0
@distance = 0.0
puts "the initialize method is running automatically"
end
def get_info
puts "I'm a car! I've driven #{@distance} miles and have #{@fuel} gallons of gas left."
puts "I have enough gas to drive #{@fuel*20.0} miles."
end
def drive(miles_driven)
availab... | true |
ebaafbfaa488fd3bbb7cfd9f8f184ffb3eb7b4ac | Ruby | Papipo/mounter | /lib/locomotive/mounter/writer/api/base.rb | UTF-8 | 7,661 | 2.671875 | 3 | [
"MIT"
] | permissive | module Locomotive
module Mounter
module Writer
module Api
class Base
attr_accessor :mounting_point, :runner
delegate :default_locale, :locales, :site, to: :mounting_point
def initialize(mounting_point, runner)
self.mounting_point = mounting_point
... | true |
fed66e31463d6acd534a7c29b8091096dc17b607 | Ruby | nishimat/Euler | /p082.rb | UTF-8 | 1,077 | 2.9375 | 3 | [] | no_license | require 'csv'
=begin
list = [
[131,673,234,103,18],
[201,96,342,965,150],
[630,803,746,422,111],
[537,699,497,121,956],
[805,732,524,37,331]
]
=end
list = CSV.read( 'p082_matrix.txt' ).map{ |e| e.map( &:to_i ) }
datasize = list.size
weight = Array.new( datasize ){ |y| Array.new( datasize){ |x| list[ y ... | true |
8eaaf16c77b898dd4d355edad209c1c97a88bf01 | Ruby | corys/scrummin | /spec/scrummin/person_spec.rb | UTF-8 | 554 | 2.71875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "time"
module Scrummin
describe Person do
it "requires a name" do
expect { Person.new(nil) }.to raise_error(ArgumentError)
expect { Person.new(" \t\n ") }.to raise_error(ArgumentError)
end
it "persists name" do
Person.new("Bob").name.should == "Bob"
... | true |
70de437b945b4d0ea056bce826d0903605014d5f | Ruby | tyrbo/sales_engine | /lib/invoice_item_repository.rb | UTF-8 | 589 | 2.671875 | 3 | [] | no_license | require_relative 'repository'
require_relative 'invoice_item'
class InvoiceItemRepository < Repository
def self.create_all(invoice_id, items)
time = Time.now.to_s
items.group_by { |item| item.id }.each do |item_id, items|
new_id = all.max_by(&:id).id + 1
invoice_item = InvoiceItem.new(id: new_id,... | true |
c43a8f59b21921881224ec982793ee87a9b1fe0a | Ruby | yyytuit/ruby_gold | /弱い問題/30.rb | UTF-8 | 145 | 2.828125 | 3 | [] | no_license | d1 = Time.new
d2 = Time.new
p(d2 - d1).class
1.Float
2.Rational
3.Fixnum
4.Bignum
答え 1
Time同士の減算はFloat型になります。
| true |
067592aa45ab83c9749646d61d6354ae15f94196 | Ruby | stephenbinns/superblockboy | /lib/block_boy.rb | UTF-8 | 4,116 | 2.53125 | 3 | [
"MIT"
] | permissive | class BlockBoy < GameObject
trait :bounding_box, scale: 0.80, debug: false
traits :timer, :collision_detection, :velocity, :effect
def setup
self.input = {
[:holding_left, :holding_a] => :holding_left,
[:holding_right, :holding_d] => :holding_right,
[:up, :w] => :jump,
[:x] => :fireba... | true |
c7181d929355e33876d026d1fae1d8f4176e5893 | Ruby | jguest/metatext | /lib/metatext.rb | UTF-8 | 2,125 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'erb'
require 'ostruct'
# MetaText
# a lightweight jekyll-style metadata parser
#
# [what it do]
#
# * parses yaml at the top of any file, jekyll style
# * stores metadata in an object
# * inject your own text processor (e.g. redcarpet for markdown)
# * use erb (<% %>) for dynamic text on demand... | true |
5c47026e4d785c9d02610d54258c569300314bd0 | Ruby | kennydrobnack/automatic-octo-guacamole | /spec/roman_numeral_spec.rb | UTF-8 | 8,305 | 3.96875 | 4 | [] | no_license | require 'rspec'
require 'roman_numeral'
#Test cases:
# Convert Roman Numeral to Arabic Number
# Numeral Number
# I 1
# III 3
# IX 9
# MLXVI 1066
# MCMLXXXIX 1989
RSpec.describe RomanNumeral do
#Test helper classes
it 'single_character_conversion converts I to 1' do
roman_number = RomanNumeral.new("I")
expect... | true |
0e7baa69b910cb2eda5e2fdc095ea31f1507e3ff | Ruby | tmat1986/demoapp | /class2.rb | UTF-8 | 605 | 3.515625 | 4 | [] | no_license | class MyCar
def initialize(name="Infiniti unnamed")
@name = name
@engine = "off"
@speed = 0
end
def start_engine
puts "bururung"
@engine = "on"
end
def stop_engine
puts "phrrr"
@engine = "off"
end
def check_engine_status
puts @engine
end
def gas_pedal
if... | true |
8d269d8fd95300d88f0dd050cf865f71ca0ec596 | Ruby | nasa/GMSEC_API | /examples/ruby/message_field_iterator.rb | UTF-8 | 7,179 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Copyright 2007-2023 United States Government as represented by the
# Administrator of The National Aeronautics and Space Administration.
# No copyright is claimed in the United States under Title 17, U.S. Code.
# All Rights Reserved.
#
# @file message_field_iterator.py
#
# This file contains a ... | true |
99039fb2ab8d8c716e98c75e7d733db900454221 | Ruby | alchemycyberblaze/selenium101 | /exercises/2/exercise2.rb | UTF-8 | 377 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | #
# Exercise 2
#
require 'selenium-webdriver'
host = 'http://www.stpcon.com'
drv = Selenium::WebDriver.for :chrome
drv.navigate.to(host)
puts "Title of #{host} is #{drv.title}"
drv.get('http://www.carmax.com')
puts "Title of Carmax site is " + drv.title
drv.navigate.back()
puts "After navigationg back, tit... | true |
a4c23cf6b989c1303b375c18b78726b917be0456 | Ruby | mfktuqtd/cs993 | /models/account.rb | UTF-8 | 1,174 | 2.703125 | 3 | [] | no_license | class Account < ActiveRecord::Base
attr_accessor :password, :password_confirmation
# Validations
validates_presence_of :name, :role
validates_presence_of :password, :if => :password_required
validates_presence_of :password_confirmation, :if => :password_required
validates... | true |
f2553cf451cb9d9f8702bf76a88f6e8479ce367c | Ruby | rikur/ramaze | /lib/ramaze/helper/aspect.rb | UTF-8 | 2,847 | 2.609375 | 3 | [
"Ruby"
] | permissive | # Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.
module Ramaze
# A helper that provides the means to wrap actions of the controller with
# other methods.
#
# For examples please look at the spec/ramaze/helper/a... | true |
bea0444ffdc6296868d8eb55fa76958d5e6a038b | Ruby | jawsthegame/ProjectEulerRuby | /problem02.rb | UTF-8 | 248 | 3.484375 | 3 | [] | no_license | class Problem02
$sum = 0
def Problem02.run
next_fibonacci(1, 2)
p $sum
end
def Problem02.next_fibonacci(a, b)
if a > 4000000
return
end
if a % 2 == 0
$sum += a
end
next_fibonacci(b, a + b)
end
end | true |
4e4c4363bb082c82e379f2a3a155c9e593e7619c | Ruby | LoesterFranco/foss-asic-tools | /images/foss-asic-tools/addons/sak/klayout/gdsLayers.rb | UTF-8 | 3,045 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/ruby
# usage: gdsLayers.rb <gdsFile>
# LIMITATION: effectively sees/processes layers present in all cells,
# not just the hierarchy of "the" one topcell of interest. i.e. Can be
# multiple topcells, where only the hier. of the "extra" topcells have
# certain layers; where better is to limit output to layers... | true |
1e7bc1bf5a3a44052e3f4549f9b08d5f00dfa95c | Ruby | joelmccracken/playground | /project_euler/lib/maximum_sum_path_triangle.rb | UTF-8 | 5,278 | 3.46875 | 3 | [] | no_license | require_relative "lib_helper"
# 3
# 7 4
# 2 4 6
# 8 5 9 3
module ProjectEuler
module MaximumPathSumTriangle
class Triangle
def self.parse_from str
t = self.new
t.parse str
t
end
def parse triangle_repr
# how much do I love ruby? this much:
rows =... | true |
3b163980b3268ffbed2da59a28e278cb77357b53 | Ruby | katsuya245126/App-Academy-Projects | /Finished/Ruby/RSpec_and_TDD/poker/spec/poker_spec.rb | UTF-8 | 1,244 | 3.265625 | 3 | [] | no_license | require 'rspec'
require 'poker'
require 'player'
# rubocop:disable all
describe Poker do
let(:poker) { Poker.new }
let(:hand_double) { double("hand") }
describe "#initialize" do
it "initializes empty pot" do
expect(poker.pot).to eq(0)
end
it "initializes a deck" do
expect(poker.deck).to... | true |
acbaa35135c230dc0c85fa307042c72c9ee797e7 | Ruby | emilyalice2708/oyster | /lib/oystercard.rb | UTF-8 | 818 | 3.296875 | 3 | [] | no_license | require_relative 'journey'
require_relative 'journey_log'
class Oystercard
CARD_LIMIT = 90
attr_reader :balance, :entry_station, :journeys
def initialize(journeys = JourneyLog.new)
@balance = 0
@journeys = journeys
end
def view_journeys
@journeys.journeys
end
def top_up(money)
exceeded... | true |
f15904926dc144302df6d22da9243440c4a9ee46 | Ruby | schasse/sort_jpgs.rb | /lib/sort_jpgs.rb | UTF-8 | 3,401 | 3 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require 'exifr'
require 'fileutils'
require 'date'
require 'optparse'
require 'logger'
FORMAT = "%y-%m-%d %H:%M:%S"
def parse_options
opts = { source: './', output: './', move: false }
optparse = OptionParser.new do |parser|
# banner that is displayed at the top
parser.banner = "Usage: \... | true |
5e60ed102ad160f1a67f5bfbd78d6f6beef557fb | Ruby | trizen/sidef | /scripts/Tests/sierpinski_penta.sf | UTF-8 | 388 | 3.546875 | 4 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
func sierpinski_penta(n) {
var penta = ['*'];
{ |i|
var sp = (' ' * 2**i);
penta = (
penta.map {|x| sp + x + ' ' + x + sp} +
penta.map {|x| x + sp + ' ' + sp + x} +
penta.map {|x| sp*2 + ' '*(i**2) + x + ' '*(i**2) + sp*2}
... | true |
60685cb46793b3f433472ede7eed29ac50b3b697 | Ruby | gmikeska/find-my-pet | /lib/geokitMethods.rb | UTF-8 | 1,762 | 3.34375 | 3 | [] | no_license | require 'geokit'
require 'pg'
require 'json'
module GEO
# main call
def self.geocode(address)
Geokit::Geocoders::GoogleGeocoder.geocode address
end
def self.getWithinRadius radius, myLongitude, myLatitude, modelObject
# Description: getWithinRadius
# - Given a location and radius (miles), find a... | true |
d294ba35c6d3cbe0fc3e2a4f3423e5b6fc536661 | Ruby | gkellogg/rdf_context | /lib/rdf_context/bnode.rb | UTF-8 | 3,055 | 2.96875 | 3 | [
"MIT"
] | permissive | module RdfContext
# The BNode class creates RDF blank nodes.
class BNode < Resource
attr_accessor :identifier
# Create a new BNode, optionally accept a identifier for the BNode.
# Otherwise, generated sequentially.
#
# A BNode may have a bank (empty string) identifier, which will be equival... | true |
c3ddecd744e49023fb61a45e1bd29a523105fe2b | Ruby | neilmcdonagh1985/pub_exercise | /pub.rb | UTF-8 | 541 | 3.4375 | 3 | [] | no_license | class Pub
attr_reader :name, :stock, :money_in_till
def initialize(name, stock, money_in_till)
@stock = {}
@name = name
@money_in_till = money_in_till
end
def sell_drink(customer, drink)
@money_in_till += drink.price
customer.buy_drink(drink)
end
def check_customer_age(customer)
if... | true |
33000ff59979acc62b42edc73aada362dee7c503 | Ruby | rodrigorosa/rhodes | /lib/framework/br_inscricao_estadual/go.rb | UTF-8 | 922 | 2.75 | 3 | [
"MIT"
] | permissive | module BrInscricaoEstadual
class GO < Common
protected
STATE_CODE = %w[10 11 15]
DIGITS_ZERO = [0]
def digit_verify_inscription(result)
if insc_int_arr.take(PESO.size).join.to_i == 11_094_402
return insc_int_arr.last if [1, 0].include?(insc_int_arr.last)
end
... | true |
0bc78c6d592e67128c7f2e5aba9fc4da4f1aa13b | Ruby | alinan-vn/programming-univbasics-nds-nds-to-insight-understand-lab-chicago-web-111819 | /lib/nds_explore.rb | UTF-8 | 928 | 3.078125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'directors_database'
directors_database
# Call the method directors_database to retrieve the NDS
def pretty_print_nds(nds)
# Change the code below to pretty print the nds with pp
pp nds
end
#puts pp directors_database
#puts pp directors_database[0][:movies][0][:... | true |
57026fc55eab834e6508d59f4289339d0cf0d2b8 | Ruby | ecin/password_exercise | /bin/pronounce | UTF-8 | 386 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby
require File.expand_path('../lib/pronounceable.rb', File.dirname(__FILE__))
class String; include Pronounceable; end
if ARGV[0].nil?
puts "Usage: pronounce <input_file>"
exit 1
end
input = File.open(ARGV[0])
input.each_line do |line|
word = line.chomp
return if word == 'end'
puts "<#{w... | true |
c54216106770e40e872515628ec28b9bbe5140e0 | Ruby | sveredyuk/perforator | /spec/meter_spec.rb | UTF-8 | 5,675 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'logger'
RSpec.describe Perforator::Meter do
let(:name) { 'my_meter' }
let(:logger) { Logger.new('my_logger.log') }
let(:expected_time) { 20 }
let(:positive_callback) { -> { ':)' } }
let(:negative_callback) { -> { ':(' } }
let(:execution_message) { ... | true |
c01e1f98175066559b2c8f867436d246d77471ff | Ruby | panda22/Symport | /lib/querying/query_generator.rb | UTF-8 | 650 | 2.6875 | 3 | [] | no_license | class Querying::QueryGenerator
class << self
def select_attr_or_string(attribute, length = 1)
return "" if (length == 0 || (length.to_i.to_s != length && length.to_i.to_s != length.to_s))
chain = select_attr_string(attribute, 'none')
for i in 2..length.to_i
chain += selec... | true |
4c5755c734e100de924316c063474bb352606154 | Ruby | emil-palm/frostbitten | /lib/frostbitten/player.rb | UTF-8 | 1,593 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'hashie'
module Frostbitten
# Class to repesent a player object returned by server
class Player < Hashie::Trash
class << self
def players_from_list(list,index)
key_count = list.slice!(index).to_i
keys = list.slice!(index,key_count)
player_count = list.slice!(index).to_i
return [].tap do... | true |
aea1494ae40f986ac11e68e9985466f73763dfdd | Ruby | kwokasch/advanced-hashes-hashketball-denver-web-82619 | /hashketball.rb | UTF-8 | 5,985 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def game_hash
basketball_hash = {
:home => {
:team_name => "Brooklyn Nets",
:colors => ["Black", "White"],
:players => [{
:player_name => "Alan Anderson",
:stats => {
:number => 0,
:shoe => 16,
:points => 22,
:rebounds => 12,
... | true |
0c6e2b598e328b5df1d7ee5af161c999a73f8abc | Ruby | kiril-kostadinov-tues/lacr-search | /src/app/services/transkribus_service.rb | UTF-8 | 6,030 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | #app/services/transkribus_service.rb
require 'net/http'
require 'json'
require 'uri'
class TranskribusService
def initialize()
@sessionId = ""
end
# Login into Transkribus
def tr_login(user,password)
req_params = {:user => user, :pw => password}
uri = URI("https://transkribus.eu/TrpServer/rest/auth/login")
... | true |
c24d856708eeef9b7a88a7eec46c709a17a931fc | Ruby | jocubeit/simplestate | /test/dummys/dummy_state_holder.rb | UTF-8 | 302 | 2.84375 | 3 | [
"MIT"
] | permissive | class DummyStateHolder
def initialize(opts={})
end
def transition_to(new_state_class)
set_new_state(new_state_class)
end
def set_new_state(new_state_class)
@cs = new_state_class
end
def current_state
@cs
end
private
def current_state=(state)
@cs = state
end
end
| true |
a59cd89c9cf107b4aa43e01c674b767f797039f5 | Ruby | jwkempe/dylan_name_exercise | /dylan.rb | UTF-8 | 1,221 | 3.9375 | 4 | [] | no_license | class Person
attr_accessor :name, :gender, :age
end
Dylan = Person.new
Dylan.name = 'Dylan Y'
Dylan.gender = 'male'
Dylan.age = 20
puts "There is a person named Dylan"
puts "Dylan's full name is " + Dylan.name
puts "Dylan's age is " + Dylan.age.to_s
Ross = Person.new
Ross.name = 'Ross M'
Ross.gender = 'male'
Ross... | true |
0d08efae9385a585b7785ee291c8da2821bba532 | Ruby | blockspring/blockspring-cli | /lib/blockspring/cli/command/help.rb | UTF-8 | 4,042 | 2.75 | 3 | [
"MIT"
] | permissive | require "blockspring/cli/command/base"
# Get information about commands
#
class Blockspring::CLI::Command::Help < Blockspring::CLI::Command::Base
PRIMARY_NAMESPACES = %w( auth block run )
# help [COMMAND]
#
# "Yo dawg. I heard you liked help..." -Xzibit
#
#Examples:
#
# $ blockspring help
# Usage: ... | true |
81b7a24b3c4b034648c93ffab289f700e1863b8e | Ruby | rmb74th/tealeaf_prep | /03_methods_ex/04_ex.rb | UTF-8 | 122 | 3.390625 | 3 | [] | no_license | # This will not print anything.
def scream(words)
words = words + "!!!!"
return
puts words
end
scream("Yippeee")
| true |
4f6ac0a3c558d0dae6ee31b8ed65d07dbef7c484 | Ruby | tsonntag/interfaces | /lib/interfaces/password_hider.rb | UTF-8 | 528 | 2.9375 | 3 | [
"MIT"
] | permissive | module Interfaces
class PasswordHider
def initialize marker = 'PPASSSSWWOORRDD', hidden = 'HIDDEN'
@marker, @hidden = marker, hidden
end
def hide s, hidden=nil
replace s, hidden||@hidden
end
def unmask s
replace s
end
def mask s
"<#{@marker}>#{s}</#{@marker}... | true |
8f820c5e2df09ebb99e798ed532c82b780b4db1d | Ruby | shunsukeee/ruby-practice | /mondai2.rb | UTF-8 | 274 | 3.1875 | 3 | [] | no_license | input = gets
a = input.split(" ").map{|n|n.to_i}
po = 0
a[1].times do
u = gets.to_i
if po < u
a[0] = a[0]-u
po = (po + u * 0.1).round
puts a[0].to_s + " " + po.to_s
else
po = po - u
puts a[0].to_s + " " + po.to_s
end
end
| true |
99921f426cb462cbd844fbb2940d2367d7c0ff52 | Ruby | K-Wei/omnicalc | /app/controllers/calculations_controller.rb | UTF-8 | 4,801 | 3.078125 | 3 | [] | no_license | class CalculationsController < ApplicationController
def word_count
@text = params[:user_text]
@special_word = params[:user_word]
# ================================================================================
# Your code goes below.
# The text the user input is in the string @text.
# The... | true |
e5923b96a420628e2d58bbedb4589a75643e9fe9 | Ruby | hrk623/practice_ruby | /merge-sort.rb | UTF-8 | 420 | 3.234375 | 3 | [] | no_license | # merge-sort.rb
# author: hrk623
# date: 2013/06/19
def mergesort(lst)
if lst.size <= 1
return lst
else
left = mergesort(lst[0...lst.size/2])
right = mergesort(lst[lst.size/2...lst.size])
sorted = []
until left.empty? || right.empty?
if left[0] <= right[0]
sorted << left.shift
... | true |
42ac54b4c3f10ae1f757d4a1a5a8c8640d903b59 | Ruby | harpreetsingh500/exercism_exercises | /etl/etl.rb | UTF-8 | 177 | 2.96875 | 3 | [] | no_license | class ETL
def self.transform(legacy)
shiny = {}
legacy.each do |score, letters|
letters.each { |char| shiny[char.downcase] = score }
end
shiny
end
end
| true |
dec915f6438e747a904e36fd10469467daa885dc | Ruby | charlesbjohnson/super_happy_interview_time | /rb/lib/leetcode/lc_371.rb | UTF-8 | 648 | 3.75 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
module LeetCode
# 371. Sum of Two Integers
module LC371
# Description:
# Calculate the sum of two integers left and right, but you are not allowed to use the operator + and -.
#
# Examples:
# Input: left = 1, right = 2
# Output: 3
#
# @param left {Integ... | true |
2a883a4fbac58994a460d91c695a6bb8fae4af11 | Ruby | wangfuhai2013/utils-rails | /lib/utils/common.rb | UTF-8 | 430 | 2.578125 | 3 | [
"MIT"
] | permissive | module Utils
class Common
def self.convert_bool(val)
ret = val
if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'sqlite'
ret = "'t'" if val.to_i > 0
ret = "'f'" if val.to_i <= 0
end
if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'm... | true |
c9917ef37f9245d490ca40ccb1c7833529aee35f | Ruby | kunieone/blockchain | /cryptoquotes/script/bundle.rb | UTF-8 | 555 | 2.59375 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | #################
# update (get) the crypto quotes bundled with this gem
# from the source:
# https://github.com/openblockchains/crypto-quotes
#
# to run use:
# ruby script/bundle.rb
require 'fileutils'
files = Dir.glob( '/sites/openblockchains/crypto-quotes/*.yml' )
puts "sources:"
pp files
puts
fi... | true |
c11db5f493f8b96b4c4a84d60c8b5fdd532860a0 | Ruby | IvoryDome/cc_w4_d2_homework_rps | /models/game.rb | UTF-8 | 868 | 3.421875 | 3 | [] | no_license | class Game
def initialize()
end
# eg. game1.who_wins("paper", "rock")
def who_wins(input1, input2)
if (input1 == 'rock' && input2 == 'rock')
return "Draw!"
elsif (input1 == 'scissors' && input2 == 'scissors')
return "Draw!"
elsif (input1 == 'paper' && input2 == 'paper')
return "Dra... | true |
9cab3e10b0c6184480be407747e8b4f19ddb4995 | Ruby | Mtmackenzie/ls101 | /101.5/practice14.rb | UTF-8 | 1,207 | 4.03125 | 4 | [] | no_license | # Given this data structure write some code to return an array containing
# the colors of the fruits and the sizes of the vegetables. The sizes
# should be uppercase and the colors should be capitalized.
hsh = {
'grape' => {type: 'fruit', colors: ['red', 'green'], size: 'small'},
'carrot' => {type: 'vegetable', ... | true |
7425d2be4ef12098f7b770b289e1a94569ed4a63 | Ruby | UbuntuEvangelist/therubyracer | /vendor/cache/ruby/2.5.0/gems/god-0.13.7/lib/god/driver.rb | UTF-8 | 6,211 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'monitor'
# Ruby 1.9.1 specific fixes.
if RUBY_VERSION.between?('1.9', '1.9.1')
require 'god/compat19'
end
module God
# The TimedEvent class represents an event in the future. This class is used
# by the drivers to schedule upcoming conditional tests and other scheduled
# events.
class TimedEvent
... | true |
cdc651681c0ed45354a3747027872cc575141f00 | Ruby | justinsuen/algo-practice | /leetcode/136_single_number/sol.rb | UTF-8 | 264 | 3.734375 | 4 | [] | no_license | def single_number(nums)
# O(n) time and space
# hash = Hash.new(0)
# nums.each { |n| hash[n] += 1 }
# hash.each { |k,v| return k if v == 1 }
# O(n) time and O(1) space
res = 0
nums.each { |n| res = res^n }
res
end
puts single_number([1,1,2,2,5])
| true |
7ff29a8e68c4b09da51c26edeeb188ced0f31058 | Ruby | eduardodeoh/RubyLearning | /Week4/Exercises/progExercise01-a.rb | UTF-8 | 1,818 | 3.9375 | 4 | [] | no_license |
#Exercise 1
#Exercise1. Write a class called Dog, that has name as an instance variable and the following methods:
#
#bark(), eat(), chase_cat()
#I shall create the Dog object as follows:
#d = Dog.new('Leo')
#
class Dog
def initialize(name)
@name = name
end
def bark
'Wolf Wolf'
end
def eat(foo... | true |
f15dc36afa3ade89f6e3c5d9c6d7933acaea9e2f | Ruby | PsychosocialMan/LAB10 | /app/controllers/polindrom_controller.rb | UTF-8 | 870 | 3.078125 | 3 | [] | no_license | class PolindromController < ApplicationController
def input
end
def output
n = (buf = params[:n].to_f).zero? && !params[:n].eql?('0') ? -1 : buf
@result_array = find_them_all(n)
@num = @result_array.length
respond_to do |format|
format.html
format.xml do
render xml: {
... | true |
98101421ac440733c725f1645a95dcaa24399cd5 | Ruby | nathanhains/sinatra-my-trainer-app | /app/controllers/users_controller.rb | UTF-8 | 1,466 | 2.53125 | 3 | [
"MIT"
] | permissive | class UsersController < ApplicationController
#route usage: to render login form
get '/login' do
erb :'/users/login'
end
#route usage: to receive login form & create a session(find user, log user in)
post '/login' do
@user = User.find_by(username: params[:username])
#is the... | true |
7d803d4d71e309fabfe3f71512d495102c5f9079 | Ruby | jadeapplegate/HappiTailsMiniProject | /shelter.rb | UTF-8 | 1,331 | 3.84375 | 4 | [] | no_license |
# #####Phase 2
# - Create your Shelter Class
# - Ensure that new animals and clients can be added to the shelter
# - Make sure your specs for shelter pass before moving on
# - Shelter:
# - The shelter should display all the clients.
# - The shelter should display all the animals.
class Shelter
attr_accessor... | true |
3e4663c8c2c8ee732cf22c0734b4bcab97d6df44 | Ruby | dfrent/ruby_fundamentals1 | /exercise2.rb | UTF-8 | 161 | 3.21875 | 3 | [] | no_license |
# cost = 55.0
#
# discount = (cost * 0.18)
# puts discount
# puts "string of words #{55}"
# puts "total #{45628 * 7839}"
(10 < 20 && 30 < 20) || !(10 == 11)
| true |
29bd037254be0648b0c79a1756f38deb39108a79 | Ruby | JEG2/advent_of_code_2015 | /day_5/count_nice.rb | UTF-8 | 461 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby -w
class Counter
def initialize
@nice = 0
end
attr_reader :nice
def check(string)
@nice += 1 if nice?(string)
end
private
def nice?(string)
# string.count("aeiou") >= 3 &&
# string =~ /(.)\1/ &&
# %w[ab cd pq xy].none? { |s| string.include?(s) }
string ... | true |
09b1972606220b340fa530c8fda551d32a0a4895 | Ruby | cayblood/learnruby | /people/smu/vital_ruby/lab05/solution/shadow_proxy_test.rb | UTF-8 | 599 | 2.78125 | 3 | [] | no_license | require 'test/unit'
require 'shadow_proxy'
class ShadowProxyTest < Test::Unit::TestCase
class Thing
attr_accessor :name
end
def setup
super
@thing = Thing.new
@thing.name = "THING"
@sh = ShadowProxy.new(@thing)
end
def test_creating_proxy
assert_not_nil @sh
end
def test_normal_... | true |
f3243273ee016c5df98241baaa12a2efa95d9674 | Ruby | Kagan-benjamin/Rails-Practice-Code-Challenge-Travelatr-nyc-web-120919 | /app/models/blogger.rb | UTF-8 | 373 | 2.734375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Blogger < ApplicationRecord
has_many :posts
has_many :destinations, through: :posts
validates :name, uniqueness: {case_sensitive: false}, presence: true
validates :bio, length: {minimum: 30}
validate :age_above_zero
def age_above_zero
if self.age < 1
errors.add(:... | true |
b9fe8eba96646ed79b58838ede4b23d4937b61e3 | Ruby | denny2trasy/zucker | /lib/zucker/cc.rb | UTF-8 | 656 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'zucker'
module Zucker Cc = true end
module Kernel
private
def c(show_irb = false)
method_stack = caller.reverse.map{ |m|
m.rindex( /:\d+(:in `(.*)')?$/ )
$2
}.compact
if !show_irb
if a = method_stack.index( 'irb_binding' )
method_stack = [ method_stack[0], '(irb... | true |
0711a450c90349289acd0688728548b7448e8d26 | Ruby | Michel-MSouza/farma_alg_reborn | /app/models/answer.rb | UTF-8 | 2,745 | 2.75 | 3 | [
"MIT"
] | permissive | class Answer < ApplicationRecord
validates_presence_of :content, :attempt, :lang_extension
validates_inclusion_of :correct, in: [true, false]
belongs_to :user
belongs_to :question
belongs_to :team
# The relationship from AnswerConnection is symmetrical, and so we need
# to check both foreign keys (answe... | true |
279c6133e768635ea168fbe3db72bb4fc83336e0 | Ruby | NREL/OpenStudio-resources | /model/refbuildingtests/measures/AddHVACSystem.rb | UTF-8 | 7,710 | 2.96875 | 3 | [
"BSD-2-Clause"
] | permissive |
class AddHVACSystem < OpenStudio::Ruleset::ModelUserScript
# override name to return the name of your script
def name
return "Add HVAC System Appropriate to give building type"
end
# return a vector of arguments
def arguments(model)
result = OpenStudio::Ruleset::UserScriptArgumentVector.new
hv... | true |
b15d42261f81bff4d10d26315e57e35b949f8276 | Ruby | wangfowen/fun | /interview_prep/sift.rb | UTF-8 | 2,202 | 3.90625 | 4 | [] | no_license | 'feline' => 'FeLiNe'
'began' => 'BeGaN'
'physics' => 'PHYSICS'
elems = { 'h', 'he', 'li', ... }
elems.contains('h')
>> true
elems.contains('xy')
>> false
# Return whether or not s is spellable with members of elems
# input string is only one word, and all alphabetical, and all lowercase
# elems are also all lowercas... | true |
9921aead1bdc2f14c46a10da7770e712da2e7f7b | Ruby | jwehmschulte/asciidoctor | /lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb | UTF-8 | 136 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # Educate Ruby 1.8.7 about the Symbol#empty? method.
class Symbol
def empty?
to_s.empty?
end unless method_defined? :empty?
end
| true |
2ec6acfa8810b02209eed8e6334eda0b32aacf2a | Ruby | zenm/RB101 | /RB101/exercises_small_problems/easy09/e09_09_grade_book.rb | UTF-8 | 754 | 4.46875 | 4 | [] | no_license |
# Write a method that determines the mean (average)
# of the three scores passed to it, and returns the letter value associated with that grade.
# Numerical Score Letter Grade
# 90 <= score <= 100 'A'
# 80 <= score < 90 'B'
# 70 <= score < 80 'C'
# 60 <= score < 70 'D'
# 0 <= score < 60 'F'
# Tested values are... | true |
5774d8284fe413a3260ca3f2d8c6347407242663 | Ruby | samirdev92/tests-ruby | /lib/01_temperature.rb | UTF-8 | 146 | 2.890625 | 3 | [] | no_license | def ftoc(t_fahr)
t_degré = (t_fahr - 32)*5/9
return t_degré
end
def ctof(t_degré)
t_fahr = ((t_degré.to_f*9/5)+32)
return t_fahr
end
| true |
95ee49fbab3405127f247eb5155dbe62e1fd6fd6 | Ruby | lucasPDY/Gilded-Rose-Kata | /lib/backstage_passes.rb | UTF-8 | 908 | 3.078125 | 3 | [] | no_license | require_relative 'item_wrapper'
class BackstagePasses < ItemWrapper
DAYS_LEFT_TO_DOUBLE_CONCERT_QLTY = 10
DAYS_LEFT_TO_TRIPLE_CONCERT_QLTY = 5
CONCERT_EXPIRY_QLTY = 0
MAX_QLTY_LIMIT = 50
MIN_QLTY_LIMIT = 0
DOUBLE = 2
TRIPLE = 3
def initialize(item)
@item = item
end
def update()
# if ther... | true |
1ad1f71ff20f23ba2e97a7d26d6c0886dfe7c7dc | Ruby | dantrovato/code_wars | /find_missing_letter.rb | UTF-8 | 1,083 | 4.625 | 5 | [] | no_license | #Find the missing letter
# Write a method that takes an array of consecutive (increasing) letters as input
# and that returns the missing letter in the array.
#
# You will always get an valid array. And it will be always exactly one letter
# missing. The length of the array will always be at least 2.
# The array will ... | true |
2d2266c0cd833f3e4162bb216640f553f1877682 | Ruby | kelsonic/exoplanet-analysis | /db/seeds.rb | UTF-8 | 420 | 3.03125 | 3 | [
"MIT"
] | permissive | csv = SmarterCSV.process('./tmp/wowah_data.csv')
p "HOlY MOLY. It converted the csv to an array."
p "The total characters of the file is #{csv.size}"
count = 0
csv.each do |character|
count += 1
Character.create!(
level: character[:level].to_i,
race: character[:race],
charclass: character[:charclass],... | true |
3d281268633c34a92251ffa7ff149a7ff049f24d | Ruby | Teaflavored/App_Academy_Work | /W2D5/Poker/spec/deck_spec.rb | UTF-8 | 997 | 3.359375 | 3 | [] | no_license | require 'deck'
RSpec.describe Deck do
subject(:deck) { Deck.new }
#can return cards back to deck
#deck can deal at most 5 at once
describe "deck properties" do
it "has 52 cards" do
expect(deck.count).to eq(52)
end
it "has array of cards" do
expect(deck.cards).to be_an(Arr... | true |
bd5f77ac5894a4b17c7139790e7e0c9a33401724 | Ruby | hugodmorais/LearnRuby | /LearnToCodeWithRuby/array02.rb | UTF-8 | 3,115 | 4 | 4 | [] | no_license | class Array02
def self.next
numbers = [1, 2, 3, "Hello", 4, nil, 5, []]
numbers.each do |num|
unless num.is_a?(Fixnum)
next
else
puts "The square of #{num} is #{num ** 2}"
end
end
end
# [1,2,3,4,5]
[1, 2, 3, 4, 5].each_with_index do |number, index|
result = nu... | true |
f0dfdae8870cb9a5475c9b712425cf2cff6635cd | Ruby | paulmccarthy42/daily_practice | /code_wars/2_8.rb | UTF-8 | 4,447 | 4.3125 | 4 | [] | no_license | # Mr. Scrooge has a sum of money 'P' that wants to invest, and he wants to know how many years 'Y' this sum has to be kept in the bank in order for this sum of money to amount to 'D'.
# The sum is kept for 'Y' years in the bank where interest 'I' is paid yearly, and the new sum is re-invested yearly after paying tax '... | true |
bc3d7ceca42fdd989bda7fe54954b832737682fb | Ruby | intenex/aA-homeworks | /W2D5/lrucache.rb | UTF-8 | 2,459 | 3.984375 | 4 | [] | no_license | # To create an LRU Cache you need two data structures
# a Queue implemented with a doubly linked list, and a Hash, fucking amazing
# incredible that you just learned this stuff literally by listening to the lectures
# just listen actively and you can figure it out for sure
# You want to use a hash because a hash has in... | true |
306c7a4d8c96132cdb5c7a0d4a52ac17b178eb85 | Ruby | mac718/assignment_ruby_api_calls | /github.rb | UTF-8 | 1,426 | 3 | 3 | [] | no_license | require 'github_api'
require 'pp'
require 'pry'
class GithubAPIWrapper
API_KEY = ENV['GITHUB_API_KEY']
def initialize
@github = Github.new(oauth_token: API_KEY)
end
def grab_repo_list
@repos = @github.repos.list(user: 'mac718').body
end
def grab_commits(repo)
@commits = @github.repos.co... | true |
f6a4b927618d3ab107511aed0412c38512874925 | Ruby | dukhyunko93/ruby-enumerables-hash-practice-nyc-pigeon-organizer-lab-nyc01-seng-ft-062220 | /nyc_pigeon_organizer.rb | UTF-8 | 414 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def nyc_pigeon_organizer(data)
final_results = {}
data.each do |key, value|
value.each do |inner_key, names|
names.each do |name|
if !final_results[name]
final_results[name] = {}
end
if !final_results[name][key]
final_results[name][key] = []
end
... | true |
9d358116458154db1d11c039695a12611bcb617f | Ruby | nacltsutomu/ruby-exercise | /r3_compile_5.rb | UTF-8 | 844 | 3.96875 | 4 | [] | no_license | #ディレクトリの内容を読む
#1
#while文で繰り返す
dir = Dir.open("/Users/tsuto/ruby-exercise/")
while name = dir.read
p name
end
dir.close
# <hint>
# dir.read
# 開いたディレクトリに含まれるものの名前を1つづつ順に返す。
# 最後の要素まで読み出していれば nil を返す。
#2
#eachメソッドで繰り返す
dir = Dir.open("/Users/tsuto/ruby-exercise/")
dir.each do |name|
p name
end
di... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.