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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
015d8a337271b92bddebc8a6725f64a47f940ff9 | Ruby | aramsalimi91/Payback | /app/models/user/expense_extension.rb | UTF-8 | 2,173 | 2.84375 | 3 | [] | no_license | module User::ExpenseExtension
def active_credits(attrs={})
credits.where({ active: true }.merge(attrs)).order('id DESC')
end
def active_debts(attrs={})
debts.where({ active: true }.merge(attrs)).order('id DESC')
end
def active_credits_to(user)
active_credits(debtor_id: user.id)
end
def ac... | true |
bbad2bf5f0dc3fc62be4523b28c28fc7ad169499 | Ruby | YusukeYoshida8849/tbpgr_utils | /lib/open_classes/enumerable/if_else_map.rb | UTF-8 | 317 | 3.171875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
# Enumerable
module Enumerable
# === Example
#
# [*1..4].if_else_map(:odd?.to_proc,->(odd){'奇数'},->(even){'偶数'}) # => ['奇数','偶数','奇数','偶数']
#
def if_else_map(predicate, proc_t, proc_f)
map { |e|predicate.call(e) ? proc_t.call(e) : proc_f.call(e) }
end
end
| true |
fe06fbaee8ba1a440fbca237a03535424f19e639 | Ruby | bellewether/stacks-queues | /job-simulation.rb | UTF-8 | 1,649 | 3.90625 | 4 | [] | no_license | # A company has six hiring positions with more people wanting jobs than the
# number of available positions. The company managers decide in order to give
# more people an opportunity to make money; they will allow people to work in
# three-month intervals. The first five people on the waiting list will be hired
# in t... | true |
92a5037cb5eb6fbfc469e59df7d7158638d57912 | Ruby | DouglasAllen/My_PDF_Lib | /Learn_Ruby_n7weeks/course_ruby_prgrams/p010aliasmtd.rb | UTF-8 | 260 | 3.4375 | 3 | [] | no_license | # p010aliasmtd.rb
# alias new_name old_name
# When a method is aliased, the new name refers
# to a copy of the original method's body
def oldmtd
"old method"
end
alias newmtd oldmtd
def oldmtd
"old improved method"
end
puts oldmtd
puts newmtd | true |
e0c6b810a44f1c30ef151dcb3fb244a825d2309c | Ruby | RobinWagner/LaunchSchool | /programming_and_back-end_development/programming_foundations/101-109_small_problems2/easy5/easy4.rb | UTF-8 | 465 | 4.0625 | 4 | [] | no_license | def swap(words)
words = words.split.each do |word|
word[0], word[-1] = word[-1], word[0]
end
words.join(' ')
end
def swap_first_last_character(word)
word[0], word[-1] = word[-1], word[0]
word
end
def swap(words)
result = words.split.map do |word|
swap_first_last_character(word)
end
result.join... | true |
6b85375da07300665cefff7757ff43aaa7cef772 | Ruby | pangea-project/pangea-tooling | /test/test_retry.rb | UTF-8 | 2,027 | 3.046875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../lib/retry'
require_relative 'lib/testcase'
class RetryHelper
attr_reader :count
def initialize(max_count: 0, errors: [])
@max_count = max_count
@errors = errors
end
def count_up
@count ||= 0
@count += 1
raise 'random' unless @count == @ma... | true |
3b7a2ffd0d7af969430a660f024bddce3c05f056 | Ruby | sweetmandm/get-eps-data | /organizer/getEPS.rb | UTF-8 | 2,230 | 3 | 3 | [] | no_license | # getEPS.rb
require 'rubygems'
require 'nokogiri'
require 'sqlite3'
def usage
puts 'usage: getEPS.rb <directory_of_morningstar_scrape>'
end
def main
scrapedir = ARGV[0]
if !scrapedir
usage
exit
end
setupDatabase
epsFromFiles scrapedir
end
def epsFromFiles (scrapedir)
files = Dir.entries(scrap... | true |
71032db216f348325693d994c49d9adf2c60a6b0 | Ruby | pewniak747/rubido | /commands.rb | UTF-8 | 4,994 | 3.0625 | 3 | [] | no_license | class Command
attr_accessor :description
end
class AddCommand < Command
attr_accessor :tasks
def initialize
@description = "add [description] - adds new task"
end
def success arg
return "Added #{arg}"
end
def run args
task = Task.new
task.name = args.join
if !task.name.empty? then
@tasks.add_t... | true |
ba314d2acd6079df28e9b6b8274b538e5faf6e92 | Ruby | usnationalarchives/federalregister-web | /app/models/facet.rb | UTF-8 | 237 | 2.6875 | 3 | [] | no_license | class Facet
attr_reader :value, :name, :condition, :count
def initialize(options)
@value = options[:value]
@name = options[:name]
@condition = options[:condition]
@count = options[:count]
end
end
| true |
f1814fbf55aeab2cc65daace65f8e431bd535f6b | Ruby | HelioGiroto/cskit-strongs-rb | /lib/cskit-strongs/splitters/hebrew_lexicon_splitter.rb | UTF-8 | 2,065 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
require 'nokogiri'
module CSKitStrongs
module Splitters
class HebrewLexiconSplitter
include Enumerable
include CSKitStrongs::Splitters::Utilities
attr_reader :input_file
def initialize(input_file)
@input_file = input_file
end
def each
doc ... | true |
c13e81507eb05309408a3714c3e61523313439cf | Ruby | fernandezvara/tabelia-v2 | /vendor/plugins/rankings/users/user_ranking.rb | UTF-8 | 1,538 | 2.640625 | 3 | [] | no_license | class UserRanking
def calculate
begining = Time.now.to_i
hashUserScore = Hash.new
hashUserFollowies = Hash.new
hashUserFollowing_to_count = Hash.new
users = User.all
users.each do |user|
hashUserScore[user.id.to_s] = 1.0
hashUserFollowies[user.id.to_s] = Array.new... | true |
a610e1ecb0f8e95bd45881d7d0e9d0369f240233 | Ruby | kparekh01/test-todo-app | /spec/models/task_spec.rb | UTF-8 | 2,271 | 2.703125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Task, type: :model do
describe '#toggle_complete!' do
it 'switches complete to false if it began at true' do
task = Task.new(complete: true)
task.toggle_complete!
expect(task.complete).to eq(false)
end
it 'switches complete to true if it began at... | true |
477dbb29e8fe0b5c6db5acc5fe6c7922136c6725 | Ruby | njpa/launchschool-rb101 | /lesson_6/twenty_one_second_pass.rb | UTF-8 | 6,346 | 3.46875 | 3 | [] | no_license | require 'colorize'
ROUNDS_PER_GAME = 5
FACE_VALUES = %w(2 3 4 5 6 7 8 9 10 Jack Queen King Ace)
FACES = %w(clubs diamonds hearts spades)
def initialize_deck
deck = []
FACES.each do |face|
FACE_VALUES.each do |face_value|
value = face_value.to_i.to_s == face_value ? face_value.to_i : 10
value = [1,... | true |
01501844965b874c7d8c34e447abcbc12b9a5c72 | Ruby | aaroncalander/phase-0-tracks | /ruby/hashes.rb | UTF-8 | 1,813 | 3.953125 | 4 | [] | no_license | # Pseudocode:
# Ask user questions to get client details.
# Convert input values to correct data type using built in String methods.
# Create client_survey hash with keys and values equal to input.
# Print hash when all questions have been answered and all keys have a value.
# Allow user to update the value of a key i... | true |
0124e7da4f14539f094c719850fb0b7e8bd049a9 | Ruby | rscole87/W2D1 | /chess/display.rb | UTF-8 | 933 | 3.265625 | 3 | [] | no_license | require_relative "board"
require_relative "cursor"
require "colorize"
require "byebug"
class Display
attr_reader :board, :cursor
def initialize(board)
@cursor = Cursor.new([0,0], board)
@board = board
end
def render
cursor_pos = cursor.cursor_pos
(0...board.gr... | true |
97f4dbefd7646cbfa373e21adb0e4639e1384edf | Ruby | eprothro/cassie | /lib/cassie/schema/migrator.rb | UTF-8 | 3,400 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'benchmark'
module Cassie::Schema
require_relative 'apply_command'
require_relative 'rollback_command'
class Migrator
attr_reader :target_version, :current_version, :direction
attr_reader :commands
attr_accessor :before_each, :after_each
def initialize(target)
@target_version =... | true |
b2fd321f0e673cb73497e04fe21a2e6309df073a | Ruby | archemars/ruby | /rb5.rb | UTF-8 | 1,630 | 4.09375 | 4 | [] | no_license | require "date"
birthday = Date.new(1111, 2, 3)
puts birthday
puts birthday.sunday?
today = Date.today
puts today
puts today.sunday?
class Menu
attr_accessor :name
attr_accessor :price
def initialize(name:, price:)
self.name = name
self.price = price
end
def info
return "#{self.name} #... | true |
942d39ed7644bdabdc36ef745b4f83bd61cd5a3b | Ruby | shu0115/opal | /stdlib/pathname.rb | UTF-8 | 1,733 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'corelib/comparable'
class Pathname
include Comparable
def initialize(path)
if Pathname === path
@path = path.path.to_s
else
@path = path.to_s
end
raise ArgumentError if @path == "\0"
end
attr_reader :path
def == other
other.path == @path
end
def absolute?
... | true |
7acf232bc86ed63d5d0948993b762214186a7abe | Ruby | pbragamiranda-teaching/food-delivery-login-day2-609 | /app/views/customers_view.rb | UTF-8 | 373 | 3.28125 | 3 | [] | no_license | class CustomersView
def list(array_of_customers)
array_of_customers.each_with_index do |customer, index|
puts "#{index + 1}. #{customer.name} - #{customer.address}"
end
end
def ask_for(customer_attribute)
puts "What's the #{customer_attribute}?"
gets.chomp
end
def ask_for_index
pu... | true |
6738d9e21e7a3cf4df5322916e7f1e87b8563b88 | Ruby | saheb222/ruby_practice | /basics/program_end.rb | UTF-8 | 118 | 2.703125 | 3 | [] | no_license |
puts "hello there"
__END__
#this ends the program hence rest of the code will not be exectuted
puts "hi"
puts "hey" | true |
9a7ee326ea66791297ec02e6dd7c8b9c6803a118 | Ruby | alphagov/collections | /app/models/content_store_organisations.rb | UTF-8 | 1,354 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | require "active_model"
class ContentStoreOrganisations
include ActiveModel::Model
attr_reader :content_item
def initialize(content_item)
@content_item = content_item
end
def live?
organisation_state == "live"
end
def self.find!(base_path)
content_item = ContentItem.find!(base_path)
ne... | true |
117dbbb0c86a86a62ad6805a49969f73aa494b2a | Ruby | saralynnazuk/lrthw | /ex33/ex33_drills01_02.rb | UTF-8 | 476 | 4.3125 | 4 | [] | no_license | #drill 1 - Convert this while-loop to a function that you can call, and replace 6 in the test (i < 6) with a variable.
#drill 2 - Use this function to rewrite the script to try different numbers.
def loop(limit)
i = 0
numbers = []
while i < limit
puts "At the top i is #{i}"
numbers.push(i)
i += 1
... | true |
f45fc4931dc11d9418a2324b904a2cf8f77c6025 | Ruby | eprendergast/oo-relationships-practice-london-web-082619 | /app/models/listing.rb | UTF-8 | 901 | 3.4375 | 3 | [] | no_license | class Listing
@@all = []
attr_accessor :city
def initialize(city)
@city = city
@@all << self
end
def self.all
@@all
end
def trips
#returns an array of all trips at a listing
Trip.all.select{ |trip| trip.listing == self }
end
def guests
#r... | true |
f9bc2196dc354ba0a7a75670790c759def313aaa | Ruby | Catsuko/checkers | /checkers-rails/app/models/game.rb | UTF-8 | 2,183 | 2.671875 | 3 | [] | no_license | class Game < ApplicationRecord
has_one :turn, dependent: :destroy
belongs_to :jumping_piece, class_name: 'Piece', optional: true
with_options class_name: 'Player' do
belongs_to :first_player
belongs_to :second_player
end
has_many :pieces, dependent: :delete_all
def self.store(attributes)
Game.c... | true |
b65d5faf82694c577a3b4d8d21855a74c6ca9180 | Ruby | SergiySergienko/rtest | /app/models/player_base.rb | UTF-8 | 2,085 | 3.078125 | 3 | [] | no_license | class PlayerBase
attr_accessor :player_id, :player_name, :player_cards, :core
def initialize(player_name)
self.player_name = player_name
self.player_cards = []
end
def update(data)
self.core = data
end
def get_player_cards
result = []
if not self.player_cards.nil?
result = self.player_cards
... | true |
ee36706de926422f95b82a5c41fcf8b6715ec22c | Ruby | katreesedarcene/ruby-intro-to-arrays-lab-online-web-prework | /lib/intro_to_arrays.rb | UTF-8 | 682 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
@my_new_array = Array.new
return @my_new_array
end
def array_with_two_elements
@my_new_array = Array.new(2)
return @my_new_array
end
def first_element(array)
array = @taylor_swift[0]
return array
end
def third_element(array)
array = @taylor_swift[2]
return array
e... | true |
44d179e5fb0c2da71a0af604fb0d09bf501cc2b4 | Ruby | aczid/ruby_patterns | /behavioral/mediator.rb | UTF-8 | 1,251 | 3.96875 | 4 | [] | no_license | #!/usr/bin/ruby
# This example demonstrates the mediator pattern in the Ruby language.
class Mediator
def initialize
@colleagues = Hash.new
end
end
class Colleague
def initialize(id)
@id = id
@mediator = nil
end
def register_mediator(mediator)
@mediator = mediator
end
def get_id
... | true |
ffc13c8db3e37c3db2b6ac90b9de1a6df968f3f5 | Ruby | capoferro/thor-package | /lib/thor-package.rb | UTF-8 | 1,659 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require 'thor'
require 'thor/actions'
module ThorPackage
class Tasks < Thor
include Thor::Actions
namespace "package"
desc "build", "Build a tar from the files tracked by git"
def build
cleanup
run "git archive --format=tar -o #{pkg_path}/tarfile HEAD"
run "tar rf #{pkg_path}/tarf... | true |
aa22b037f4eea2a7ec1ea01034a98dd6e3b0c3f7 | Ruby | ideacrew/aca_entities | /lib/aca_entities/maps/entities/geo_json/coordinate.rb | UTF-8 | 1,145 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module AcaEntities
module Maps
module GeoJson
# A position in space represented as a set of decimal numbers. The first two
# elements are longitude and latitude, or easting and northing. Altitude or elevation
# MAY be included as an optional third element. Line... | true |
15a7255cddd7832926afa5bfbf492901a69a5d8e | Ruby | kumarsaurabh20/NGShelper | /Phylogenomics/old_scripts/test_mod_fasta.rb | UTF-8 | 376 | 2.8125 | 3 | [] | no_license | class FormatFasta
def nameChange
count = 0
file = ARGV[0].to_s
file = IO.readlines(file)
file2 = file.map {|e| e.strip}
file3 = file2.each_with_index do |e,i|
if e.include?(">missing_-m_qualifer")
e.replace(">Hchl|#{i}")
else
next
end
end
puts file3
... | true |
83e71e7b79e65034cd9c284342f8c48d39521f51 | Ruby | waxnyc/Metis-Prework | /CP_LTP/Chapter8/ch8_array_exercise.rb | UTF-8 | 211 | 3.46875 | 3 | [] | no_license | puts "Hi, Rectangle People. Please give me some words. Any word will do. Start...NOW!"
words = Array.new
while true
word = gets.chomp
if word == ""
break
end
words.push(word)
end
puts words.sort
| true |
4cca54d6b4652aa7400067bc9acf9aa6e3ac7be2 | Ruby | Mathieu5419/mise_en_chauffe | /lib/03_word_counter.rb | UTF-8 | 604 | 3.609375 | 4 | [] | no_license | def hash_add(hash, key)
if (hash.key?(key))
hash[key] += 1
else
hash[key] = 1
end
end
def word_counter(str, dictionnary)
corps = str.split(" ")
res = {}
for word in corps do
for known_word in dictionnary do
if (word.downcase.include?(known_word.downcase))
h... | true |
2a1850e68ec9234aad731e18e96a0c32514b48cc | Ruby | n1koo/znet_local_to_statsd | /lib/znet_local_to_statsd.rb | UTF-8 | 3,867 | 2.625 | 3 | [
"MIT"
] | permissive | require "znet_local_to_statsd/version"
require 'json'
require "net/http"
require 'uri'
require 'statsd-ruby'
module ZnetLocalToStatsd
STATSD_NAMESPACE = "tellstick"
class << self
def run
@stick_address = ENV['STICK_ADDRESS'] || "tellstick"
@file_path = ENV['TOKEN_LOCATION'] || "#{Dir.home}/.tells... | true |
08b045033a9d9896d51eaefbd2bd2a43049a7ba3 | Ruby | Eduki/eduki | /app/models/quiz_attempt.rb | UTF-8 | 1,469 | 2.734375 | 3 | [] | no_license | # == Schema Information
#
# Table name: quiz_attempts
#
# id :integer not null, primary key
# quiz_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# enrollment_id :integer not null
#
class QuizAttempt < ActiveRecord::Base
attr_... | true |
dd95151fb7581c3291a2fa6a38be739c4e288fb7 | Ruby | SKG360/black_thursday | /test/item_test.rb | UTF-8 | 3,127 | 2.859375 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require 'minitest/autorun'
require 'minitest/pride'
require 'bigdecimal'
require 'time'
require './lib/item'
class ItemTest < Minitest::Test
def test_it_exists
i = Item.new({
id: 1,
name: 'Pencil',
description: 'You can use it to write things',
unit_pri... | true |
9bb8fbf9b94583ca41d44704140bf1b816fce87a | Ruby | ruby-processing/The-Nature-of-Code-for-JRubyArt | /chp03_oscillation/NOC_3_03_pointing_velocity/mover.rb | UTF-8 | 902 | 2.734375 | 3 | [
"MIT"
] | permissive | class Mover
include Processing::Proxy
attr_reader :location, :mass, :velocity
def initialize(location:)
@location = location
@velocity = Vec2D.new
@topspeed = 4
@xoff = 1_000
@yoff = 0
end
def update(mouse:)
dir = mouse - location
dir.normalize!
dir *= 0.5
@velocity += di... | true |
5e13bba00dadfd6fe2c77c21bfc8e6064b6dc51e | Ruby | wolfravenous/rlc | /p003rubystrings.rb | UTF-8 | 702 | 3.78125 | 4 | [] | no_license | # p003rubystrings.rb
=begin
Ruby Strings
In Ruby, strings are mutable
=end
puts "Hello World"
# Can use " or ' for Strings, but ' is more efficient
puts 'Hello World'
# String concatenation
puts 'I like' + ' Ruby'
# Escape sequence
puts 'It\'s my Ruby'
# New here, displays the string three times
puts 'Hello' * 3
#... | true |
fa01f5b69d16d3e4bd64d0da33d19e26fcf6c8dc | Ruby | noemi-ashizuka/595_ar_basics | /db/seeds.rb | UTF-8 | 313 | 2.90625 | 3 | [] | no_license | # This is where you can create initial data for your app.
require 'faker'
puts "Creating Restaurants"
# land = Restaurant.create!(name: "Land", address: "Meguro")
20.times do
Restaurant.create!(
name: Faker::Restaurant.name,
address: Faker::Address.city,
rating: rand(0..5)
)
end
puts "Done!"
| true |
cfb61a8113fa5df7933ded74992922a712193c3c | Ruby | aag1091/html-schema | /lib/html-schema/api/attribute.rb | UTF-8 | 1,173 | 2.515625 | 3 | [
"MIT"
] | permissive | class HTMLSchema
class API
class Attribute < HTMLSchema::Attribute
def microdata
if @microdata.nil?
object = HTMLSchema.instance.microdata[parent]
object = object[_name] if object
object = false if object.blank?
@microdata = object
end
... | true |
01d97e9bc60802fdd30e47b010cb9a956e8836b7 | Ruby | tfabery/Ruby_Rock-paper-scissors | /lib/rps.rb | UTF-8 | 1,521 | 3.203125 | 3 | [] | no_license | class String
define_method(:beatsai) do
play = ["rock", "paper", "scissors"]
p1 = self.downcase()
p2 = play[rand(3)]
result = ''
play.each_with_index do |val, idx|
if p1 == val
if p2 == play[idx]
result = "tied"
elsif p2 == play[idx - 1]
result = "win"
... | true |
d2dd2c6638ea86753372ec72e6c911a0082916ad | Ruby | NancyKo/super-sinatra-forms-web-0715-public | /app.rb | UTF-8 | 1,131 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'sinatra/base'
class Superhero
attr_accessor :name, :power, :biography
def initialize(params)
@params = params
end
end
class Team
attr_accessor :name, :motto
def initialize(params)
@params = params
end
end
class App < Sinatra::Base
get '/' do
erb :'/super_hero'
end
post '/teams' do
@tea... | true |
be48f9358af588074699e649614e3450c477edc3 | Ruby | pmanni02/api-muncher | /lib/recipe_search_wrapper.rb | UTF-8 | 1,071 | 2.828125 | 3 | [] | no_license | require 'httparty'
class RecipeSearchWrapper
URL = "https://api.edamam.com/"
APP_ID = ENV["APP_ID"]
APP_KEY = ENV["APP_KEY"]
@recipe_list = []
def self.list_recipes(search)
encoded_uri = URI.encode("#{URL}search?q=#{search}&app_id=#{APP_ID}&app_key=#{APP_KEY}&from=0&to=30")
response = HTTParty.get... | true |
e8c8439c3902b3a79691ba83a315b211522f6bf3 | Ruby | ahorner/advent-of-code | /lib/2021/19.rb | UTF-8 | 1,660 | 3.3125 | 3 | [] | no_license | require "set"
SCANS = INPUT.split("\n\n").map do |scan|
_name, *coords = scan.split("\n")
coords.map { |coord| coord.split(",").map(&:to_i) }
end.freeze
class Scanner
ROTATIONS = [0, 1, 2].permutation.to_a.freeze
INVERSIONS = [1, -1].repeated_permutation(3).to_a.freeze
def initialize(scan)
@scan = scan... | true |
414df94c512e6d6e052646ab9b1eacd2bf07c57a | Ruby | geebabygee/cookbook-reboot | /lib/view.rb | UTF-8 | 523 | 3.296875 | 3 | [] | no_license | class View
def display(recipes)
recipes.each_with_index do |recipe, index|
# prep_time = recipe.prep_time.nil? ? " " : "(#{recipe.prep_time})"
done = recipe.done? ? "[X]" : "[ ]"
puts "#{index + 1}. #{done} #{recipe.name}: #{recipe.description} (#{recipe.prep_time})"
end
end
de... | true |
eefdbf3d498fdef8adc78f6856beb065fcaa7b38 | Ruby | raul/conferencia_rails_2009 | /sinatra/14_errors/errors.rb | UTF-8 | 770 | 2.84375 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
# Visit /fail to see a generic error page,
# /epic-fail to see an error page for custom error
# / to see a nice 404
# - - - Controllers - - - #
get '/epic-fail' do
raise EpicFailError, 'EPIC FAIL!!!'
"Visit /fail to see error page and /foo to see a nice 404"
end
... | true |
6599e10f8df4c266090473963631e19187853bc0 | Ruby | Gegardus/ruby_koans_rspec_expect | /spec/about_control_statements_spec.rb | UTF-8 | 2,916 | 3.703125 | 4 | [] | no_license | require 'spec_helper'
describe "Control Statements" do
it "should demonstrate if_then_else_statements" do
if true
result = :true_value
else
result = :false_value
end
expect(result).to eql __
end
it "should demonstrate if_then_statements" do
result = :default_value
if true
... | true |
7b5d5631337884e5df1d0bd120cd3f91d5d2896b | Ruby | yltsrc/targetprocess-ruby | /lib/target_process/api_error.rb | UTF-8 | 859 | 2.734375 | 3 | [
"MIT"
] | permissive | module TargetProcess
class APIError < StandardError
class BadRequest < APIError; end
class NotFound < APIError; end
class MethodNotAllowed < APIError; end
class InternalServerError < APIError; end
class Forbidden < APIError; end
class NotImplemented < APIError; end
class Unauthorized < API... | true |
ef28ef882b801373f9d1a8870fa67b4d8789e117 | Ruby | nordus/zinlot | /app/models/geofence.rb | UTF-8 | 895 | 2.546875 | 3 | [] | no_license | require 'open-uri'
require 'json'
class Geofence
def self.is_boundary(geofence_id)
boundaries[String(geofence_id)]
end
def self.boundaries
return @boundaries if @boundaries
spreadsheet_url = 'https://script.googleusercontent.com/macros/echo?user_content_key=9jo2erGNd3OfAIwxTngNOvdZGibZdqOHgm-v3xG... | true |
e689cd0102278e382275ba8968fe894f8c4983cb | Ruby | mfiore/tom | /combat/combat_manager.rb | UTF-8 | 1,917 | 2.796875 | 3 | [] | no_license | class CombatManager
def manageCombat(enemies,party)
enemies.each do |e|
initiative=e.rollInitiative
turn_order.add([e,initiative])
end
party.each do |p|
initiative=p.rollInitiative
turn_order.add([p,initiative])
end
turn_order.sort {|x,y| x[1]<y[1]}
n_party_dead=0
n_enemies_dead=0
charac... | true |
e1849f76cc8ac373c4aff3c8b4fcd5dd69fa6719 | Ruby | kgilla/building-blocks | /lib/caesar.rb | UTF-8 | 744 | 3.15625 | 3 | [] | no_license | def encode(string, key)
converted = ""
string.each_byte do |c|
if c >= 97 && c <= 122
c = c - 97 + key
if c > 0
c = (c % 26) + 97
else
while c < 0
c += 26
end
c += 97
end
... | true |
d52d6a332eeff90def00b33fa7149f15bd3d30b8 | Ruby | radarek/brainyplex-utils | /lib/brainyplex/level/packager.rb | UTF-8 | 1,116 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'stringio'
module Brainyplex
module Level
class Packager
def initialize(logger = nil)
@logger = logger
end
def package_files(data_file, metadata_file, output_file)
data = Brainyplex::Level::Data.from_binary(File.read(data_file, encoding: 'binary'))
metadata = Br... | true |
01fb3ae9f940b95c6eb8261a4b11a501d95d73cd | Ruby | wycats/rake-pipeline-web-filters | /lib/rake-pipeline-web-filters/minispade_filter.rb | UTF-8 | 2,413 | 2.6875 | 3 | [
"MIT"
] | permissive | module Rake::Pipeline::Web::Filters
# A filter that wraps JavaScript files in a minispade.register closure
# for use in minispade.
#
# @example
# !!!ruby
# Rake::Pipeline.build do
# input "app/assets", "**/*.js"
# output "public"
#
# # Wrap each JS file in a minispade.register closur... | true |
ce77849c1c400481599daf2a4a1a8eb766511700 | Ruby | Alex223124/banking_application | /lib/accounts/customer_account.rb | UTF-8 | 4,460 | 3.640625 | 4 | [] | no_license | # Definition of Customer Account Class
# This is the class that all customer accounts will inherit from.
# It has been implemented so that the master account will not have certain features, such as overdraft
class CustomerAccount < BaseAccount
# inherits from base account
attr_reader :interest_rate, :daily_limit, :... | true |
cab425320dbb9a2b411a10f609d5bca12a58c1b7 | Ruby | adamspittler/phase-0-tracks | /ruby/gps_2.2.rb | UTF-8 | 2,321 | 4.65625 | 5 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# Split input string into an array.
# Define hash
# use block to iterate through array adding to array as key and 1 as the value
# print the list to the console
# output: A hash with a k... | true |
5497262daf0989b77fa64aeba7168feb54494c43 | Ruby | ConSou/algorithms_and_complexity | /assignment_two/binary_search_iterative.rb | UTF-8 | 373 | 3.921875 | 4 | [] | no_license | def binary_search(collection, value)
low = 0
high = collection.length - 1
while low <= high
mid = (low + high) / 2
if collection[mid] > value
high = mid - 1
elsif collection[mid] < value
low = mid + 1
else
return mid
end
end
return "Value not found."
end
array = [0, 1,... | true |
cb5f2acc86c90b1be518e3745e64e2eab8484703 | Ruby | coduery/savings_organizer | /app/helpers/accounts_helper.rb | UTF-8 | 919 | 2.78125 | 3 | [] | no_license | module AccountsHelper
def self.get_account_id(user_id, account_name)
user_account = get_user_account(user_id, account_name)
if !user_account.empty?
account = user_account.first
account_id = account[:id]
else
account_id = nil
end
end
def self.get_account_names(user_id)
accou... | true |
0f3c8e26922192732f6d3d3b01bf08f0c0f72ad3 | Ruby | davidjkim810/wardrobe_organizer | /app/models/wardrobe.rb | UTF-8 | 309 | 2.609375 | 3 | [
"MIT"
] | permissive | class Wardrobe < ActiveRecord::Base
belongs_to :user
has_many :categories
has_many :items
def slug
self.name.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
end
def self.find_by_slug(name)
Wardrobe.all.find do |wardrobe|
wardrobe.name.downcase == name.gsub('-', ' ')
end
end
end
| true |
a081bfdc03c25c806cf6e7b21f5a4f61c45a6a99 | Ruby | amorphid/learn_to_program | /spec/ch_7.5_99_bottles_of_beer_on_the_wall_spec.rb | UTF-8 | 814 | 3.6875 | 4 | [] | no_license | # “99 Bottles of Beer on the Wall.” Write a program that prints out the lyrics
# to that beloved classic, “99 Bottles of Beer on the Wall.”
require "ch_7.5_99_bottles_of_beer_on_the_wall"
describe "99 Bottles of Beer on the Wall" do
describe "Dynamic verse" do
it "should include '99 bottles'"do
dynamic_v... | true |
71fd4e0a94401e99692b6b4fdf0a954f8a800d35 | Ruby | anfperez/ldap-csv-tool | /ldap-csv-tool.rb | UTF-8 | 4,882 | 3.015625 | 3 | [] | no_license | require 'rubygems'
require 'net/ldap'
require 'csv'
require 'rspec'
csv_file = ARGV
def get_ldap_response(ldap)
msg = "Response Code: #{ ldap.get_operation_result.code }, Message: #{ ldap.get_operation_result.message }"
raise msg unless ldap.get_operation_result.code == 0
end
#connects to the LDAP serve... | true |
291c328e0c66f56dfabdc13e41f773cc92680344 | Ruby | ajesler/s3-signed-url | /lib/s3_signed_url/cli.rb | UTF-8 | 1,102 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'trollop'
require 'aws/creds'
require 's3_signed_url/manager'
require 's3_signed_url/version'
require 'chronic'
module S3SignedUrl
class CLI
def start
opts = Trollop::options do
version "s3signedurl #{S3SignedUrl::VERSION} (c) Andrew Esler 2013"
banner <<-BANNER
This is the progra... | true |
aa5fe98e84c6e88375c0ebf33f81839a49d40c81 | Ruby | devver/germinate | /spec/germinate/publisher_spec.rb | UTF-8 | 3,578 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.expand_path(
File.join(File.dirname(__FILE__), %w[.. .. lib germinate]))
module Germinate
describe Publisher do
before :each do
@name = "my_pub"
@hunk = stub("Input Hunk")
@output = stub("Pipeline Output")
@pipeline = stub("Pipeline", :call => @output)
... | true |
5c8673646b17e7972662ea5dabfbda2468a3d7a0 | Ruby | northofnormal/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 192 | 3.359375 | 3 | [] | no_license | def add(number, number2)
number + number2
end
def subtract(number, number2)
number - number2
end
def sum(array)
if array = []
return 0
elsif array = 7
return array
end
end
| true |
b01315604a3ec9c06603af40f4f3cafc6f83eeaf | Ruby | smithjason/prime_numbers | /helpers/prime_helper.rb | UTF-8 | 815 | 3.828125 | 4 | [] | no_license | class PrimeHelper
BASE_PRIMES = [2,3]
# input: integer representing the Nth Prime
# output: array of integers that are prime numbers
def self.primes_to_nth_prime(nth_prime)
# return empty array if nth_prime is 0 or negative
return [] if nth_prime < 1
# returns first or both primes up to nth_prime i... | true |
378b9e0eaa52b210d98abd3d59b6ed58be873804 | Ruby | gengogo5/atcoder | /ABC/abc243/ABC243_B.rb | UTF-8 | 210 | 3.03125 | 3 | [] | no_license | N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
AB = A & B
eq = 0
nq = 0
AB.each do |ab|
if A.find_index(ab) == B.find_index(ab)
eq += 1
else
nq += 1
end
end
puts eq
puts nq
| true |
f73b9336283ff667d480fc04ccf7d5b1d0d8e48e | Ruby | pablotron/weather-sage | /lib/weather-sage/cli/env/cache.rb | UTF-8 | 886 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'fileutils'
#
# Create HTTP::Cache fron environment variables.
#
class WeatherSage::CLI::Env::Cache < ::WeatherSage::HTTP::Cache
#
# Default cache path.
#
DEFAULT_PATH = '~/.config/weather-sage/http-cache.pstore'
#
# Create HTTP::Cache fron environment variables.
#
# Uses the following environ... | true |
bd53edc39ab47ba3fe541659ce93d5f0a44e8b66 | Ruby | scharfie/bones | /test/test_cache.rb | UTF-8 | 2,374 | 2.53125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/test_helper'
context "Bones::Cache with default options" do
uses_example_site
setup do
@cache = Bones::Cache.new
@page = @cache.process_page('index')
end
test "should process page correctly" do
assert_include @page, 'src="/stylesheets/styles.css"'
assert... | true |
fd218d9b01a7e1cdfb83190b269d77d21356b50b | Ruby | bu1der/ruby | /basic/class.rb | UTF-8 | 45 | 3.203125 | 3 | [] | no_license | puts 1.class
puts 1.234.class
puts "A String" | true |
b23c64e535fdccb1ae9ad4879aabddf8e4ed289b | Ruby | richwynmorris/ruby_small_problems | /challenges/7kyu_longest_vowel_chain.rb | UTF-8 | 1,333 | 4.0625 | 4 | [] | no_license | # The vowel substrings in the word codewarriors are o,e,a,io. The longest of these has a length of 2. Given a lowercase string that has alphabetic characters only and no spaces, return the length of the longest vowel substring. Vowels are any of aeiou.
# solve("codewarriors") == 2
# solve("suoidea") == 3
# solve("iu... | true |
d2f3e49525ab483060873855e57af646d2e025e1 | Ruby | imack5/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 441 | 2.875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
@input = gets.chomp
newStore = Sto... | true |
c8cdeb49062e7b79f46b6f2caee27fee272b2837 | Ruby | obiora22/launch_school | /exercises/unique_item.rb | UTF-8 | 327 | 3.421875 | 3 | [] | no_license | def iq_test(numbers_string)
even = []
odd = []
numbers_string = numbers_string.split
numbers_string.each do |i|
even << i if i.to_i.even?
odd << i if i.to_i.odd?
end
binding.pry
even.size < odd.size ? numbers_string.index(even.first) + 1 : numbers_string.index(odd.first) + 1
end
p iq_test "2 4 7... | true |
5c13c00e3370064b52a910ad878508f0d8422064 | Ruby | clarencekwong/blood-oath | /tools/console.rb | UTF-8 | 1,411 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
c1 = Cult.new... | true |
b7c72e637c80f6e8b6c74ef111fab36ce93bd472 | Ruby | mdoliwa/parser | /lib/analyzers/page_views_analyzer.rb | UTF-8 | 434 | 2.953125 | 3 | [] | no_license | class PageViewsAnalyzer
attr_reader :pages
def initialize
@pages = {}
end
def register_page_view(page_view)
if pages[page_view.page]
pages[page_view.page] += 1
else
pages[page_view.page] = 1
end
end
def print_report
puts pages
.sort_by { |page, page_views_count| -pag... | true |
420239858351d029e518fe7793129b0ff257e50b | Ruby | dalzinho/projecteuler | /euler7.rb | UTF-8 | 586 | 4.46875 | 4 | [] | no_license | # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
# What is the 10 001st prime number?
class Integer
def is_prime?
#nicked from http://stackoverflow.com/questions/3594345/ruby-determine-if-a-number-is-a-prime/37887596#37887596
(2..Math.sqrt(self)).none?... | true |
18cb621f300a4194c122107e81445a739f9476d0 | Ruby | eriksacre/todolist | /app/interactors/interactor_base.rb | UTF-8 | 1,524 | 2.5625 | 3 | [] | no_license | class InteractorBase
def self.dependencies *args
args.each do |dependency|
define_method("#{dependency}=".to_sym) do |value|
instance_variable_set("@#{dependency}", value)
end
define_method("#{dependency}".to_sym) do
value = instance_variable_get("@#{dependency}")
... | true |
8e63c03456832547b5cb28bf64ace2e5b7726e91 | Ruby | yuqiqian/ruby-leetcode | /155_min_stack.rb | UTF-8 | 623 | 3.5 | 4 | [] | no_license | class MinStack
# Initialize your data structure here
def initialize
@data = []
@min_data = []
end
# @param {Integer} x
# @return {Void} nothing
def push(x)
@data << x
if @min_data.empty?
@min_data << x
else
@min_data << [@min_data[... | true |
2e88455e5ba4952a21104a8c42b45b6c845d6d74 | Ruby | kevinrutherford/ordered-jobs | /lib/roster.rb | UTF-8 | 397 | 3 | 3 | [] | no_license | require './lib/instruction'
require './lib/job'
class Roster
def initialize(spec)
@jobs = {}
instructions = spec.split("\n")
instructions.map {|instr| Instruction.parse(instr, self) }
end
def job(name)
@jobs.fetch(name) { create_job(name) }
end
def ordered_jobs
@jobs.values.sort
end
... | true |
a16cc58404026a3e1167e972cb0d630ef5fe15e3 | Ruby | clm21020/Diggable | /app/models/listing.rb | UTF-8 | 2,129 | 2.65625 | 3 | [] | no_license | # == Schema Information
#
# Table name: listings
#
# id :integer not null, primary key
# price :integer not null
# listing_type :string
# street_1 :string not null
# street_2 :string
# city :string not null
# state :string no... | true |
df37a33d3ff38aa743f13c6f15bee114ef41de69 | Ruby | rizo/crystal | /spec/type_inference/if_spec.rb | UTF-8 | 757 | 2.75 | 3 | [] | no_license | require 'spec_helper'
describe 'Type inference: if' do
it "types an if without else" do
assert_type('if 1 == 1; 1; end') { union_of(int32, self.nil) }
end
it "types an if with else of same type" do
assert_type('if 1 == 1; 1; else; 2; end') { int32 }
end
it "types an if with else of different type" ... | true |
d4497da316614438eb2149aaeabd970c084fb891 | Ruby | hommah/ruby_beginner | /own/array_test.rb | UTF-8 | 337 | 2.984375 | 3 | [] | no_license | train_types = ["local","rapid","express"]
exam_scores = [40,35,22,70,90]
fruits_prices =[["apple",200],["orange",100],["mellon",450000]]
puts train_types
#puts train_types[2]
print fruits_prices[1]#[1]
#puts fruits_prices[2][0]
puts train_types.index("rapid")
fruits_prices.each { |fp|
puts "name:#{fp[0]}, price:... | true |
d62aedc16611f1b017c71741d3c62cf3673efd18 | Ruby | Appsgauge/liquid_markdown | /spec/liquid_markdown_spec.rb | UTF-8 | 3,251 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe LiquidMarkdown::Render do
subject { described_class }
it 'has a version number' do
expect(LiquidMarkdown::VERSION).not_to be nil
end
it 'expect template string on initialize' do
expect { subject.new }.to raise_error(ArgumentError)
end
context '.Liquidize' do
it... | true |
0f86b21a7d5e7a464f22fc16d65a9198d5eec5f3 | Ruby | alina-gutsul/Redmine-Plugin | /app/models/author.rb | UTF-8 | 539 | 2.515625 | 3 | [] | no_license | class Author < ActiveRecord::Base
belongs_to :user
belongs_to :project
validate :if_already_added
def self.all_from_project(id)
where(project_id: id).map do |author|
{
id: author.id,
firstname: author.user.firstname,
lastname: author.user.lastname,
login: author.user.... | true |
185be50212badb9b485fcbef8b268aa08e0104b6 | Ruby | coreypnorris/customer_support_metrics | /transformer/app/send_to_widget_methods.rb | UTF-8 | 13,825 | 2.578125 | 3 | [] | no_license | require 'active_record'
require 'date'
require 'week_of_month'
require 'pry'
Dir[File.dirname(__FILE__) + '/lib/*.rb'].each {|file| require file }
def send_response_time(current_value, pp_value, ly_value, time_period)
HTTParty.post("http://#{request.host}:3030/widgets/response_time_#{time_period}", :body => {curren... | true |
0fd43659c5f264dbb46f0862f9dba490a5f0f906 | Ruby | mjacobus/capistrano-tarball | /lib/capistrano/tarball.rb | UTF-8 | 1,862 | 2.53125 | 3 | [
"MIT"
] | permissive | require "capistrano/tarball/version"
module Capistrano
class Tarball < SCM
# required as a default strategy for overwriting the abstract methods
module DefaultStrategy
end
# @abstract
#
# Your implementation should check the existence of a cache repository on
# the deployment target
... | true |
516264304d4e436353d4d8ab777eae8c09f8b1c5 | Ruby | jevargasv/MakersBnB | /spec/webhelpers.rb | UTF-8 | 1,928 | 2.65625 | 3 | [] | no_license | def sign_up
visit('/')
fill_in('email', with: 'josh@wemail.com')
fill_in('password', with: 'secretpassword')
click_button("Sign up")
end
def sign_up_and_sign_in
sign_up # as josh@wemail.com
fill_in('email', with: 'josh@wemail.com')
fill_in('password', with: 'secretpassword')
click_button("Log in")
end
... | true |
d425167c8c97cef5689de2b7de747974ba2ab1ae | Ruby | polyfox/moon-packages | /lib/moon/packages/test/logger.rb | UTF-8 | 891 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'test/colorize'
module Moon
module Test
class Logger
# @!attribute [r] c
# @return [Colorizer]
attr_reader :c
# @!attribute io
# @return [#puts, #write]
attr_accessor :io
def initialize(io = nil)
@c = Colorizer.new
@io = io || STDERR
en... | true |
4875f887b208475285518d84700ae92bf157f401 | Ruby | aetzion1/sweater-weather | /app/poros/roadtrip.rb | UTF-8 | 303 | 3.015625 | 3 | [
"MIT"
] | permissive | class Roadtrip
attr_reader :id, :start_city, :end_city, :travel_time, :weather_at_eta
def initialize(start_city, end_city, travel_time, weather_at_eta)
@id = nil
@start_city = start_city
@end_city = end_city
@travel_time = travel_time
@weather_at_eta = weather_at_eta
end
end
| true |
3e7847634dde39de0563631c48adb31193c0cc3a | Ruby | JWong411/phase-0-tracks | /web_dev/sinatra_intro/app.rb | UTF-8 | 2,545 | 3.21875 | 3 | [] | no_license | # require gems
require 'sinatra'
require 'sqlite3'
db = SQLite3::Database.new("students.db")
db.results_as_hash = true
# write a basic GET route
# add a query parameter
# GET /
get '/' do
"#{params[:name]} is #{params[:age]} years old."
end
# write a GET route with
# route parameters
get '/about/:person' do
pers... | true |
dd79e5f2d2e7805e5dae4f5e797fdeae17790075 | Ruby | CodeByLine/ruby-music-library-cli-v-000 | /lib/artist.rb | UTF-8 | 1,128 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist #artist keeps a list of songs
extend Concerns::Findable
attr_accessor :name, :songs #, :song,:genre, :genres,
@@all = []
def initialize(name, song=nil, genre=nil)
@name = name
@songs = []
end
def self.all
@@all
end
def save
@@all << self #can't b... | true |
89507c0b7b95400faf4e26f5cc55ca34c6d5def5 | Ruby | EdSabino/UpCaseTDDTrails | /testing-fundamentals-testing-activerecord/spec/models/person_spec.rb | UTF-8 | 556 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Person do
it "invalid without first name" do
person = Person.new()
expect(person).to be_invalid
expect(person.errors.messages).to include(first_name: ["can't be blank"])
end
it "invalid with first_name blank" do
person = Person.new(first_name: "")
expect(person... | true |
a457881ca53bc0df9bd5c306bfad48df97ce6fa9 | Ruby | mrb/tupelo | /lib/tupelo/client/atdo.rb | UTF-8 | 710 | 2.59375 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | require 'tupelo/client'
require 'atdo'
module Tupelo
class Client
class AtDo < ::AtDo
def initialize client, **opts
@client = client
super **opts
end
# Accepts numeric +time+. Logs errors in +action+. Otherwise, same
# as ::AtDo.
def at time, &action
time = ... | true |
c5811c8b12b0f2078ca7c58bdb232c22d8df0ffa | Ruby | mheadd/rap_sheet_parser | /lib/rap_sheet_parser/builders/registration_event_builder.rb | UTF-8 | 535 | 2.515625 | 3 | [
"MIT"
] | permissive | module RapSheetParser
class RegistrationEventBuilder
include EventBuilder
def build
event_syntax_node.updates.each do |update|
logger.warn('Update on registration event:')
logger.warn(update.text_value)
end
RegistrationEvent.new(
date: date,
code_section: co... | true |
e6a0386ff26769aed111da9fbbbe788f5bb78c33 | Ruby | jruby/image_voodoo | /lib/image_voodoo/awt/shapes.rb | UTF-8 | 2,439 | 3.15625 | 3 | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | permissive | # frozen_string_literal: true
class ImageVoodoo
# (Experimental) An attempt at some primitive drawing in images.
module Shapes
# FIXME: if image has alpha values the border shows through since it is
# a solid fill.
##
# *AWT* (experimental) Add a border to the image and yield/return a new
# i... | true |
7719555ea5cc897a3c1ca3c054213e13550fe74d | Ruby | ruaridhdunbar/Pub_Lab | /specs/customer_spec.rb | UTF-8 | 1,735 | 3.3125 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../pub.rb")
require_relative("../customer.rb")
require_relative("../drink.rb")
require_relative("../food.rb")
class CustomerTest < MiniTest::Test
def setup()
@pub = Pub.new("The White Horse", 100)
@customer1 = Customer.new("Ruaridh", 50.0... | true |
e57b03778d5df3da574b73de3409d7d0c52ab9b3 | Ruby | StevenJL/goedel | /lib/goedel/statement.rb | UTF-8 | 1,178 | 2.703125 | 3 | [
"MIT"
] | permissive | module Goedel
class Statement
attr_reader :object, :indent, :force_attributes, :override_attributes
def initialize(object, options={})
@object = object
@force_attributes = options[:force_attributes] || []
@override_attributes = options[:override_attributes] || {}
@indent = 2
end
... | true |
fe56088709dcd745deb273d3a5ca2b7049e4e0e7 | Ruby | avallabh/cash | /cash3.rb | UTF-8 | 3,160 | 3.78125 | 4 | [] | no_license | =begin
USER STORIES
1) As a cashier
I want to display a menu
So that I can make checkout easier
2) As a cashier
I want to prompted to choose items from menu
So I can speed up checkout
3) As a cashier
I want to prompted to choose quantities from menu
So I can speed up checkout
4) As a cashier
I wa... | true |
6889ccee458d509765e877faa32f580470e1c549 | Ruby | mmasaki/Reudy19 | /lib/reudy/word_searcher.rb | UTF-8 | 961 | 2.875 | 3 | [
"BSD-3-Clause"
] | permissive | #ncoding:utf-8
#Copyright (C) 2003 Gimite 市川 <gimite@mx12.freecom.ne.jp>
#Modified by Glass_saga <glass.saga@gmail.com>
require $REUDY_DIR+'/wordset'
KANA_AN = Regexp.compile("([ァ-ンー−][ァ-ンー−]|[a-zA-Z][a-zA-Z])") # #カタカナ又は英数
module Gimite
#文中から既知の単語を探す
class WordSearcher
include Gimite
def initialize... | true |
1e8eeb0463433f2a8799c9b7702e3b4231ea31fb | Ruby | ekmixon/builderator | /lib/builderator/control/version/auto.rb | UTF-8 | 1,752 | 2.546875 | 3 | [
"MIT"
] | permissive | module Builderator
module Control
class Version
##
# Search through commits since current version for #TYPE tags
#
# Included in Version
##
module Auto
DEFAULT_TYPE = 'patch'.freeze
MESSAGE_KEYWORDS = /#(?<type>build|prerelease|release|patch\-prerelease|patch|mi... | true |
e4c09a0b3e5a92a51c27d1e3d2010ab4c02d24a7 | Ruby | fly-will/videofingerprinting | /avisynthLuma_kaist.rb | UTF-8 | 6,571 | 2.890625 | 3 | [] | no_license | #Usage
#avisynthLuma sourceVideo start {-debug}
#benchmarking
stime = Time.new
#Throughout this program, CLIP is the small sequence we want to find, MOVIE is the big sequence we want to search into
#INCLUDES
#
require 'rubygems'
require 'complex'
require 'sqlite3'
#VARIABLES
#
gui = false
debug = f... | true |
8534b38ed8d5e4070bb966f8aab695a49862c2f5 | Ruby | sandri4/softgroup_test | /2.rb | UTF-8 | 260 | 3.625 | 4 | [] | no_license | def index(array, number)
"Your number = #{number}, index in the array = #{array.index(number.to_i)}"
end
p 'Enter a number from the following array, so we can figure it`s index'
p array = [10, 6, 4, 9, 1, 3, 2, 5, 7, 8].sort
p index(array, gets.chomp.to_i)
| true |
05a13e8fdfd661bb010283db39b03a191d62d501 | Ruby | tiffaniechia/food-scripts | /kitchentable.rb | UTF-8 | 967 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'json'
require 'uri'
require 'net/http'
require 'date'
tomorrow = Date.today + 1
def check_availability(date)
availability_uri = URI("https://www.sevenrooms.com/api-yoa/availability/widget/range?venue=kitchentable&time_slot=19:30&party_size=3&start_date=#{date}&num_days=1")
availabili... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.