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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
64b697aa4cc5e5ebbca3a7e1719d60aaba62120a | Ruby | juliangommans/rails_shopping_cart | /app/models/order.rb | UTF-8 | 293 | 2.578125 | 3 | [] | no_license | class Order < ActiveRecord::Base
belongs_to :users
belongs_to :purchase
def total_conversion
items = Purchase.where(order_id: self.id)
total_price = 0
items.each { |item| total_price += Product.find_by(id: item.product_id).price}
self.total = total_price/100.0
end
end
| true |
6a001096ba6d07569baf5e9ff2c7d3fc6f107a1a | Ruby | Digital-Learner/prime_numbers | /lib/code_challenge/challenge.rb | UTF-8 | 183 | 2.8125 | 3 | [] | no_license | module CodeChallenge
class Challenge
def initialize(output)
@output = output
end
def main
@output.puts 'Challenge : Prime multiplication'
end
end
end | true |
ed5860b00a33cde2c80a7de06f2cff2c329404f3 | Ruby | andrewstucki/sinkhole | /spec/sinkhole/support/command_ensures.rb | UTF-8 | 3,004 | 2.734375 | 3 | [
"MIT"
] | permissive | def it_ensures_states(*states)
it "should not error when all the states are present" do
connection = mock()
connection.stubs(:state).returns(states)
expect do
begin
obj = described_class.new([], connection)
obj.stubs(:do_process)
obj.process
rescue Sinkhole::Errors::Com... | true |
6ba18a54003fa5c5a3eef401b10ac9031d7d1de1 | Ruby | Diazblack/day_hike | /spec/features/user_goes_to_trip_show_spec.rb | UTF-8 | 1,304 | 2.6875 | 3 | [] | no_license | require 'rails_helper'
describe 'User goes to hiking trips index ' do
before do
@trip_1 = create(:trip)
@trip_2 = create(:trip)
@trail_1 = create(:trail, trip: @trip_1)
@trail_2 = create(:trail, trip: @trip_1)
@trail_3 = create(:trail, trip: @trip_2)
@trail_4 = create(:trail, trip: @trip_2)
... | true |
a6668fc4f557e7c5281950a8e6f25152dfe7f0b1 | Ruby | kristinalim/schedule_attribute | /lib/schedule_attribute/parser.rb | UTF-8 | 1,514 | 2.859375 | 3 | [] | no_license | module ScheduleAttribute
class Parser
def self.parse_schedule(type, value)
value = String.new(value)
schedules = []
while (line = value.slice!(/\A[\r\n]*[^\r\n]+[\r\n]*/))
line = ActiveSupport::Multibyte::Handlers::UTF8Handler.strip(line)
start_time, end_time = [nil, nil]
... | true |
c2dad594363bc7e13fc6706f47ffb95d3cac534c | Ruby | mnylen/image_tools | /lib/image_tools/image_analyzer.rb | UTF-8 | 483 | 2.78125 | 3 | [] | no_license | module ImageTools
class ImageAnalyzer
def self.analyze(file_name)
width, height, mime_type = %x{exiftool -T -ImageWidth -ImageHeight -MimeType "#{file_name}"}.split
{:width => value_or(width, 0).to_i,
:height => value_or(height, 0).to_i,
:mime_type => value_or(mime_type, "a... | true |
879555715dc5afa6d8d2cadf5e6a32568b6f44f3 | Ruby | esakat/ruby-cherry-book | /memos/chap10/proc_sample2.rb | UTF-8 | 911 | 4.5 | 4 | [] | no_license | def greeting(&block)
puts block.class # => Proc
text = block.call('こんにちは')
puts text
end
# 普通にブロック
greeting do |text|
text * 2
end
# Procを渡す
repeat_proc = proc { |text| text * 2 }
# &指定が必要
greeting(&repeat_proc)
# 普通の引数として渡すと
def greeting2(not_block)
puts not_block.class # => Proc
text = not_block.call(... | true |
7ebe438db58c21d1dd24c1071171a68ca5159c4f | Ruby | LYunZhi/mathgame | /question.rb | UTF-8 | 239 | 3.75 | 4 | [] | no_license | class Question
def initialize
@first_number = rand(1..20)
@second_number = rand(1..20)
end
def ask_question
"What is #{@first_number} + #{@second_number}?"
end
def answer
@first_number + @second_number
end
end | true |
053228d393d484a9a67a7a029ba2b4ded09c3c53 | Ruby | braxtonlemmon/launch-book-oop | /exercise_part_1.rb | UTF-8 | 1,715 | 3.96875 | 4 | [] | no_license | #!/home/braxton/.rbenv/shims/ruby
module Truck
def cargo_space
puts "You have an 8x3 foot space for cargo."
end
end
class Vehicle
attr_accessor :color
attr_reader :year
@@count = 0
def initialize(year, color, model)
@year = year
@color = color
@model = model
@speed = 0
@@count += 1
end
def sel... | true |
b23f4ed6641377add64b2dca37bb558bf7ced1d2 | Ruby | JFVF/cucumber_022015 | /Jimmy/Session4/modules/greetsAndBye3Lib.rb | UTF-8 | 242 | 2.765625 | 3 | [] | no_license | #Greets and bye to a friend
#require_relative "greets.rb"
#require_relative "bye.rb"
# Lib mode
require "./greetsLib"
require "./byeLib"
#creating the class
Greets.goodAfternoon
Bye.goodBye
Greets.hiFriend
Bye.seeYouLater
Bye.takeCare
| true |
2249ff29270dfa301e4690018460dfecb4de02ff | Ruby | stacybanks514/Practice | /ruby_notes.rb | UTF-8 | 24,731 | 4.15625 | 4 | [] | no_license | # # SCOPE (what objects have access to...)
# Blocks: local variables, method variables, @instance, @@classes, $global
# Methods: method variables, @instance, @@classes, $global
# Instances: @instance, @@classes, $global
# Classes: @@classes, $global
# Global: $Global
#
#
#
#
# ARRAYS**ARRAYS**ARRAYS**ARRAYS**ARRAYS**AR... | true |
674b3d262b211c58f617dfb77ec0d5c6fa95f354 | Ruby | itiut/sutra-copying | /metaprogramming-ruby/c03/ampersand.rb | UTF-8 | 297 | 3.96875 | 4 | [] | no_license | def math(a, b)
yield(a, b)
end
def teach_math(a, b, &operation)
puts "さあ、計算を始めよう:"
puts math(a, b, &operation)
end
teach_math(2, 3) { |x, y| x * y }
def my_method(&the_proc)
the_proc
end
p = my_method { |name| "Hello, #{name}!"}
puts p.class
puts p.call('Bill')
| true |
ee44d47d5003072f72f4edb54c798a3474cad8b2 | Ruby | greensync/json-sequence | /lib/json_sequence/result.rb | UTF-8 | 702 | 2.53125 | 3 | [
"MIT"
] | permissive | module JsonSequence
module Result
class Json
attr_reader :value
def initialize(value)
@value = value
end
def ==(other)
return false unless other.is_a?(self.class)
other.value == value
end
alias eql? ==
end
class ParseError
attr_reader :... | true |
8f27dceaa07f3f46db462dc91e752331d884613d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/filtered-submissions/6a49968f708140a6b34a7917256f56fb.rb | UTF-8 | 267 | 3.265625 | 3 | [] | no_license | def compute( a, b)
count = 0
index = 0
if b.length < a.length
a, b = b, a
end
strandA = a.split('')
strandB = b.split('')
strandA.each do |nucleotide|
if nucleotide != strandB[index]
count += 1
end
index += 1
end
return count
end | true |
d14d40b89cad855e13043275942e28265a5e719a | Ruby | apostolosSotiropoulos/testing-ruby | /arithmetic_utils.rb | UTF-8 | 377 | 3.25 | 3 | [] | no_license | # used like irb "arithmetic_utils.rb"
module ArithmeticUtils
def digital_root
return self if self < 10
digits.sum.digital_root
end
def multiples_until(limit)
[].tap do |m|
i = 1
while i * self < limit
m << i * self
i += 1
end
end
end
end
Integer.include(Arit... | true |
e7a05febf5f790f2fbcbfe20f5cc7d54f84166d0 | Ruby | Dimon4ikD/--------j | /project_polyedr/spec/edge_spec.rb | UTF-8 | 4,564 | 3.171875 | 3 | [] | no_license | require 'rspec'
require '../shadow/polyedr'
EPS = 1.0e-12
class R3
# проверка на приближённое равенство
def equal?(other)
(@x - other.x).abs < EPS and (@y - other.y).abs < EPS and
(@z - other.z).abs < EPS
end
end
class Segment
# проверка на приближённое равенство
def equal?(other)
(@beg - oth... | true |
401879f3c019b7786098bd3df388c87051e78a22 | Ruby | Madeline-Stark/margaritaville | /lib/api.rb | UTF-8 | 767 | 3.0625 | 3 | [] | no_license | class API
def self.fetch_drinks
url = "https://www.thecocktaildb.com/api/json/v1/1/search.php?s=margarita"
uri = URI(url)
response = Net::HTTP.get(uri)
hash = JSON.parse(response)
array_of_drinks = hash["drinks"]
# strDrink - name
# strInstructions
... | true |
7924d28a8bb81a7cb5df357b313ea15e9df09df2 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/accumulate/11a1bbd8bde7487983f05aa995166fe0.rb | UTF-8 | 103 | 3.390625 | 3 | [] | no_license | class Array
def accumulate
answer = []
each { |n| answer << (yield n) }
answer
end
end
| true |
1702776b44f3a960b8d6820c948972687edccce2 | Ruby | sakuraisoki/HongoScripts | /astrophysics/tools/xspec_get_parameter_from_a_logfile.rb | UTF-8 | 2,089 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env ruby
#20101111 Takayuki Yuasa
if(ARGV.length<3)then
puts <<EOS
xspec_get_parameter_from_a_logfile.rb (log file) (model component number) (parameter name) (errp/errm/value_errp_errm/value/errP/errM/value_errM_errP;optional) (ruby style format;optional)
EOS
exit
end
logfile=ARGV[0]
if(!File.exist?(logfi... | true |
5155c20267323b1ef1caf466c6e99ece1b091e3d | Ruby | vencha90/taxi-sim | /spec/taxi/action_spec.rb | UTF-8 | 2,925 | 2.703125 | 3 | [
"MIT"
] | permissive | describe Taxi::Action do
subject { Taxi::Action.new(type: 'type') }
describe 'initialisation' do
subject { Taxi::Action }
it 'assigns type' do
expect(subject.new(type: 'type').type).to eq('type')
end
it 'assigns value' do
expect(subject.new(type: nil, value: 'value').value).to eq('value... | true |
03deb1d24ece871ab1f03d97fcb0fa8dd6e5f517 | Ruby | TimurM/ruby_prep_work | /leap_years.rb | UTF-8 | 352 | 3.828125 | 4 | [] | no_license | def leap_years
puts "enter a starting year:"
start_year = gets.chomp
start_year = start_year.to_i
puts "enter an ending year"
end_year = gets.chomp.to_i
end_year = end_year.to_i
(start_year..end_year).each do |year|
if (year % 100 == 0 && year % 400 != 0)
next
elsif year % 4 == 0
puts year
end... | true |
8cc8d6ef3e4782a7335f6b5981055a94e04d44d1 | Ruby | 89hikari/auto-deploy-full | /lib/human.rb | UTF-8 | 268 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
# Initialization for FIO is here
class Human
attr_accessor :name, :lastn, :patr
def initialize(name, lastn, patr)
@name = name
@lastn = lastn
@patr = patr
end
def name_str
"#{@name} #{@lastn} #{@patr}"
end
end
| true |
e3bba76d6ae4611df0e7eb455c0a33a95b3c6ef2 | Ruby | igorsimdyanov/ruby | /hashes/transform_values.rb | UTF-8 | 82 | 2.59375 | 3 | [] | no_license | h = { fst: 1, snd: 2}
p h.transform_values { |v| v * 10 } # {:fst=>10, :snd=>20}
| true |
266bcd7c444b7365d4172da889533f2096ba1c24 | Ruby | srknc/s | /lib/Robot.rb | UTF-8 | 2,522 | 2.859375 | 3 | [] | no_license | #!/usr/bin/ruby -w
require 'optparse'
require 'ostruct'
require 'json'
class Robot
def initialize
### default parameters from file
vars_file = File.read('conf/vars.json')
@vars = JSON.parse(vars_file)
### read template files
@ec2_def_temp = File.read('templates/ec2_main.json')
@e... | true |
d3d85582028486d178fdf39feb0a14d5ef8de277 | Ruby | oscar6654/test | /street-show/code.rb | UTF-8 | 1,105 | 3.578125 | 4 | [] | no_license | #Street Show
sum_of_knife_juggling = 2.10 + 0.77 + 5.00 + 1.00 + 3.00
sum_of_torch_juggling = 6.00 + 3.50 + 7.00
sum_of_hand_balancing = 2.00 + 1.00
sum_of_human_blockhead = 0.75 + 0.43
puts "Knife Juggling:"
puts sum_of_knife_juggling.round(2)
puts "Torch Juggling:"
puts sum_of_torch_juggling
puts "Hand Balancing:"
p... | true |
be4f21579e2cac7885a09742694a07478b5da46e | Ruby | dataminerhkhome/CodeExercise | /assign_engine.rb | UTF-8 | 1,199 | 2.71875 | 3 | [] | no_license | class AssignEngine
attr_accessor :distance_bound
attr_accessor :graph
def initialize graph, time_limit
@sum_distance=0
@distance_limit=time_limit*600
@graph=graph
end
def assign queue_left,assign_list
return if queue_left.length==0
current_node=assign_list.last
next_node=current_n... | true |
08c67cfdf153c3cb29fbc51f165df54da10c4d30 | Ruby | dtbrad/grocer | /app/service_objects/spending_state.rb | UTF-8 | 2,051 | 2.640625 | 3 | [
"MIT"
] | permissive | class SpendingState
include ActiveModel::Model
attr_reader :graph_config, :basket_helper_start, :basket_helper_end, :basket_helper_unit, :sort_column,
:sort_direction, :tooltip_date, :tooltip_unit, :default_start
def initialize(default_start, options = {})
@graph_config = options[:graph_config... | true |
4608e7d9901ec3683a2086f08261a8c207bf5465 | Ruby | RyanZolper/AssignmentsIronYard | /assignment20.rb | UTF-8 | 534 | 3.796875 | 4 | [] | no_license | class String
VOWELS = %w(a e i o u)
def pigatize
pigatized_array = Array.new
x = 0
arr = self.split
arr.each do|a|
if VOWELS.include? a[0].downcase
pigatized_text = a + "way"
else
pigatized_text = a.downcase.chars.rotate.join + "ay"
end
pigatized_array[x] =... | true |
4f756f5beb69d349a46cd1e0ff36ca72b89fb972 | Ruby | darrylcohen/WDI_13_HOMEWORK | /Darryl Cohen/wk04/3-wed/happitails/shelter.rb | UTF-8 | 2,030 | 3.5 | 4 | [] | no_license | class Shelter
def initialize name, address
@name = name
@address = address
@animals =[]
@clients = []
add_animal Animal.new 'Fluffy', 2, 'male', 'dog'
add_animal Animal.new 'Rusty', 5, 'male', 'dog'
add_animal Animal.new 'Felix', 7, 'male', 'cat'
add_animal Animal.new 'Tweety', 2, 'm... | true |
00c871a7d4ea84b299b789c693b854de173f1f73 | Ruby | cesareferrari/programming-foundations | /exercises/101-109_small_problems/easy7/04_swapcase.rb | UTF-8 | 646 | 4.375 | 4 | [] | no_license | # Write a method that takes a string as an argument and returns a new string in
# which every uppercase letter is replaced by its lowercase version, and every
# lowercase letter by its uppercase version. All other characters should be
# unchanged.
# You may not use String#swapcase; write your own version of this metho... | true |
b82059ec2ab0f621d9795c5d31235c8887281dc4 | Ruby | andersondanilo/travelling_salesman_ai4r_example | /lib/proximity_algorithm.rb | UTF-8 | 480 | 3.34375 | 3 | [] | no_license | require_relative './algorithm'
require_relative './path'
class ProximityAlgorithm
def create_path(start_city, other_cities)
path = Path.new
path.cities << start_city
last = start_city
while other_cities.length > 0
best = nil
other_cities.each do |city|
if not best or last.calc_co... | true |
f75c091344f2109189d465f5db63bfbaf6026495 | Ruby | mizutaki/crawler | /chapter5/wikipedia-category.rb | UTF-8 | 610 | 2.921875 | 3 | [] | no_license | require "nokogiri"
require "open-uri"
@base_url = "http://ja.wikipedia.org"
#検索対象のカテゴリURL
#日本の映画作品(ジャンル別)
category_url = "/wiki/Category:%E6%97%A5%E6%9C%AC%E3%81%AE%E6%98%A0%E7%94%BB%E4%BD%9C%E5%93%81_(%E3%82%B8%E3%83%A3%E3%83%B3%E3%83%AB%E5%88%A5)"
def category_search(url,depth)
return if depth >= 4
doc = Nokogiri... | true |
44c5018a2af5898fc039125db576456e4a9e8f70 | Ruby | juandefelix/rock_paper_scissors | /lib/dessert.rb | UTF-8 | 1,043 | 3.640625 | 4 | [] | no_license | class Dessert
attr_accessor :name, :calories
def initialize(name, calories)
@name = name
@calories = calories
end
def healthy?
@calories < 200
end
def delicious?
true
end
end
class JellyBean < Dessert
def initialize(flavor)
@flavor = flavor
@name = "#{flavor} jelly bean"
@... | true |
3b2acc45c798ee3d6bd724c1ef713aa452799d87 | Ruby | rmathur101/tddtelephoneTues | /pizza/lib/pizza.rb | UTF-8 | 151 | 2.765625 | 3 | [] | no_license | class Pizza
attr_reader :description, :time_baked, :name
def initialize
@description = nil
@time_baked = nil
@name = "name"
end
end
| true |
20d3ec57debf254e457295b7c6de1abbd34f2b06 | Ruby | warrend/cartoon-collections-v-000 | /cartoon_collections.rb | UTF-8 | 550 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(array)
array.each_with_index { |v, i| puts "#{i + 1} #{v}" }
end
def summon_captain_planet(array)
array.collect { |i| i.capitalize + "!" }
end
def long_planeteer_calls(array)
array.any? { |i| i.length > 4 }
end
# def find_the_cheese(array)
# cheese_types = ["cheddar", "gouda", "camember... | true |
70cc0cedc58cdcdb4316e8221d55269502993d5d | Ruby | Not-A-Sith-Lord/course-examples | /week1/solutions/day5/chess_validator/lib/movement/straight_movement.rb | UTF-8 | 286 | 3.015625 | 3 | [] | no_license | # lib/movement/straight_movement.rb
module StraightMovement
def straight_move?(final_x, final_y)
if final_x == @x || final_y == @y
"yes"
else
"no"
end
# Another option for the condition:
# if (final_x - @x) == 0 || (final_y - @y) == 0
end
end
| true |
119654b28e517fedefe6172df8762be2c2f15cff | Ruby | mikekelly/git_curses | /lib/git_curses/input.rb | UTF-8 | 281 | 3.125 | 3 | [] | no_license | class Input
def initialize(window)
@window = window
end
def next_command
case next_char
when 'q'
:quit
when Curses::Key::DOWN
:move_down
when Curses::Key::UP
:move_up
end
end
private
def next_char
@window.getch
end
end
| true |
a86c380520829f364555d9b36cd7c3eb74551c18 | Ruby | Dav-Ho/ActualizeCompSci_Solutions | /binary_search.rb | UTF-8 | 627 | 4.375 | 4 | [] | no_license | def binary_search(array, value, from= 0, to= 0 )
if to == 0
to = array.count - 1 # This takes the last value
end
mid = (from + to) / 2 # (0 + 10) / 2 = 5
if value < array[mid]
return binary_search array, value, from, mid - 1
elsif value > array[mid]
return binary_search array, value, mid + 1, to
... | true |
16189fb4135440faaa7b329057f0efd52ec19ab1 | Ruby | twrodriguez/duct_tape | /spec/ext/numeric_spec.rb | UTF-8 | 1,619 | 2.75 | 3 | [
"BSD-2-Clause"
] | permissive | require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
#
# Numeric#units
#
describe Numeric, "units" do
it "chronological sizes" do
expect(3.years).to eq(3*365*24*60*60)
expect(3.weeks).to eq(3*7*24*60*60)
expect(3.days).to eq(3*24*60*60)
expect(3.hours).to eq(3*60*60)
expect(3.minutes... | true |
d84f762388c5f8bc8638a70d36ed7c2caa682a57 | Ruby | VictorManzanilla/programming-univbasics-4-finding-an-element-in-an-array-lab-chi01-seng-ft-080320 | /lib/find_in_array.rb | UTF-8 | 217 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
def find_element_index(array, value_to_find)
count = 0
found_value_index = nil
while count < array.length do
if array[count] == value_to_find
found_value_index = count
end
count += 1
end
found_value_index
end | true |
c8139e94ca340af2468f62994b0f331ff43838b9 | Ruby | anoam/customers_locations | /spec/domain/customer_spec.rb | UTF-8 | 1,092 | 2.84375 | 3 | [] | no_license | require "domain"
RSpec.describe Domain::Customer do
let(:frank_location) { instance_double(Domain::Point, distance_to: 42) }
let(:christina_location) { instance_double(Domain::Point, distance_to: 9000) }
let(:frank) { Domain::Customer.new(user_id: 7, location: frank_location, name: "Frank Kehoe") }
let... | true |
39abda4bcfc93c7e31357417ca97ddf5283aff67 | Ruby | kellyhky/Assignments | /Part_I/assignment-ii.c2/bonus.rb | UTF-8 | 804 | 3.96875 | 4 | [] | no_license | #Problem 1
def multiples_of_three_and_five
count = 0
for x in (1..999) do
if x % 3 == 0 || x % 5 == 0
count += x
end
end
return count
end
#Answer: 233,168
#Problem 2
def even_fibonacci_numbers
fibonacci = [1, 2, 3]
while fibonacci[-1] < 4000000 do
x = fibonacci[-1] + fibonacci[-2]
fib... | true |
4be415589e349ce0eb1bca1344ce8d629f808789 | Ruby | Jonasmalmlof/TDP007 | /Seminarie1/uppgift06.rb | UTF-8 | 1,283 | 3.921875 | 4 | [] | no_license | #!/usr/bin/env ruby
require 'date'
class PersonName
attr_accessor :fullname
attr_reader :name
attr_reader :surname
def fullname
return "#{@surname} #{@name}"
end
def fullname=(fullname)
#Set first name as first name of full name and capitalize the name
@name = fullname.split(" ")[0].capitali... | true |
331225718a09cdf70fa61642d41d984c989cc8d9 | Ruby | misstonbon/hotel | /specs/block_spec.rb | UTF-8 | 1,049 | 3.0625 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../lib/block'
describe 'Block' do
before do
@check_in = Date.new(2017, 5, 5)
@check_out = @check_in + 3
@price = 150
end
it "block is a subclass of Range"do
@rooms = [5, 12, 15]
@reserved_block = Property::Block.new(@rooms, @check_in, @check_... | true |
87aa5024f2008d990c397658310755a82a77c84f | Ruby | bluzi/homebrew-cask | /developer/bin/generate_issue_template_url | UTF-8 | 1,144 | 3.53125 | 4 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env ruby
#
# generate_issue_template_url
#
###
### dependencies
###
require "erb"
###
### constants
###
BASE_URL = "https://github.com/caskroom/homebrew-cask/issues/new".freeze
###
### methods
###
def main(args)
title, body = File.read(args[0]).match(%r{(.*?)\n(.*)}m).captures
print generate_url(ti... | true |
868a426ec87ece1934ce98b3379e104f3d86c4a9 | Ruby | mnoble/anaximander | /spec/anaximander/crawler_spec.rb | UTF-8 | 2,144 | 2.59375 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Anaximander::Crawler do
let(:link) { "http://example.com" }
subject!(:crawler) { described_class.new(link) }
it "does not visit pages that have already been visited" do
crawler.visit(link)
expect(crawler.visit(link)).to be_nil
end
it "does not visit pages that ... | true |
1c1e78f6e01ba28c47a5b649395482dfd19c56ee | Ruby | pooja-yadav-ctrl/Ror-training | /factorial.rb | UTF-8 | 152 | 3.53125 | 4 | [] | no_license | #!usr/bin/ruby
def factorial
i=1,fact=1
for i in 1..5
fact = fact * i
end
puts "factorial of 5 is #{fact}"
end
factorial | true |
d796687b0f946183fd4f7e63a2ee9c55fe8c58b0 | Ruby | CLantigua2/learning-ruby | /challengeLetterChanger.rb | UTF-8 | 741 | 4.1875 | 4 | [] | no_license | # Challenge
# Have the function LetterChanges(str) take the str parameter being passed and modify it using the following algorithm. Replace every letter in the string with the letter following it in the alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally ... | true |
8ef1be8526b683fb0981b5a027d6c41382271359 | Ruby | dnguye2/hotel | /test/date_range_test.rb | UTF-8 | 4,750 | 2.890625 | 3 | [] | no_license | require_relative "test_helper"
describe Hotel::DateRange do
describe "constructor" do
before do
start_date = Date.new(2017, 01, 01)
end_date = start_date + 3
@range = Hotel::DateRange.new(start_date, end_date)
end
it "can be initialized with two dates" do
start_date = Date.new(2... | true |
26df469120e32787b87bc0d2be5fcbf3511024d5 | Ruby | Qmzp2/debugging-with-pry-onl01-seng-ft-032320 | /lib/pry_debugging.rb | UTF-8 | 36 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
num
num +2
end | true |
8a10c0bbc0625024dd5348a42b764b62d1226537 | Ruby | KoharaKazuya/sieve | /sieve.rb | UTF-8 | 1,098 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
# オプションをパース
option = { placeholder: '{}', linenum_placeholder: '{linenum}' }
OptionParser.new do |opt|
opt.on('-p', '--placeholder=TEXT', '入力行で置き換える文字列') {|v| option[:placeholder] = v}
opt.on('-l', '--linenum-placeholder=TEXT', '行数で置き換える文字列') {|v| option[:... | true |
aa0d347ff59785355e05343123cc3231d1c798d5 | Ruby | poyzn/bowling-test-app | /app/modules/games/commands/calculate_score.rb | UTF-8 | 2,500 | 3.0625 | 3 | [] | no_license | module Games
module Commands
class CalculateScore
def initialize(frames, bonus)
@frames = frames
@bonus = bonus
end
def call
score = []
@frames.each_with_index do |frame, frame_index|
return score if frame_index > 9
sum = frame.sum
... | true |
fe780da923ee8c8af029573e0ed0d1ef69a43f3f | Ruby | Omosofe/Play | /project_euler/lib/project_euler/problems/005.rb | UTF-8 | 255 | 2.953125 | 3 | [
"MIT"
] | permissive | module ProjectEuler
class Problem5
def solution
# I feel like this one is so much easier to solve
# by hand than trying to write a program to pull
# these numbers, so why bother.
19*17*13*11*7*5*3*3*2*2*2*2
end
end
end
| true |
ed0f80090c75f19e9a00a1434293db5a81eebe8a | Ruby | parkr/ebooks | /lib/ebooks/config.rb | UTF-8 | 613 | 2.5625 | 3 | [
"MIT"
] | permissive | module Ebooks
class Config
attr_reader :conf
def initialize conf_file = nil
@conf = YAML.load File.open File.join(File.dirname(__FILE__), '..', '..', 'config/defaults.yaml')
if conf_file
conf_file.sub!('~', ENV["HOME"])
locals = YAML.load(File.open(conf_file))
@conf =... | true |
38ceba10eb91354d520481305440148aca59c162 | Ruby | Platinumwrist/brew | /Library/Homebrew/cmd/unlink.rb | UTF-8 | 865 | 2.765625 | 3 | [
"CC-BY-4.0",
"BSD-2-Clause"
] | permissive | #: * `unlink` [`--dry-run`] <formula>:
#: Remove symlinks for <formula> from the Homebrew prefix. This can be useful
#: for temporarily disabling a formula:
#: `brew unlink <formula> && <commands> && brew link <formula>`
#:
#: If `--dry-run` or `-n` is passed, Homebrew will list all files which would
#: ... | true |
1730b9f3d9c0c64eee5d639c5800dd2e2928b7ac | Ruby | foxnewsnetwork/monadic | /lib/monadic/contextable.rb | UTF-8 | 236 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Monadic
module Contextable
def initialize( pure=nil )
@_pure = pure
@_empty_flag = @_pure.nil? || @_pure.empty?
end
def empty?
@_empty_flag
end
def purify
@_pure
end
end
end | true |
dc1c2a1af2c9dfe05261d8a833c4e32bcd8be5d1 | Ruby | mwagner19446/wdi_work | /w03/d05/Dima/food/food.rb | UTF-8 | 5,422 | 3.5 | 4 | [] | no_license | require 'pry'
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: "postgresql",
host: "localhost",
username: "dmitryjum",
password: "",
database: "ga_food"
)
class Fridge < ActiveRecord::Base
has_many :foods
has_many :drinks
#self.has_many(Foods{:dependent => :destroy})
#... | true |
56f6a232ce8efdb4f38f22561e6beb85da632b27 | Ruby | Michael-Wayne-Wells/The-Word-Definer | /lib/word.rb | UTF-8 | 831 | 3.046875 | 3 | [
"MIT"
] | permissive | class Word
attr_reader :id
attr_accessor :name
@@words = {}
@@rows = 0
def initialize(attributes)
@name = attributes.fetch(:name)
@id = attributes.fetch(:id) || @@rows += 1
end
def save
@@words[self.id] = Word.new({ :name => self.name, :id => self.id})
end
def self.all
@@words.valu... | true |
83cc94e8855c3ce77e50389ff20fce13103b1073 | Ruby | RudiBoshoff/databases | /sequel_with_ruby.rb | UTF-8 | 554 | 3.296875 | 3 | [] | no_license | # DOESN'T WORK JUST AN EXAMPLE OF A TYPICAL FORMAT (FOLLOWING A TUTORIAL)
require 'sequel'
require 'pg'
DB = Sequel.connect('postgress://user:passwprd@localhost/dbname')
DB.create_table :people do
primary key :id
String :first_name
String :last_name
Integer :age
end
people = DB[:people]
people.insert(:first... | true |
5b1ab77645f0c9727eca0dd0a164363e4b593e76 | Ruby | jmazrimas/phase-0-tracks | /ruby/gps6/my_solution.rb | UTF-8 | 4,961 | 3.90625 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
# require uses looks for the class/file you're attempt to access relative to the directory that you are running the calling code from
# require_relative looks for the class/fil... | true |
63c9773ee2ac43cd7eac6bd3c6aa54c60df0b313 | Ruby | sarahcalande/the-bachelor-todo-dumbo-web-080618 | /lib/bachelor.rb | UTF-8 | 2,132 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def get_first_name_of_season_winner(data, season)
# code here
#winner = nil
#data.each do |hash_season, contestants_array|
# if hash_season == season
# contestants_array.each do |contestant|
# if contestant["status"] == "Winner"
# winner = contestant["name"].split
... | true |
f23dbbadfb97543e0bc24b04b88f22e8d3e8c29c | Ruby | quintel/atlas | /spec/atlas/active_document_spec.rb | UTF-8 | 25,135 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Atlas
describe SomeDocument do
let(:some_document) { SomeDocument.find('foo') }
describe 'new' do
context 'given no key or path' do
it 'does not raise an error' do
expect { SomeDocument.new({}) }.not_to raise_error
end
end
context 'given a dumb key' d... | true |
c2e11b0bb3241317ca3b90e5d76be6505be47032 | Ruby | payrollhero/ph_model | /lib/ph_model/concerns/attribute_type_validation.rb | UTF-8 | 1,796 | 2.671875 | 3 | [
"MIT"
] | permissive | module PhModel
module Concerns
# This will validate any attribute defined with `type: `
# the type value should be a class, or the special notation `[SomeClass]` which is meant to designate that this is
# a collection of those classes
#
# `no_type_check: true` can be optionally passed to disable ... | true |
2e7578c1ed3c81cc1b138378271316a815963f52 | Ruby | maya-a/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 1,395 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
require 'open-uri'
require 'json'
class GamesController < ApplicationController
def new
@start_time = Time.now.to_s.gsub(/\s+/, '')
@letters = []
vowels = ['A', 'E', 'O', 'U', 'I']
2.times { @letters << vowels.sample }
8.times { @letters << ('A'..'Z').to_a.sample }
... | true |
6414896dbe8cf4061e82b7f93ac6cab87b71629e | Ruby | JSun-Kim/CVTS | /app/models/activity_item.rb | UTF-8 | 1,245 | 2.5625 | 3 | [] | no_license | class ActivityItem < ActiveRecord::Base
belongs_to :user
belongs_to :story
belongs_to :topic
belongs_to :comment
belongs_to :vote
belongs_to :community #KJS. July 16, 2013
# Constant Definitions
# Note: DO NOT change the numeric values. If you do, reset the database, because the bindings would be al... | true |
cfd78f3cd05b4d6fa4986c82776995b0c36b2cf5 | Ruby | Fuseit/fuse-dev-tools | /lib/fuse_dev_tools/lib/git_hub.rb | UTF-8 | 1,801 | 2.734375 | 3 | [] | no_license | require 'semantic'
require 'octokit'
class GitHub
def self.client
@client ||= Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'] || raise('Missing Github access token'))
end
def self.previous_release_version username, repo
latest_release = client.latest_release("#{username}/#{repo}")[:name]
... | true |
08702a4425d42b0e42386171b699f86ad1c348d6 | Ruby | dalspok/exercises | /small_problems/easy_4/2.rb | UTF-8 | 1,696 | 3.875 | 4 | [] | no_license | # Input
# - integer
# Output
# - string: century + suffix
# Rules
# - century
# - starts 01
# - ends 00
# - number of century: num/100 + 1 except end double: 00 (%100==0)
# - suffixes
# - final numbers
# - 0: th
# - 1: st
# - 2: nd
# - 3: rd
# - 4-9: th
# - ex... | true |
1b199d7cd0a5d7ab95709777fec1e3c47d8c0dc5 | Ruby | bjornnborg/englishfy | /lib/challenges/pt_en/animals.rb | UTF-8 | 997 | 2.96875 | 3 | [] | no_license | require_relative('../../simple_challenge_picker')
require_relative('../../default_random_language_service')
module Challenges
module PtEn
class Animals
def initialize
@english = {
"horse" => ["cavalo"],
"cat" => ["gato"],
"dog" => ["cachorro"],
"pig" => ["po... | true |
da437b2899bc083a9479569e59f9940e6dd43e2f | Ruby | jdahiyajd/practice | /even.rb | UTF-8 | 358 | 3.6875 | 4 | [] | no_license | puts "Enter The Number."
input =gets.chomp.split('').map { |e| e.to_i }
evenpos_elm = input.select { |e| input.index(e)%2 == 0 }
sum_evenpos = evenpos_elm.sum
oddpos_elm =input.select{|e| input.index(e)%2 !=0 }
sum_oddpos = oddpos_elm.sum
if sum_evenpos > sum_oddpos
puts "even"
elsif sum_oddpos > sum_evenpos
puts "o... | true |
69c1455a7f3bf8efacd298490d93d4e4f9caafc9 | Ruby | adriantoman/project_validator | /lib/validation.rb | UTF-8 | 6,696 | 2.625 | 3 | [] | no_license | require 'gooddata'
require 'json'
require 'faster_csv'
require 'archiver'
module ProjectValidator
class Validation
TASK_POOL_SIZE = 3
attr_accessor :task_pool,:items_to_process, :login
def initialize(login, password,items_to_process,export_path,server)
@task_pool = Array.new
... | true |
671e0838dbaa8574a706652a5be5b38379d650f4 | Ruby | hhf666feng/gitlab | /lib/banzai/filter/emoji_filter.rb | UTF-8 | 3,428 | 2.671875 | 3 | [
"MIT"
] | permissive | module Banzai
module Filter
# HTML filter that replaces :emoji: and unicode with images.
#
# Based on HTML::Pipeline::EmojiFilter
#
# Context options:
# :asset_root
# :asset_host
class EmojiFilter < HTML::Pipeline::Filter
IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set
... | true |
ce9c489e7de2c28d8b2876bd7e63e52858e5dc5b | Ruby | developingdina/oo-meowing-cat-onl01-seng-pt-032320 | /lib/meowing_cat.rb | UTF-8 | 149 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cat
attr_accessor :name
def meow
puts "meow!"
end
end
patrick = Cat.new
patrick.name = "Patrick"
patrick.name
patrick.meow | true |
65dd9f5f541d4345b4040bb281a168e58a35b22e | Ruby | AlvinDevelopments/knights-travails | /knightsearcher.rb | UTF-8 | 2,237 | 3.6875 | 4 | [] | no_license | require_relative 'movetree'
require_relative 'queue'
require 'Time'
class KnightSearcher
def initialize(tree)
@tree = tree
@path = []
@node_queue = Queue.new
@found = false
end
def bfs_for(target_coords)
@node_queue.enqueue(@tree.start_move)
check_node(@node_queue.dequeue, target_coords)... | true |
386ddd7e46712903b4823cd782e4a7ac711bf7ed | Ruby | kyled871/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 153 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
reverse = []
sentence.split(' ').collect do |word|
reverse << word.reverse.to_s
end
reverse.join(' ')
end
| true |
500ff3614d576b5bacb0f5f828a973d940c2728b | Ruby | danmayer/blog2ebook | /test/book_formatter_test.rb | UTF-8 | 1,173 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
ENV['RACK_ENV'] = 'test'
require 'sinatra'
require File.expand_path(File.join(File.dirname(__FILE__), '../app'))
require 'test/unit'
require 'mocha/setup'
class BookFormatterTest < Test::Unit::TestCase
def test_formatted_title
formatted_book = BookFormatter.new("replace.periods", "content")
... | true |
f954b65f7141eeb43967a0a69384efedc04f1e1d | Ruby | AppsDJ/launch-school-101 | /lesson_2/calculator.rb | UTF-8 | 2,213 | 4.59375 | 5 | [] | no_license | # ask user for 2 numbers
# ask user what operation to perform
# perform operation on the 2 nums
# output result
def prompt(message)
Kernel.puts("=> #{message}")
end
def valid_number?(number)
number.to_i() != 0
end
def operation_to_message(operator)
case operator
when 1
"Adding"
when 2
"Subtracting"... | true |
6d9fc55417bafff7c22b9e30d6e66e9107f69e9d | Ruby | takuyamaeda/atcoder | /abc_189/c.rb | UTF-8 | 355 | 3.296875 | 3 | [] | no_license | # frozen_string_literal: true
count = gets.to_i
apple_dishes = gets.chomp.split(' ').map(&:to_i)
max = 0
(0...count).each do |l|
x = apple_dishes[l]
(l...count).each do |r|
break if max >= x * (count - l)
x = [x, apple_dishes[r]].min
eatable_apple_count = x * (r - l + 1)
max = [max, eatable_appl... | true |
486f55e4e0b66717cb97f88b6ffe8337f4947d93 | Ruby | semk/blog | /_plugins/excerpt.rb | UTF-8 | 801 | 2.75 | 3 | [] | no_license | # Original source taken from the below site and modified.
# http://www.jacquesf.com/2011/03/creating-excerpts-in-jekyll-with-wordpress-style-more-html-comments/
module Jekyll
module ExcerptFilter
include Liquid::StandardFilters
def excerpt(input)
excerpt = ""
if input.include?(BEGIN_EXCERPT) &&... | true |
378b1a8d1238463e8b04444884e2f1cd011b9f4a | Ruby | luontola/cygwin-deployer | /spec/utils_spec.rb | UTF-8 | 1,372 | 2.546875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | # Copyright © 2012 Esko Luontola <www.orfjackal.net>
# This software is released under the Apache License 2.0.
# The license text is at http://www.apache.org/licenses/LICENSE-2.0
require_relative 'test_helpers'
require 'fileutils'
describe "download" do
before(:each) do
@output_file = 'download.tmp'
end
... | true |
a4025d51dd54eb725866e09c6a2448f55fcf1a57 | Ruby | Eistime/coffeemachine | /controllers/specs/users_spec.rb | UTF-8 | 3,189 | 2.671875 | 3 | [] | no_license | require_relative '../users.rb'
require_relative '../../models/users.rb'
require_relative '../../fixtures/users.rb'
describe UsersController do
before(:each) do
@db = SQLite3::Database.new "./sqlite/coffee_machine_testing.db"
create_table_users @db
@users_model = Users.new @db
@users_controller = Use... | true |
a742d6a6fe0122887538cdfb7e6afebe232ffa55 | Ruby | kargo-k/advanced-hashes-hashketball-seattle-web-060319 | /hashketball.rb | UTF-8 | 5,352 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here!
require "pry"
def game_hash
h = {
home: {
team_name: "Brooklyn Nets",
colors: ["Black", "White"],
players: {
"Alan Anderson" => {
number:0,
shoe:16,
points:22,
rebounds:12,
assists:12,
steals:3,
blocks:1,
slam_dunks:1
},
"Reggie E... | true |
df27bd386bcfdf7ad22bd1b4f0a11abe5f0b86cf | Ruby | joshsouza/enviera | /lib/enviera/subcommands/unknown_command.rb | UTF-8 | 862 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'enviera/subcommand'
module Enviera
module Subcommands
class UnknownCommand < Enviera::Subcommand
class << self
attr_accessor :original_command
end
@@original_command = "unknown"
def self.options
[]
end
def self.description
"Unknown command... | true |
b828258acba07f899a29ef2ede8fd635167add93 | Ruby | boom100100/cli-portfolio-project | /lib/music.rb | UTF-8 | 965 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'pathname'
require 'pry'
class Music
def self.background_noise_menu
Music.build_menu("background_noise")
end
def self.playlist_menu
Music.build_menu("playlist")
end
def self.build_menu(path)
puts ''
puts 'Choose from the tracks below.'
puts 'Enter the number next to the track t... | true |
c39e88a72105d8af5b5dd8b48b16ad74951844bc | Ruby | kswang2400/app-academy-kwang | /week-1-day-3/eight_queens.rb | UTF-8 | 2,032 | 4.15625 | 4 | [] | no_license | require 'pry'
class EightQueens
def initialize
@board = Array.new(8) { Array.new(8) {" "} }
@queens = []
end
def place_queen
(0..7).each do |x|
(0..7).each do |y|
@queens.each do |queen|
place_piece(true, *queen)
end
next if self[x,y] == :blocked || self[... | true |
ec0a77765540a9b7b9da60ff5f123acda7ff2b68 | Ruby | sergey-koba-mobidev/health-checker | /lib/monitor.rb | UTF-8 | 1,386 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require 'net/http'
require 'date'
require './lib/logger'
require './lib/notification/resolver'
class Monitor
STATE_UP = 'up'
STATE_DOWN = 'down'
def initialize(config)
@name = config['name']
@url = config['url']
@notifications = config['notifications']
dt = DateTim... | true |
c8cc567c15ee1abca9b2a6ae6e9d3db4056d5c7f | Ruby | inbabbini/ttps_ruby_2015 | /Practicas/Practica2/metodos/e3.rb | UTF-8 | 348 | 3.75 | 4 | [] | no_license | #teniendo este metodo
def sort_numeric_params(*nums)
nums.sort
end
#y esta entrada
input = [15,16,14,3]
#para poder invocar el metodo sin que explote (ya que espera los numeros
#como parametros separados) deberia "explotar" el input al enviarlo por el
#parametro, es decir, separa el array en partes individuales
... | true |
afc09fc2f5c8a850815cc57cfeb71dcfbf7e4c90 | Ruby | masonatraylor/leetcode_solutions | /ruby/1172.rb | UTF-8 | 2,046 | 3.40625 | 3 | [] | no_license | class DinnerPlates
def initialize(capacity)
@capacity = capacity
@stacks = []
@open = PriorityQueue.new
end
def push(val)
idx = @open.peek
# No open stacks registered
if idx.nil? || @stacks[idx].nil?
idx ||= @stacks.size
@stacks[idx] = []
@open.offer(idx)
end
... | true |
2eea1354df773b350c6a065f8a5bb68190c2d6a4 | Ruby | ben-harvey/Small-problems-Ruby | /procedural/easy5/10.rb | UTF-8 | 942 | 4.40625 | 4 | [] | no_license | # Input: a string that fits in the terminal window
# Output: output to display a box surrounding the input
# +--------------------------------------------+
# | |
# | To boldly go where no one has gone before. |
# | |
# +------------... | true |
989f45c0c62d5fbe5f7f4e30a2adc8dcbb4eb8f4 | Ruby | sgvincentho/introrubycourse | /more_exercises_4.rb | UTF-8 | 131 | 3.9375 | 4 | [] | no_license | # more_exercises_4.rb
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# Append
arr.push(11)
puts arr
# prepend
arr.unshift(0)
puts arr | true |
587fd45bb2f134ae12d72bb863cf04a29673992a | Ruby | kg-coderta/atcoder | /abc/124.rb | UTF-8 | 246 | 3 | 3 | [] | no_license | A
a,b = gets.split.map(&:to_i).sort
if b-a == 0
p a + b
else
p 2 * b - 1
end
B
n = gets.to_i
m = gets.split.map(&:to_i)
view = 0
highest = 0
for num in 0..n-1
if m[num] >= highest
highest = m[num]
view += 1
end
end
p view
C
D
| true |
327f7e5d2c22c546b742dd13205c0219c6d36cb0 | Ruby | kymmt90-sandbox/rails-graphql-batch | /db/seeds.rb | UTF-8 | 586 | 2.546875 | 3 | [] | no_license | puts 'Loading seeds...'
user = User.create(email: 'foo@example.com')
deliverers = %w(Sagawa Yamato).map { |name| Deliverer.create(name: name) }
customer_attributes = %w(John Paul George Ringo).map { |name| { name: name } }
customers = user.customers.create(customer_attributes)
customers.each_with_index do |customer, in... | true |
1bd4b2a1684c34804b8d426c7e0d4716abb2523e | Ruby | ismailfaruqi/luhn | /spec/credit_card_generator_test.rb | UTF-8 | 1,222 | 2.75 | 3 | [] | no_license | require 'spec_helper'
describe CreditCardGenerator do
# it must accept these card patterns as valid card templates
['1111-1111-1111-111?',
'1111-222?-33?3-4444',
'1111-22?2-33??-4444',
'?111-?222-3?33-?444'].each do |card_pattern|
it "must accept #{card_pattern} as valid" do
expect(CreditCardGenerator.ne... | true |
310182e1dfabcf0c151d287f903d643cad513793 | Ruby | benosteen/printer | /test/print_archive_test.rb | UTF-8 | 2,108 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require "test_helper"
require "print_archive"
describe PrintArchive do
subject do
PrintArchive.new("printer-id")
end
let(:data) do
{width: 8, height: 8, pixels: []}
end
describe "storing a print" do
before do
IdGenerator.stubs(:random_id).returns("random-print-id")
end
it "stores... | true |
b5f5b7d0a66e50723b9f748b9d3c6a2d80852f90 | Ruby | OctavianRotari/learn_to_program | /ex-chapter-1-9/99b.rb | UTF-8 | 70 | 2.78125 | 3 | [] | no_license | 99.downto(1) do|i|
puts "#{i.to_s} bottles of beer on the wall"
end | true |
46385378ac13a942deed5d642248ce7f3c385421 | Ruby | G07Watch/AppAcademy-homeworks | /W5D5/map.rb | UTF-8 | 920 | 3.390625 | 3 | [] | no_license | class Map
def initialize
@map = Array.new()
end
def set(key,value)
map.each do |subarray|
if subarray.first == key
subarray[1] = value
return subarray
end
end
map << [key, value]
return [key,value]
end
... | true |
6efcd5d6f854296fc5fab276b5c38613de74f1d6 | Ruby | adrianeyre/bank-tech-test | /spec/account_spec.rb | UTF-8 | 742 | 3 | 3 | [] | no_license | require "account"
describe Account do
let(:statement) {Statement.new}
subject(:account) {described_class.new(statement)}
context "New Account" do
describe "#initialize" do
it "should have an empty balance" do
expect(account.balance).to eq 0
expect(account.statement).to eq "date || cred... | true |
13bd85a8b932ea8792523582b86fe18a0ab43d1c | Ruby | yusungkim/BioPerlPrograms | /DoublePrimerExtansion/AppRuby/bio/db/aaindex.rb | UTF-8 | 8,450 | 2.609375 | 3 | [] | no_license | #
# = bio/db/aaindex.rb - AAindex database class
#
# Copyright:: Copyright (C) 2001
# KAWASHIMA Shuichi <s@bioruby.org>
# Copyright:: Copyright (C) 2006
# Mitsuteru C. Nakao <n@bioruby.org>
# License:: LGPL
#
# $Id: aaindex.rb,v 1.18 2006/02/22 07:35:19 nakao Exp $
#
# == Description
#
#... | true |
dbb7df54da3145719b9bf154d3ebb237b2000002 | Ruby | cremno/mruby-allegro | /examples/fixbyproximity/RotatedBitmap.rb | UTF-8 | 737 | 2.546875 | 3 | [] | no_license | width, height = 640, 480
done = false
degree = 0
Al::Display.create width, height
image = Al::Bitmap.load 'selbstgemalt.JPG'
image_width, image_height = image.width, image.height
event_queue = Al::EventQueue.create
event_queue.register Al::Keyboard.event_source
until done
ev = event_queue.wait_for_event
case ev.typ... | true |
021c73fa07f75db5270c13428a364e2820f858e7 | Ruby | demullane/ruby-practice-problems | /birthday.rb | UTF-8 | 316 | 3.421875 | 3 | [] | no_license | require 'csv'
print "What's your name? "
name = gets
csv = CSV.foreach('birthday_data.csv') do |row|
if row[1] == name.split(" ")[0].strip && row[0] == name.split(" ")[1].strip
puts "Your full name is: " + row[1] + " " + row[0] + ". Your birthday is " + row[2] + ". Your email is " + row[3] + "."
end
end
| true |
c7c30e4c2df4a461c4f6018989a793881a1597a8 | Ruby | mohammadaliawan/launch_school_RB101 | /lesson_4/loops_ruby_basics/print_until.rb | UTF-8 | 110 | 3.203125 | 3 | [] | no_license | numbers = [7, 9, 13, 25, 18]
index = numbers.size - 1
until index < 0
puts numbers[index]
index -= 1
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.