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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ce2d60a4ec7c02d36038535a61d6067d5466d0f3 | Ruby | staynight0083/RubyTutorial1 | /ChangingDirectory/changingdirectory.rb | UTF-8 | 770 | 3.484375 | 3 | [] | no_license | # https://www.techotopia.com/index.php/Ruby_Directory_Handling
# current directory
Dir.pwd
current_dir = Dir.pwd # case sensitive it is Dir not dir
puts current_dir
# changing the directory
Dir.chdir("C:\\Ruby\\StringConversion")
current_dir = Dir.pwd
puts current_dir
Dir.chdir("C:\\Ruby\\ChangingDirectory")
cu... | true |
921361feb784e11e38555b2ab5b8e2c701b61d7e | Ruby | jcstone/euler_problems | /problem1.rb | UTF-8 | 207 | 3.9375 | 4 | [] | no_license | #Find the sum of all the multiples of 3 or 5 below 1000.
def three_or_five
results = 0
for i in 0...1000 do
if i % 3 == 0 || i % 5 == 0
results += i
end
end
return results
end
puts three_or_five | true |
e927f251466231e2f85976814762863b7b82d941 | Ruby | SurajG/codeeval | /hard/word-search/word-search.rb | UTF-8 | 1,301 | 3.859375 | 4 | [] | no_license | # Given a 2D board and a word, find if the word exists in the grid. The word can
# be constructed from letters of sequentially adjacent cell, where adjacent
# cells are those horizontally or vertically neighboring. The same letter cell
# may not be used more than once.
require 'enumerator'
def word_exists?(word, boar... | true |
82bed05fdfc1f17bbdc0024db629d229e64ebfe6 | Ruby | petersow/town-simulator | /lib/town/item.rb | UTF-8 | 216 | 2.515625 | 3 | [] | no_license | require 'securerandom'
module Town
class Item
attr_reader :i_id
attr_accessor :name
def initialize(options = {})
@i_id = SecureRandom.uuid
@name = options[:name] ||= ""
end
end
end
| true |
19723aa4d7b0fba5c13d27ffb84fae3ba715db72 | Ruby | ajshemi/programming-univbasics-3-labs-with-tdd-dumbo-web-102819 | /calculator.rb | UTF-8 | 204 | 2.578125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Add your variables here
first_number=3.3
second_number=4
sum=first_number+second_number
difference=first_number - second_number
product=first_number * second_number
quotient=first_number / second_number | true |
c045ea87aebf650952a314d267261a69bb32845c | Ruby | Marcus-UK/bank_tech_test | /spec/account_spec.rb | UTF-8 | 1,330 | 2.96875 | 3 | [] | no_license | require './lib/account.rb'
describe Account do
subject(:account) {described_class.new(transaction)}
let(:transaction) { Transaction.new([{:date => '01/11/2017', :amount => 100, :balance => 100},
{:date => '01/11/2017', :amount => 500, :balance => 600},
{:date => '01/11/201... | true |
c6b882ce56221eb09792ea1976dec5fc9da360ee | Ruby | kaileeagray/flatiron-store-project-v-000 | /app/models/cart.rb | UTF-8 | 365 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cart < ActiveRecord::Base
belongs_to :user
has_many :line_items, dependent: :destroy
has_many :items, through: :line_items
def add_item(item)
LineItem.find_by(cart: self, item_id: item) || LineItem.new(cart: self, item_id: item)
end
def total
line_items.collect do |li|
li.item.price * ... | true |
b9d034bbe5b5ec29bec226b1ca186454ffbcd97f | Ruby | hersheyj16/ShoeRack | /shoe.rb | UTF-8 | 214 | 2.953125 | 3 | [] | no_license | class Shoe
attr_reader :sku
attr_accessor :price, :size, :description
def initialize(sku, desc, size, price)
@sku = sku
@description = desc
@size = size
@price = Float(price)
@owner = "jenny"
end
end
| true |
f544ff504700bbd0e99f1e47c5dd8fde82471ddc | Ruby | Max-Leopold/LeetCode | /src/main/other/advent_of_code_2021/day4/day4.rb | UTF-8 | 1,488 | 3.734375 | 4 | [] | no_license | require_relative "bingo_board"
input = File.open(File.join(File.dirname(__FILE__), "input.txt"), "r")
drawn_numbers = input.readline.split(",").map(&:to_i)
input.readline
def create_bingo_boards(input)
input.each_line.reject { |line| line.start_with?(/\r|\n/) }
.each_slice(5)
.map { |board|
... | true |
5e0fe378b7b9b7549528f369fad771ad2cbcf797 | Ruby | OthmanAmoudi/looping-loop-cb-gh-000 | /looping.rb | UTF-8 | 96 | 2.75 | 3 | [] | no_license | def looping
#your code here
loop {
puts "Wingardium Leviosa"
}
end
#call your method here
looping
| true |
986d6ecb9d5afc5d34c5057668801e937dc42f35 | Ruby | TudorMaxim/InternshipProject | /app/models/challenge.rb | UTF-8 | 1,627 | 2.609375 | 3 | [] | no_license | class Challenge < ApplicationRecord
belongs_to :sender, class_name: 'User'
belongs_to :receiver, class_name: 'User'
scope :played, -> { where(status: "finished") }
scope :monthly, -> { where('finished_at > ?', 1.month.ago) }
scope :daily, -> { where('finished_at > ?', 1.day.ago) }
def set_winner(user)
... | true |
d60afcbeae3e55bdf6535ec31b197991d6875770 | Ruby | vijayvardhan94/stratify | /spec/lib/stratify/collector_spec.rb | UTF-8 | 4,889 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
class TestCollector < Stratify::Collector
configuration_fields :username => {:type => :string},
:password => {:type => :password}
end
def anonymous_collector_subclass(source = "some-source")
Class.new(Stratify::Collector).tap do |collector_class|
collector_class.so... | true |
60ffbf2213f6901c4973767dc5b3806d6ac21ef6 | Ruby | CampbellOleson/Campbell-aA-Homework | /W5D2/memory_puzzle/play_ball.rb | UTF-8 | 493 | 3.515625 | 4 | [] | no_license | require_relative 'board'
puts 'Find all the pairs!'
puts 'Enter a size 2 4 6 8'
def get_size
size = nil
size = gets.chomp.to_i
until size.between?(1,9) && size.even?
get_size
end
size
end
size = get_size
puts "Enter your name"
name = gets.chomp.to_s
board = Board.new(size,name)
board.po... | true |
19d454071f63fd2823474258b3e2e66cfc620cb8 | Ruby | onyoo/ruby-collaborating-objects-lab-v-000 | /lib/mp3_importer.rb | UTF-8 | 350 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MP3Importer
attr_accessor :path
def initialize(real_path)
@path = real_path
# files = []
# files = Dir.entries(path)
# @files = files.shift.shift
end
def files
Dir.entries(path).select{|file| file.end_with?(".mp3")}
end
def import
files.each{|string| Song.new_by_... | true |
4b43c58a4ebc29907ab838bd97841e69a45d52f0 | Ruby | zhuliangyu/9-23-2016 | /class/01.rb | UTF-8 | 158 | 2.921875 | 3 | [] | no_license | module Computer
class Apple
end
end
module HelpMethod
def say_hi
p "Hi"
end
end
class Person
include HelpMethod
end
p1=Person.new
p1.say_hi | true |
4c8134284ea29e34e9396553f3b296eea61c5d7c | Ruby | beetlegius/garabello | /app/models/tarea.rb | UTF-8 | 853 | 2.59375 | 3 | [] | no_license | class Tarea < ApplicationRecord
# CONFIG
include Destroyable
UNIDADES = %w(metro metro_2 litro unidad kilo tonelada hora kilometro)
ESFUERZO = 0.125
# CALLBACKS
after_initialize :set_esfuerzo
# RELATIONS
has_many :trabajos
has_and_belongs_to_many :tipos_programa, class_name: 'TipoPrograma'
... | true |
5b86cd1ec4255ad5f12b825e3575b2bb99fe3455 | Ruby | rails/rails | /activerecord/test/cases/forbidden_attributes_protection_test.rb | UTF-8 | 4,083 | 2.578125 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
require "cases/helper"
require "models/company"
require "models/person"
require "models/ship"
require "models/ship_part"
require "models/treasure"
require "support/stubs/strong_parameters"
class ForbiddenAttributesProtectionTest < ActiveRecord::TestCase
def test_forbidden_attributes_ca... | true |
1116d5df42357938a04fc17416d661bb3b3568e3 | Ruby | DougWelchons/black_thursday | /lib/merchant.rb | UTF-8 | 285 | 2.5625 | 3 | [] | no_license | class Merchant
attr_reader :id,
:created_at
attr_accessor :name,
:updated_at
def initialize(info)
@id = info[:id].to_i
@name = info[:name]
@created_at = info[:created_at]
@updated_at = info[:updated_at]
end
end
| true |
d330bf2c241c12a26fe1eb8822fd55e7a38e2814 | Ruby | tamarochka/data-scraping | /deals_scraping.rb | UTF-8 | 534 | 2.734375 | 3 | [] | no_license | require 'mechanize'
require "csv"
require "pry"
deal_name = "Hair"
url = "https://www.livingsocial.com/cities/2-boston"
@deal_titles = []
agent = Mechanize.new
page = agent.get(url)
@deals = page.search(".deal-tile")
@deals.each do |deal|
@deal_titles << {:name => deal.search("h3").text, :id => deal.attributes["data-... | true |
1cbb08d8f7faf2f37f236b5009d36aceeef19fa3 | Ruby | nesi/pan_ib_topology | /generators/gen_yml.rb | UTF-8 | 1,192 | 2.71875 | 3 | [
"MIT"
] | permissive | #Output YAML file from IBLinkinfo output.
module YML
#Generate Yaml output file, from the iblinkinfo data.
# @param ib [IBLinkInfo] The data derived from an iblinkinfo command, and parsed by the IBLinkInfo class parser
# @param file [String] The name of the output file.
def self.gen(ib, file='iblinkinfo.yml')
... | true |
e44f3338267b023f795c973f42843f352a61b254 | Ruby | shibinp/RubyMonk_exercises | /advd_array/exmple3.rb | UTF-8 | 48 | 2.921875 | 3 | [] | no_license | def zen
[23,45]
end
x,y = zen
puts x
puts y
| true |
edaeee3a711f72946456ab7168cef98ee68c0e4f | Ruby | feng/tuya | /spec/models/post_spec.rb | UTF-8 | 1,933 | 2.53125 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Post, "with fixtures loaded" do
fixtures :posts
before(:each) do
end
it "should have a non-empty collection of posts" do
Post.find(:all).should_not be_empty
end
it "should find an existing post" do
post = Post.find(pos... | true |
4cfb9876044c95483ec2ae0806bb0549d5e7e771 | Ruby | not1214/Ruby | /lesson7-2.rb | UTF-8 | 431 | 3.796875 | 4 | [] | no_license | puts "計算を始めます"
puts "何回計算を繰り返しますか?"
a = gets.to_i
i = 1
while i <= a do
puts "#{i}回目の計算"
puts "2つの値を入力してください"
b = gets.to_i
c = gets.to_i
puts "b=#{b}"
puts "c=#{c}"
puts "計算結果を出力します"
puts "b+c=#{b+c}"
puts "b-c=#{b-c}"
puts "b*c=#{b*c}"
puts "b/c=#{b/c}"
i += 1
end
puts "計算を終了します... | true |
deb00866aa9d5e8e3017b787710bf9ccca55a390 | Ruby | ChrisRG/lewagon | /livecodes/food-delivery-1/app/controllers/orders_controller.rb | UTF-8 | 2,261 | 3.203125 | 3 | [] | no_license | require_relative '../views/customers_view'
require_relative '../views/meals_view'
require_relative '../views/orders_view'
require_relative '../views/sessions_view'
class OrdersController
def initialize(meal_repo, customer_repo, employee_repo, order_repo)
@meal_repo = meal_repo
@customer_repo = customer... | true |
88eaa3671bdce4c7f42f691132c0164b62d06186 | Ruby | flatiron-school/learn-party-gem | /lib/learn_party.rb | UTF-8 | 2,406 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'ostruct'
require "learn_party/version"
require 'learn_party/generator'
require 'active_support/core_ext/hash'
module LearnParty
class GroupMaker
VALID_ARGS = {
valid_keys: ["groups_of", "collection", "sort_type", "number_of_groups"],
sort_type: ["random", "progress"]
}
attr_access... | true |
437f5cd4b5bcf37d5438ed03ad10d2037a339046 | Ruby | aowainati/matchdb | /lib/scraper.rb | UTF-8 | 4,415 | 2.703125 | 3 | [] | no_license | require 'open-uri'
class Scraper
@@base_youtube_domain = "https://www.youtube.com"
@@base_youtube_channel = @@base_youtube_domain + "/user/%s/videos"
@@base_youtube_video = @@base_youtube_domain + "%s"
def self.run
# Fetch initial channel content
Channel.all.each do |channel|
Scraper.new(channel... | true |
93afa8070d8b203be11287fb98ee8d1bd70a523b | Ruby | gpandeya/puzzles | /main.rb | UTF-8 | 655 | 3.15625 | 3 | [] | no_license | module Puzzle
def Puzzle.add(a,b)
a + b
end
def Puzzle.showInitials(str)
str.upcase.split.map {|word| word[0]}.join
end
def Puzzle.expand(inputInt)
inputStr = inputInt.to_s
newIntArray = inputStr.to_s.split("").map{|w| w.to_i}
temp =... | true |
e4348341b37715186b99fa898b76a3acf40447c9 | Ruby | kristianmandrup/roles_data_mapper | /lib/roles_data_mapper/strategy/single/one_role.rb | UTF-8 | 1,875 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'roles_data_mapper/strategy/single'
class Role
def self.named role_names
where(:name.in => role_names.flatten)
end
# belongs_to :user, :required => false
# has n, :users, :child_key => [ :one_role ]
end
module RoleStrategy::DataMapper
module OneRole
def self.default_role_attribute
... | true |
5d3e35926e3ec7dca6c143bacffc1ea274e873ae | Ruby | AtsushiHashimoto/chiffon-navigator | /app/lib/Recipe/Recipe.rb | UTF-8 | 3,443 | 2.59375 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'lib/Recipe/Progress'
module Recipe
Recipe = Nokogiri::XML::Document
class Nokogiri::XML::Document
def getByID(id, name=nil)
name = "*" if nil == name
elements = self.xpath("//#{name}[@id='#{id.to_s}']")
raise "several elements has the same ID... | true |
93c1e76143413d0197b7ac555b790d48e07ce31c | Ruby | travishn/HiR-Prep | /practice1.rb | UTF-8 | 3,430 | 4.5 | 4 | [] | no_license | # Instructions
# ------------------------------------------------------------------------------
# This file is in the same format as your assessments.
#
# You have 1 hour for this assessment. Give yourself about 15 minutes per problem.
# Move on if you get stuck
#
# Everything should print 'true' when you run the file.... | true |
57001b62c7719cdf9869982d5cd4b8aaacff4ec9 | Ruby | sonam-clarion/first-app | /features/step_definitions/cash_withdrawal_steps.rb | UTF-8 | 401 | 2.578125 | 3 | [] | no_license | class Account
def deposit
end
end
Given(/^I have deposited \$(\d+) in my account$/) do |amount|
my_amount = Account.new
my_amount.deposit(amount.to_i)
end
When(/^I request \$(\d+)$/) do |arg1|
pending # express the regexp above with the code you wish you had
end
Then(/^\$(\d+) should be dispensed$/) d... | true |
b98b67be669ee3ca14391d0a07f041465761856e | Ruby | CamillaCdC/seir01-homework | /alex_maunder/week_05/games_on_rails/app/controllers/game_controller.rb | UTF-8 | 528 | 2.578125 | 3 | [] | no_license | class GameController < ApplicationController
attr_accessor :rock, :paper, :scissors
def rock_paper_scissors
render :rock_paper_scissors
end
def rock_paper_scissors_answer
possible_answers = [
"Rock", "Paper", "Scissors"
]
@sample = possible_answers.sample
# raise "hell"
@answer... | true |
04695fdd9b5f3b06bb911472d2e1a3b1d694157b | Ruby | jmporchet/tealeaf_prework | /countdown_recursive.rb | UTF-8 | 128 | 3.4375 | 3 | [] | no_license | def count_to_zero(num)
if num < 1
return
end
puts num
num = count_to_zero(num-1)
end
count_to_zero(gets.chomp.to_i) | true |
a606e25080ccf3e5f5cfaf609ecfbbfdaab85618 | Ruby | ejbyne/ruby-rock-paper-scissors | /app/models/computer.rb | UTF-8 | 173 | 3 | 3 | [] | no_license | class Computer
attr_reader :name, :pick
def initialize(name)
@name = name
end
def picks
choices = [:rock, :paper, :scissors]
@pick = choices[rand(3)]
end
end
| true |
e1985fd9b74573ad03a61d3946ebd8b3d7a5f811 | Ruby | RyanSpittler/lrthw_exercises | /chapter_twelve/tenth.rb | UTF-8 | 150 | 3.59375 | 4 | [] | no_license | print "Please, sir, may I have some money? Type it in: "
number = gets.chomp.to_f
puts "Sir, this is too much! I will give you $#{number / 10} back."
| true |
7dfcc927d0552c56965c07ce859ad9809fdc90a2 | Ruby | DanielLacis/chess | /input.rb | UTF-8 | 1,658 | 3.5625 | 4 | [] | no_license | # from https://gist.github.com/acook/4190379
require 'io/console'
class PlayerInput
# Reads keypresses from the user including 2 and 3 escape character sequences.
def self.read_char
STDIN.echo = false
STDIN.raw!
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) r... | true |
cec8dd26d5616f6c72877af6706feae00e107362 | Ruby | ashishra0/Ruby-Beginner | /hello_world_variable.rb | UTF-8 | 78 | 3.046875 | 3 | [] | no_license | # This program prints hello world using a variable
hello = "Hello World"
puts hello | true |
364eac9d00b5bf68a9f4923c7f532097e29eb13c | Ruby | sarisgar28/instance-methods-lab-ruby-onl01-seng-ft-012120 | /lib/dog.rb | UTF-8 | 97 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | Class Dog = ("dog")
def bark
puts "woof"
end
Dog class #sit
puts "the dog is sitting"
end
| true |
d6b2ebc1cc5b71ea9a23af32e3f904d5521e1754 | Ruby | bbbbruno/memo_app | /models/memo.rb | UTF-8 | 858 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
require 'fileutils'
require 'yaml'
class Memo
attr_accessor :title, :content, :created_at, :id
def initialize(title: '', content: '', created_at:, id:)
@title = title
@content = content.gsub(/\R/, "\n")
@created_at = created_at
@id = id
end
class << self
def... | true |
3c98991cca6bb9a96d9d236c3b4d9d677eef54fe | Ruby | johnsusi/ai-viewer | /tools/qrc.rb | UTF-8 | 363 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'ostruct'
class Renderer < OpenStruct
def render
template = File.join(File.expand_path(File.dirname(__FILE__)), 'qrc.erb')
ERB.new( IO.read(template), nil, '-').result(binding)
end
end
ARGV.each do |pattern|
renderer = Renderer.new :files => Dir.glob(pattern).select { |file| File... | true |
836fc3b163af0cad52a9f95224e637e73e76bf95 | Ruby | nishimat/Euler | /p044.rb | UTF-8 | 713 | 3.546875 | 4 | [] | no_license |
def binary_search( arr, value)
left = 0
right = arr.size - 1
mid = 0
while left <= right do
mid = (left + right) / 2
if arr[mid] == value
return true
elsif arr[mid] < value
left = mid + 1
else
right = mid - 1
end
end
return false
end
def main
maxindex = 10000
pentagon... | true |
f56e99af34c20863ec4d6e24d3c7eaec4f873765 | Ruby | Souravgoswami/ruby-masterclass | /SECTION 16: Array II/Part11_The_find_any?_all?_methods.rb | UTF-8 | 3,865 | 4.46875 | 4 | [
"Unlicense",
"LicenseRef-scancode-proprietary-license"
] | permissive | #!/usr/bin/ruby -w
# PART 11
# The find method, as we saw previously, looks up for an element in an array
# passed as block.
# It returns nil if the item is not found.
# It returns an enumerator if no block is passed
a = %w(A ginger cat and a white bottle) # => ["A", "ginger", ... | true |
3b8ffaa2171875a5ab9dbecfb75f6e1e4e698028 | Ruby | MathildeSerret/Ruby_exos_S2 | /exo_19.rb | UTF-8 | 57 | 2.859375 | 3 | [] | no_license | for i in 0..50
next if i % 2 != 0
puts "jean.dupont.#{i}@email.fr"
end | true |
e3b93fcdd946d93ff1fee85ed1e5c3a3557ffdbf | Ruby | soufiane121/activerecord-tvland-nyc-clarke-web-100719 | /app/models/actor.rb | UTF-8 | 377 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Actor < ActiveRecord::Base
has_many :characters
has_many :show, through: :characters
def full_name
"#{self.first_name} #{self.last_name}"
end
def list_roles
answer = ""
character_name = self.characters.pluck(:name)
show_name = self.show.pluck(:name)
answer = character... | true |
824108627e661ec73fb15eac39914e640b2bfb61 | Ruby | AlisonZ/ride-share-two | /lib/trips.rb | UTF-8 | 2,802 | 3.078125 | 3 | [] | no_license | #require csv?
#require other lib files?
module RideShare
class Trip
attr_reader :id, :rider_id, :driver_id, :date, :rating
def initialize(id, driver_id, rider_id, date, rating) #rating must be between 1-5 or raise an error
@id = id.to_i
@rider_id = rider_id.to_i
@... | true |
2d99dc6f8985afae59a5feb8664b40ff0c083078 | Ruby | tkiefhaber/sales_engine | /lib/sales_engine/merchant.rb | UTF-8 | 3,609 | 2.890625 | 3 | [] | no_license | require 'date'
module SalesEngine
class Merchant
attr_accessor :results, :input, :id, :name, :created_at, :updated_at
def initialize(attributes = {})
self.id = attributes[:id].to_i
self.name = attributes[:name]
self.created_at = Date.parse(attributes[:created_at].to_s)... | true |
b18875f7c7117e7a87cb82928ff92494a8221eec | Ruby | dunlapww/monster_shop_2005 | /spec/features/sessions/new_spec.rb | UTF-8 | 6,991 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
# As a visitor
# When I visit the login path
# I see a field to enter my email address and password
# When I submit valid information
# If I am a regular user, I am redirected to my profile page
# If I am a merchant user, I am redirected to my merchant dashboard page
# If I am an admin user, I a... | true |
2101687d812927cedb68def257d7162c50c8c7bc | Ruby | botandrose/rw24 | /features/support/step_definitions/download_steps.rb | UTF-8 | 772 | 2.53125 | 3 | [] | no_license | require "csv"
Then "I should download a file named: {string}" do |filename|
page.driver.downloads[filename]
end
Then "I should download a CSV named {string} with the following contents:" do |filename, table|
file = page.driver.downloads[filename]
actual = CSV.parse(file.read).to_a
table.diff! actual
end
Then... | true |
04040bd5366ef66dcce9b339d139d391889c57b6 | Ruby | imvsnu/core-ruby-learning | /from_book/range.rb | UTF-8 | 1,445 | 3.21875 | 3 | [] | no_license | (-1..-5).to_a #=> []
(-5..-1).to_a #=> [-5, -4, -3, -2, -1]
('a'..'e').to_a #=> ["a", "b", "c", "d", "e"]
('a'...'e').to_a #=> ["a", "b", "c", "d"]
(0..2) == (0..2) #=> true
(0..2) == Range.new(0,2) #=> true
(0..2) == (0...2) #=> false
case 79
when 1..50 then print "low\n"
whe... | true |
eea1a6e654199297f79c119d5fb74f61a71f7649 | Ruby | kamataryo/monorepo | /Rakefile | UTF-8 | 1,275 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
task :lint do
system 'bundle exec rubocop'
end
task l: :lint
RSpec::Core::RakeTask.new(:spec)
task s: [:spec]
task test: [:spec]
task t: [:test]
# increments
def increment_version(section)
regex = /(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+)/... | true |
fcd4bfdf2ebfa75037a8869a77dc378d0e638e71 | Ruby | QBFreak/NightMAREbot | /sbin/newsbot/lib/tree.rb | UTF-8 | 2,265 | 3.765625 | 4 | [] | no_license | =begin
The Tree module can be included to give
"tree"-type functionality, including children
and several "drilling" methods.
=end
module Tree
#NB: @children should be set to [] in initialize
attr_accessor :children
@children = []
#Allows access to the children property much more easily
#for various methods.
... | true |
2c98851823ce48f94befd7a14657479227e6cf67 | Ruby | EncoreTechnologies/puppet-powershellmodule | /lib/puppet/provider/psrepository/powershellcore.rb | UTF-8 | 3,883 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x', 'encore', 'powershellmodule', 'helper.rb'))
Puppet::Type.type(:psrepository).provide(:powershellcore) do
initvars
commands pwsh: 'pwsh'
mk_resource_methods
def initialize(value = {})
super(value)
@property_flush =... | true |
735838f7283c12ff28ad72fc6acef1c1f8d88f68 | Ruby | jakejakearell/the_met | /lib/museum.rb | UTF-8 | 1,292 | 3.4375 | 3 | [] | no_license | class Museum
attr_reader :name, :exhibits, :patrons
def initialize(name)
@name = name
@exhibits = []
@patrons = []
@winner = nil
end
def add_exhibit(exhibit)
@exhibits << exhibit
end
def admit(patron)
@patrons << patron
end
def recommend_exhibits(patron)
@exhibits.reduce(... | true |
cf6888769d9c1783df2bcf425239e2baabcabffe | Ruby | Ben-893/bank_app | /lib/account.rb | UTF-8 | 716 | 3.296875 | 3 | [] | no_license | require './lib/transactions'
require './lib/printer'
class Account
attr_reader :balance, :transactions
def initialize(printer)
@printer = printer
@balance = 0
@transactions = []
end
def deposit(amount, transaction)
@balance += amount
transaction.credit = amount
transaction.balance = @... | true |
0e69104cff7d15b9f08ee78622304007db9fad86 | Ruby | eva0919/mypaper | /calChiSquare.rb | UTF-8 | 9,548 | 2.640625 | 3 | [] | no_license | wordList = Array.new
phoneWord = Hash.new # tf
phoneDfWord = Hash.new # df
nonPhoneWord = Hash.new # tf
nonPhoneDfWord = Hash.new # df
stopWordList = Array.new
# label from myself
Apple = [1,2,4,6,8,12,14,17,19,26,27,32,33,34,39,42,49,52,53,55,62,63,64,71,73,74,75,76,77,82,90]
Samsung = [1,2,4,10,12,13,14,15,17,20,23... | true |
69077bfbdd55250ce1ea952eb63ac76d0e1c7c0f | Ruby | MattRice12/blogs | /LC-blogs/access_control/user.rb | UTF-8 | 122 | 2.765625 | 3 | [] | no_license | class User
def name
puts "Sam"
end
private :name
end
user = User.new
user.send(:name)
user.public_send(:name)
| true |
aa55244db259c5c2e487ec227f06dafbc330086a | Ruby | ben-pritchard/to_do_with_sql | /spec/task_spec.rb | UTF-8 | 1,548 | 2.875 | 3 | [] | no_license | require("spec_helper")
describe(Task) do
describe("#do_it") do
it("returns the value of 'do_it'") do
test_task = Task.new({:do_it => "dishes"})
expect(test_task.do_it()).to(eq("dishes"))
end
end
describe("#due") do
it("returns the value of 'due'") do
test_task = Task.new({:do_it =... | true |
2dbe09bb7234916de18210767e874cf3900b1c84 | Ruby | NatashaRaime/FarMar | /lib/products.rb | UTF-8 | 1,997 | 3.03125 | 3 | [] | no_license | module FarMar
class Product
@@all_products_by_vendor = nil
@@all_products = nil
attr_accessor :product_id, :name, :vendor_id
def initialize(product_id, name, vendor_id)
@product_id = product_id
@name = name
@vendor_id = vendor_id
end
#return Vendor instance that... | true |
22246067786fd550cafa891659eac34c85406eff | Ruby | authorNari/chip | /lib/chip/command.rb | UTF-8 | 1,644 | 2.984375 | 3 | [
"MIT"
] | permissive | require "uri"
require "net/https"
module Chip
class Command
attr_writer :force
def install(url)
puts "Installing..."
code = ::Chip.fetcher.fetch(url)
fn = install_filepath(url)
unless @force
puts "#{fn}"
puts "---"
puts code
puts "---"
print "... | true |
471c7f99b50030abc01d0481dc31960127203951 | Ruby | iron-io/iron_consumer_starter | /slow/slowcode.rb | UTF-8 | 139 | 2.609375 | 3 | [
"MIT"
] | permissive | puts "Got message: #{IronConsumer.message.body}"
sleep_for = 10
puts "Sleeping for #{sleep_for} seconds..."
sleep sleep_for
puts "Woke up"
| true |
a0840573e29d2582fff988a270a4182d93925a03 | Ruby | krainboltgreene/intrinsic | /lib/intrinsic/intrinsicism/validation.rb | UTF-8 | 981 | 2.65625 | 3 | [
"MIT"
] | permissive | module Intrinsic::Intrinsicism
module Validation
attr_reader :validators, :errors
def self.included(subject)
super
subject.extend Validation
end
def validation_for(property, &block)
check_for_property property
add_validators property, block
end
def is_valid?(propert... | true |
76ba3df9bccca30a6a8f8b521fd9d0c5930403dd | Ruby | pianista215/SegmentationExample | /Step4/4-iterateAlgorithm.rb | UTF-8 | 3,354 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | #Once we have created the initial centroids, we have to make n iterations to finally assign a segment
#If you want to change the initial centroids just execute again the 3-assignInitialClusters script of ruby
#An expansion could be make a graph to see how is evolving the algorithm (this can be accomplished easily in Ma... | true |
11a28e633dde3c8eef8578a60656c7c0c4d56c41 | Ruby | plantamurajk/ruby-enumerables-introduction-to-map-and-reduce-lab-nyc-web-082619 | /lib/my_code.rb | UTF-8 | 740 | 3.5625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # My Code here....
def map_to_negativize(source_array)
negative_array = source_array.map { |i| -i }
return negative_array
end
def map_to_no_change(source_array)
new_array = source_array.map { |i| i }
return new_array
end
def map_to_double(source_array)
doubled_array = source_array.map { |i| 2*i }
return d... | true |
10cc3b1372e75838fde0984c479756becde3384f | Ruby | ysei/project_euler_solutions | /e031.rb | UTF-8 | 615 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'linked_list'
D = LinkedList[200, 100, 50, 20, 10, 5, 2, 1]
def value(v)
result = 0
d = D
v.each_with_index do |n, i|
result += n * D.head
d = d.tail
end
result
end
def count(total, denominations)
result = 0
if ! denominations.empty?
max_coins = total / denomin... | true |
87eab48c61c0a235388f9e3c4f06fdfb204f510a | Ruby | barelyknown/five_question_interview | /spec/problem_4_spec.rb | UTF-8 | 385 | 2.765625 | 3 | [] | no_license | require_relative "../large_number_formation"
RSpec.describe "Problem 4: Arrange numbers to create largest number" do
class Problem4
include LargeNumberFormation
end
subject do
Problem4.new
end
let :numbers do
[50,2,1,9]
end
it "arranges them to form the largest number" do
expect(subjec... | true |
33267f19514df65730662c786fc9cc72779118bf | Ruby | mihilbabin/infosec | /app/models/caesar.rb | UTF-8 | 991 | 3.390625 | 3 | [] | no_license | class Caesar
attr_reader :offset
LOW_RU_ALPHABET = Array('а'..'я')
UP_RU_ALPHABET = Array('А'..'Я')
LOW_EN_ALPHABET = Array('a'..'z')
UP_EN_ALPHABET = Array('A'..'Z')
def initialize(offset = 8)
@offset = offset
@encryptor = create_encryption_table(offset)
@decryptor = create_encryption_table(-... | true |
982c7b17d77e89da0d0eb76fa5e15eca0766b55f | Ruby | ngust/RottenMangoes | /app/models/movie.rb | UTF-8 | 1,180 | 2.609375 | 3 | [] | no_license | class Movie < ActiveRecord::Base
mount_uploader :image_path, AvatarUploader
has_many :reviews
validates :title,
presence: true
validates :director,
presence: true
validates :runtime_in_minutes,
numericality: { only_integer: true }
validates :description,
presence: true
validates :... | true |
01c4bf95aabc414def44a2bf96e8aad26844e8da | Ruby | KieranL/FE.rb | /src/game.rb | UTF-8 | 2,438 | 2.765625 | 3 | [] | no_license | require_relative 'chapter'
require_relative 'menu'
require_relative 'Constants/drawing_z'
require_relative 'settings'
require 'state_machine'
class Game
def initialize(window)
@window = window
@chapter = Chapter.new(window)
super()
end
state_machine :state, initial: :INTRO do
event :finish_intro... | true |
4f6b82cb8deb0458ff521a41b44a32db1331e6a7 | Ruby | worace/tdd-workshop | /cryptographer.rb | UTF-8 | 996 | 4.15625 | 4 | [] | no_license | class Cryptographer
def encrypt(message) #"ad"
# find position of the character (a -> 0)
# find the new (shifted) position (0 -> 13)
# find the character at that new position (13 -> n)
# what can we do -- encrypt single characters
# how do i encrypt a multicharacter string?
# encrypt each c... | true |
e405a01849cc286599e48897259e222f5f626a44 | Ruby | rupy/AizuOnlineJudge | /vol100/10025triangle.rb | UTF-8 | 241 | 3.53125 | 4 | [] | no_license | def triangle
(a, b, c) = gets.split.map{|i| i.to_i}
s = a * b * Math.sin(c * Math::PI / 180.0) * 0.5
l = a + b + Math.sqrt((a ** 2) + (b ** 2) - 2 * a * b * Math.cos(c * Math::PI / 180.0))
h = s / a * 2.0
puts s,l,h
end
triangle | true |
52c86dbaa2d5d4d8bae619aa71f7cbcb56e38875 | Ruby | ISS-Analytics/weather_weaver_api | /lib/weather_repo.rb | UTF-8 | 1,406 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
require 'google/cloud/bigquery'
# Repository class for BigQuery
class WeatherRepo
attr_reader :bigquery, :dataset, :table
module Error
class NoConnection < StandardError; end
end
# Setup connection to repo with either configured or specified parameters
# e.g., repo = Wea... | true |
a1100168ffe2d18583647536544f0d10cf7e9da6 | Ruby | mkitchingh/southwest-checkin-1 | /lib/autoluv/southwestclient.rb | UTF-8 | 4,740 | 2.59375 | 3 | [
"MIT"
] | permissive | require "rest-client"
require "securerandom"
require "json"
require "tzinfo"
require "shellwords"
module Autoluv
class SouthwestClient
# minimum required headers for all API calls
DEFAULT_HEADERS = {
"Content-Type": "application/json",
"X-API-Key": "l7xx0a43088fe6254712b10787646d1b298e",
"X... | true |
820233db6409aaf9d635d1e1b30cb4b17745bf6c | Ruby | azhi/BSUIR_labs | /7sem/BAA/lab3/server.rb | UTF-8 | 785 | 2.84375 | 3 | [] | no_license | require 'socket'
require 'pry'
PR_FLIP_CHANCE = 0.2
PRICE_RANGE = 100..10000
DELTA_PRICE_RANGE = -1000..1000
prices_count = ARGV[0].to_i
timeout = ARGV[1].to_i
@threads = []
@prices = [0] * prices_count
@prices.map!{ Random.new.rand(PRICE_RANGE) }
@gen_thread = Thread.new do
random = Random.new
loop {
@price... | true |
ea7569f1e7bfcd7140a2713eb58d565b9cf71db7 | Ruby | andriusch/blueprints_boy | /lib/blueprints_boy/configuration.rb | UTF-8 | 1,717 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
module BlueprintsBoy
# Contains configuration of blueprints. Instance of this is yielded in Blueprints.enable block.
# @example Configuring through Blueprints.enable block
# Blueprints.enable do |config|
# config.global = :user, :profile
# end
# @example Configuring di... | true |
70e5b32d587100c5e57edf759be66a1dc6282190 | Ruby | rlmoser99/design_patterns | /singleton/nato_example/person.rb | UTF-8 | 190 | 2.640625 | 3 | [] | no_license | class Person
def initialize(first, last)
@first = first
@last = last
@verbal = VerbalAssistance.new
end
def spell_last_name
@verbal.expanded_spelling(@last)
end
end
| true |
cf006cb8017398d123e71021a239f5ecb9c9f13b | Ruby | Ko-kiNanko/furima-34390 | /spec/models/user_spec.rb | UTF-8 | 5,958 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
# sleep 0.5(処理多くなりエラーが発生する場合にコメントアウトを外す)
end
describe "ユーザー新規登録" do
context '新規登録がうまくいきとき' do
it "nickname,email,last_name,first_name,last_name_kana,first_name_kana,birth_day,passwordとpassword... | true |
75ee8f747a6f04229b3b7577b8575da5ab7f980f | Ruby | codeAligned/aa-prep-work | /codeeval/easy/22_fibonacci_series/lib/22_fibonacci_series.rb | UTF-8 | 457 | 3.40625 | 3 | [] | no_license | def fibonacci_term(index)
sequence = [0, 1]
(index - 1).times do | index |
sequence << (sequence[-1] + sequence[-2])
end
sequence[index]
end
def read_indices(filename)
indices = File.readlines(filename)
indices.map(&:chomp).map(&:to_i)
end
def fibonacci_series(filename)
read_indices(filename).each d... | true |
214781e72b375317a151fb54bd715f55bcb2163f | Ruby | orbitalimpact/opal-phaser | /spec/core/math_spec.rb | UTF-8 | 11,142 | 2.890625 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | require 'spec_helper'
describe "Phaser::Math" do
let!(:game) { Phaser::Game.new }
it "PI2" do
expect(game.math.pi2).to eq(2 * Math::PI)
end
# This is between points, not vectors
# 0
# |
# |
#-0.5---*--- 0.5
# |
# |
# |
# 1
it "angle_between" do
... | true |
ecdbdc0f8a1658f0fd667fb6bf9be87a289a1a10 | Ruby | flanger001/tranquility | /bin/gem_update | UTF-8 | 1,088 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "open3"
puts "Create new branch? (press y to continue)"
print "> "
if gets.chomp.casecmp?("y")
system("git checkout master")
system("git branch -D gems/outdated")
system("git checkout -b gems/outdated")
end
# Build list
puts "Fetching gems...\n"
to_update, _status, = Open3.capture2... | true |
8acffba04f660eeef35b3211297976699aff2d79 | Ruby | AaronLasseigne/Rind | /test/children_test.rb | UTF-8 | 1,267 | 3.171875 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'rind'
class ChildrenTest < Test::Unit::TestCase
def setup
@parent = Rind::Html::Html.new()
@one = Rind::Html::P.new(:attributes => {:id => '1'})
@two = Rind::Html::P.new(:attributes => {:id => '2'})
@three = Rind::Html::P.new(:attributes => {:id => '3'})
@children = Rind::Childr... | true |
90efb0a506ca6222598eb2f9d3e672632b9124cc | Ruby | thebravoman/software_engineering_2014 | /class019_test/files_for_exam_2/results/Hristo_Dachev_29_277028c8.rb | UTF-8 | 1,337 | 3.078125 | 3 | [] | no_license | =begin
Develop a program named FirstName_LastName_ClassNumber_277028c8.rb
You are given an argument for a folder with .rb files. Other arguments should be discarded.
Find all the files from the folder which have more than 30 lines.
Sort the result by number of lines ASC
Produce a result in CSV format named result.csv.... | true |
4e3a9f9399de5041d32a5f7ed8254d1cc2a69ac5 | Ruby | TheMindset/whether_sweater | /app/services/geocoder_service.rb | UTF-8 | 542 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
class GeocoderService
def initialize(location)
@location = location
end
def coords
get_json("maps/api/geocode/json")
end
private
def conn
@conn ||= Faraday.new(url: "https://maps.googleapis.com/") do |faraday|
faraday.params["key"] = ENV['GOOGLE_MAPS_API_K... | true |
d12bb0d4944dea2c332caa5cf16d4de7979b90e1 | Ruby | darrylclarke/CodeCore | /week1/2015.08.12/function_test_2.rb | UTF-8 | 332 | 3.703125 | 4 | [] | no_license | def first_value(a, hash = {} )
a + hash.first[1]
end
puts first_value( 2, {a:1, b:2} ) #should return 1
puts "first value is #{first_value( 3,{a:1, b:2})}" #should return 4
puts "first value is #{first_value 3, a:1, b:2 }" #should return 4
puts first_value 1, a:441, b:2 # The interpretter treats the last argument ... | true |
9661e8932ce310e20434e90ccc6d1cb400e8ac4e | Ruby | arunavagreen/rubyexercises | /ex17.rb | UTF-8 | 2,939 | 4.03125 | 4 | [] | no_license | class Customer
def initialize(customer)
@customer = customer
end
# this initializes a Customer class
def print_customer_details
#puts "Id: #{@customer['id']}"
puts "Name: #{@customer['name']}"
puts "Address: #{@customer['address']}"
puts "Phone number: #{@customer['phonenumber']... | true |
2bbdf1c305659b32cac6b29e9997b492b0467c67 | Ruby | pelf/advent-of-code | /2017/14/p14.rb | UTF-8 | 1,174 | 3.40625 | 3 | [] | no_license | # knot hash copied from p10
def knot_hash(input)
lengths = input.each_char.map(&:ord) + [17, 31, 73, 47, 23]
list = (0..255).to_a
pos = skip = 0
64.times do
lengths.each do |length|
(length/2).times do |pos_inc|
s1 = (pos + pos_inc) % list.length
s2 = (pos + length - 1 - pos_inc) % ... | true |
636b2f30f02797b0bd7e910e30e1094c90fe7adb | Ruby | tgauguet/elevator | /app/models/call.rb | UTF-8 | 860 | 2.6875 | 3 | [] | no_license | class Call < ApplicationRecord
belongs_to :elevator
validates_presence_of :elevator_id, :direction, :floor_request, on: :create
validates_inclusion_of :direction, in: %w( up down )
validate :can_request_floor, on: :create
scope :uncomplete, -> { where(completed: false) }
scope :inside, -> { where(inside: tr... | true |
3037d178014b7e1ab55aba0e9232e9b923084079 | Ruby | 844196/renge.rb | /exe/renge | UTF-8 | 869 | 3.171875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'renge'
require 'optparse'
options = {}
OptionParser.new do |opt|
opt.on('-l', '--list', 'Print all quotes list and exit.') {|v| options[:l] = v }
opt.on('-f', '--file PATH', 'Specifiles the dictionary.') {|v| options[:f] = v }
opt.on('-n', '--number INT', 'Specify quote number.') {|... | true |
c8ca749727c1355e4f4ee898c033eaf45380067c | Ruby | blip-lorist/RubyWarrior | /level_5.rb | UTF-8 | 409 | 3.078125 | 3 | [] | no_license | class Player
def play_turn(warrior)
# Resting
if warrior.health < 14 && warrior.feel.empty? && @health <= warrior.health
warrior.rest!
# Moving forward
elsif warrior.feel.empty?
warrior.walk!
# Rescues
elsif warrior.feel.captive?
warrior.rescue!
# Fighting
else warr... | true |
b4209f4c211a5cfb0eaca4923cc2b83e2fb855b8 | Ruby | Itxaka/chef | /chef/lib/chef/monkey_patches/numeric.rb | UTF-8 | 273 | 3.0625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | unless 0.respond_to?(:fdiv)
class Numeric
def fdiv(other)
to_f / other
end
end
end
# String elements referenced with [] <= 1.8.6 return a Fixnum. Cheat to allow
# for the simpler "test"[2].ord construct
class Numeric
def ord
return self
end
end
| true |
629d63929d6dac34aaa866bba260fc7eeb2048b6 | Ruby | NawarYossef/launch_school | /coding_challenges/average_round_score.rb | UTF-8 | 440 | 4.03125 | 4 | [] | no_license | # Challenge :
# Create a function that returns the average of an array of numbers ("scores"), rounded to the nearest whole number.
# You are not allowed to use any loops (including for, for/in, while, and do/while loops).
# Solution :
def average(arr)
(arr.reduce(&:+).to_f / arr.size).round
end
average([5, 78, 52,... | true |
9f2d7dc6d05a19f40a2bc62a459d3e26c5ab93d7 | Ruby | kylehoward/udemy-ruby | /Udemy - Comprehensive Ruby Programming/basic_error_handling2.rb | UTF-8 | 87 | 2.96875 | 3 | [] | no_license | begin
puts nil + 10
rescue StandardError => e
puts "Error occurred: #{e}"
end
| true |
683336d0342f41664254d91e8bc0d848b7c90b21 | Ruby | SamuSan/Ruby_LemonadeStand | /spec/reconcile_sales_spec.rb | UTF-8 | 1,078 | 2.796875 | 3 | [] | no_license | require_relative '../lib/services/reconcile_sales'
require_relative '../lib/temperature_generator'
require_relative '../lib/foot_traffic_generator'
require_relative '../lib/market'
require_relative '../lib/inventory'
require_relative '../lib/day'
describe ReconcileDailySales do
let(:day) { Day.new(temperature... | true |
3d339a87f24786d643b93eb8a4b71ec624503ee0 | Ruby | BideoWego/my_algorithms | /__Ruby__/find_dup/index.rb | UTF-8 | 175 | 3.21875 | 3 | [] | no_license |
def find_dup(array)
hash = Hash.new(0)
array.each do |i|
hash[i] += 1
return i if hash[i] > 1
end
end
array = (1..100).to_a
array << 50
p find_dup(array)
| true |
d50104116cc4cb49d2bc052f277831d8a776802a | Ruby | stevecj/thyme | /features/support/domain_support.rb | UTF-8 | 637 | 2.71875 | 3 | [
"MIT"
] | permissive | module KnowsTheDomain
def application
Application.new(persistence)
end
def persistence
@persistence ||= Persistence.new
end
class Persistence
def initialize
@records = []
end
def save_new_activity_time_range(data)
@records << data
end
def all_activity_time_ranges
... | true |
660312501ca4db614a4aa0c965e86618a189fd61 | Ruby | jceaser/DailyBriefing | /test/lib/daily/segments/Face_test.rb | UTF-8 | 569 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | require 'minitest/autorun'
require_relative '../../../../lib/daily/segments/Face'
module Daily
module Segments
describe Face do
before do
@face = Face.new("daily_brefing.erb", {})
@face.hair_length = 3
end
describe 'is there long hair' do
it 'it must be long' do
@face.... | true |
5985aa9627fa1624fce41e84a6f0b5cee61bb48e | Ruby | Macaroni2629/Launch-School | /RB100_back_end_prep/ruby_exercises/return/breakfast_lunch_or_dinner_part4.rb | UTF-8 | 244 | 3.90625 | 4 | [] | no_license | def meal
puts 'Dinner'
return 'Breakfast'
end
puts meal
# This will return 'Dinner' on the first line and 'Breakfast' on the second line.
# Puts method will pass the 'Dinner' argument.
# Return will return the last line of the method. | true |
ac11a809f18395adb9e3c965a4a0823591fc962d | Ruby | ahorner/advent-of-code | /lib/2015/08.rb | UTF-8 | 393 | 3.234375 | 3 | [] | no_license | LINES = INPUT.split("\n")
def evaluated_difference(line)
line.length - eval(line).length
end
total = LINES.map { |line| evaluated_difference(line) }.sum
solve!("The original strings are longer by:", total)
def escaped_difference(line)
line.inspect.length - line.length
end
total = LINES.map { |line| escaped_dif... | true |
1b90ded33fb6044238623f283ba65e788367573b | Ruby | genometools/genometools | /scripts/mktexoptstable.rb | UTF-8 | 697 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"ISC",
"BSD-2-Clause",
"LicenseRef-scancode-mit-old-style",
"Zlib",
"MIT",
"BSD-3-Clause",
"bzip2-1.0.6"
] | permissive | #!/usr/bin/env ruby
# simple transfer -help option list to tex
opts = false
opt = ""
desc = ""
puts <<TEXT
\\begin{table}[hbpt]
\\centering
\\caption{<+caption+>}
\\begin{footnotesize}
\\label{<+label+>}
\\begin{tabular}{lp{0.6\\textwidth}}
TEXT
ARGF.each_line do |line|
if line =~ /^-/
if not opts
... | true |
b190d53253dcd1a7e2f12da390e3c2e79fba928c | Ruby | admuaq/oo-spaceship-practice-mod1 | /models/Spaceship.rb | UTF-8 | 609 | 3.015625 | 3 | [] | no_license | class Spaceship
attr_reader :name
attr_accessor :been_to_space
@@all = []
def initialize(name, been_to_space=false)
@name = name
@been_to_space = been_to_space
@@all << self
end
def self.all
@@all
end
def self.find_by_name(name)
self.all.find {|spaceship| spaceship.name == name}
e... | true |
a36baab989080afd4ecde492c1494527c5e133ef | Ruby | medusa-project/book-tracker | /app/config/configuration.rb | UTF-8 | 1,595 | 2.90625 | 3 | [] | no_license | ##
# Singleton interface to the application configuration.
#
# # Usage
#
# `Configuration.instance.key_name` (shorthand for
# `Configuration.instance.get(:key_name)`)
#
# # How the configuration system works
#
# The configuration system works in two different ways depending on the Rails
# environment:
#
# 1. In the dev... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.