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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e3a20fe01981220f1350e1ab6adba985372d707a | Ruby | himanz/object_oriented_programming | /sales_tax.rb | UTF-8 | 2,795 | 3.796875 | 4 | [] | no_license | class Taxes
def initialize(items)
@items = items
end
# Split the sentence into an array of words
def sentence_split(sentence)
arr = []
sentence.each do |item|
arr << item.split(" ")
end
@items = arr
end
# Remove the at word as it is useless
def remove_at(item_arr)
item_arr.e... | true |
0111a55ff10a14fa6b6c0d55b330f511176ad1e3 | Ruby | Chida-Takuya/2-8 | /lesson8-2.rb | UTF-8 | 389 | 3.828125 | 4 | [] | no_license | puts "計算をはじめます"
puts "何回繰り返しますか?"
input = gets.to_i
i = 1
while i <= input do
puts "#{i}回目の計算"
puts "2つの値を入力してください"
a=gets.to_i
b=gets.to_i
puts "a=#{a}"
puts "b=#{b}"
puts "計算結果を出力します"
puts "a+b=#{a+b}"
puts "a-b=#{a-b}"
puts "a*b=#{a*b}"
puts "a/b=#{a/b}"
i += 1
end | true |
bc8832f7fc2f0ce33fd8be21be1a577bdcd6d6d6 | Ruby | mattTea/battle | /spec/features/lose_spec.rb | UTF-8 | 296 | 2.609375 | 3 | [] | no_license | # As a Player,
# So I can Lose a game of Battle,
# I want to see a 'Lose' message if I reach 0HP first
describe "Lose Message" do
it "shows a message when a player's hit points reach 0" do
sign_in_and_play
attack_to_zero_points
expect(page).to have_content "Andy loses!"
end
end
| true |
4fb947cc93490e11aeafc6ce08eae3fbd07607de | Ruby | lina1812/study | /railway/menu/print.rb | UTF-8 | 1,679 | 3.53125 | 4 | [] | no_license | # frozen_string_literal: true
# Menu methods that relate to print
class Menu
module Print
private
def print_stations
Station.all.each.with_index(1) { |station, i| puts "#{i} #{station.name}" }
end
def print_trains(trains = Train.all)
trains.each { |train| puts train.number }
end
... | true |
9574fd9f01442f1a76ceaa20f1fee9bb4af666f5 | Ruby | FreedomBen/angelbot | /bots/moss.rb | UTF-8 | 2,920 | 2.875 | 3 | [] | no_license | require 'slackbot_frd'
class Moss < SlackbotFrd::Bot
EMERGENCY_TRIGGER_WORDS = %w[
emergency
urgent
].freeze
CHANNEL_TRIGGER_WORDS = %w[
<!channel
<!group
<!here
].freeze
NORMAL_TRIGGER_WORDS = %w[
moss
].freeze
EMERGENCY_MESSAGES = [
'"Dir sir/madam, FIRE!"',
'"Is this... | true |
2906742804af55dd7f1a5173e507aafe807b1c04 | Ruby | subatta/azbuild | /src/lib/dependency.rb | UTF-8 | 846 | 2.78125 | 3 | [] | no_license | def auto_add_dependencies(project)
@Dependencies = Array.new
each_package_dependency(project) do |package|
yield package
end
return @Dependencies
end
def each_package_dependency(project)
packages_config = File.join File.dirname(project), 'packages.config'
return [] unless File.exists? packages_confi... | true |
5752dfeb0764aa6102018a7f65b6d99a4a090078 | Ruby | benningm/circuit_client | /lib/circuit_client/send_message_cli.rb | UTF-8 | 3,826 | 2.921875 | 3 | [] | no_license | require 'circuit_client'
require 'getoptlong'
require 'yaml'
module CircuitClient
class SendMessageCli
class Config
DEFAULTS = {
timeout: 60,
host: 'eu.yourcircuit.com',
client_id: nil,
client_secret: nil,
auth_scope: 'ALL'
}
def self.load_config(path)
... | true |
5b82bc7f56a2f4bf74f7ec16b977d8a545ec99d4 | Ruby | udhayamgit/DreamSIS | /app/models/term.rb | UTF-8 | 5,166 | 2.953125 | 3 | [] | no_license | # Models a specific period of time, usually aligning to an academic calendar. This used to be called "Quarter" to model the academic quarters of the UW, but was renamed to Term to handle other types of calendars, such as semesters. The change also allows customers to use completely arbitrary calendar terms, like a full... | true |
7086ca6298b98571e148468a10f1036b2439b540 | Ruby | crguezl/sinatra-up-and-running | /chapter3/helpers_without_modules_56_57/app.rb | UTF-8 | 681 | 2.890625 | 3 | [] | no_license | # Example 3-10, page 57. Creating a helper via a block
#
require 'sinatra'
helpers do
def link(name)
case name
when :about then '/about'
when :index then '/index'
else "/page/#{name}"
end
end
end
['/', '/index', '/index.html', '/about', '/page/:random?'].each do |x|
get x do
@x = x
e... | true |
e5df5fbb6fa16869d0220b09cf8ca92bdf6a37bb | Ruby | lukaszklis/oo_boot_camp_2015-02-02 | /comparison/comparison.rb | UTF-8 | 598 | 3.453125 | 3 | [] | no_license | # Copyright 2015 by Fred George. May be copied with this notice, but not used in classroom training.
# Understands the "largest" among a collection of elements
class Comparison
def self.max(*elements)
elements.flatten.reduce(elements[0]) do |champion, challenger|
challenger.better_than?(champion) ? challe... | true |
31a87f18a8e126fb948c6aceb0c8b8282756ce91 | Ruby | jicheng1014/YanhaoTest | /test/models/user_test.rb | UTF-8 | 2,847 | 2.984375 | 3 | [] | no_license | require 'test_helper'
require 'date'
class UserTest < ActiveSupport::TestCase
test "appconfig load correct" do
assert APP_CONFIG['date_format'] =="big-endian"
user = User.new
assert_equal user.date_format,"big-endian"
end
test "Could user sets its birth_string?" do
user = User.new
# as... | true |
892363fe05100ca5f1b20f0f20bda8a5ab227994 | Ruby | southbridgeio/redmine_bots | /lib/redmine_bots/result.rb | UTF-8 | 234 | 2.765625 | 3 | [] | no_license | module RedmineBots
class Result
attr_reader :value
def initialize(success, value)
@success, @value = success, value
end
def success?
@success
end
def failure?
!success?
end
end
end
| true |
065ea0fddb47894aacfcefa9c90bae860c97121d | Ruby | Uthaeus/codewars_ruby | /7kyu/element_parity.rb | UTF-8 | 365 | 3.84375 | 4 | [] | no_license | # In this Kata, you will be given an array of integers whose elements have both a negative and a positive value, except for one integer that is either only negative or only positive. Your task will be to find that integer.
def solve(arr)
arr.each do |x|
if !arr.include? x * -1
return x
... | true |
9f5deb5c88690aaeac8a17fe90170e4698f47d90 | Ruby | seekingalpha/rocketchat-ruby | /lib/rocket_chat/info.rb | UTF-8 | 443 | 2.546875 | 3 | [
"MIT"
] | permissive | module RocketChat
#
# Rocket.Chat Info
#
class Info
# Raw info data
attr_reader :data
#
# @param [Hash] data Raw info data
#
def initialize(data)
@data = data.dup.freeze
end
# Rocket.Chat version
def version
data['version']
end
def inspect
format(... | true |
c571669d81c416e7a335e9ed6deb1b35894f71bf | Ruby | jackie-ell/ROF | /db/seeds.rb | UTF-8 | 29,095 | 2.625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
cb99c21399a1220731f8954e11c84da50fc36db6 | Ruby | Fluminiss/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 825 | 3.8125 | 4 | [] | no_license | #write your code here
def echo(word)
word
end
def shout(word)
word.upcase
end
def repeat(word, times = 2)
words = ""
times.times do |i|
if i == times-1
words += word
else
words += word + ' '
end
end
words
end
def start_of_word(word, amount)
word[0,... | true |
d0dd53ff471b9f63cef0db7b788efbf521d01ff1 | Ruby | kaiyu-tech/reminder-bot | /test/models/reminder_test.rb | UTF-8 | 2,414 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class ReminderTest < ActiveSupport::TestCase
def setup
travel_to("2021-06-16 12:00:00 +0900")
@event = events(:event_3)
@reminder = @event.reminders.build(number: 10, unit: 1, remind_at: nil)
end
test "should be valid" do
assert @reminder.valid?
end
test "event id sho... | true |
efbc58f779e6e3cf4b454d14ea5b0744f754bf87 | Ruby | CSOBerkeley/cskit-rb | /lib/cskit/formatters/science_health/science_health_plain_text_formatter.rb | UTF-8 | 2,081 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
module CSKit
module Formatters
module ScienceHealth
class ScienceHealthPlainTextFormatter < CSKit::Formatters::Formatter
# semicolon, question mark, or period
SENTENCE_TERMINATOR_REGEX = /[;\?\.]/
# either a period + space, quotes, or start of line followed by th... | true |
22eca0f66bef3410c5751528d84e991bcf68f433 | Ruby | kreyes12/ruby-objects-has-many-lab-london-web-071618 | /lib/author.rb | UTF-8 | 483 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Author
attr_accessor :name, :posts
@@all = []
def initialize(name=nil, posts)
@name = name
@posts = posts
@@all << self
end
def self.all
@@all
end
def add_post(message)
message.author = self
@@all << message
end
def add_post_by_title(post_title)
twee... | true |
877afedf74d47a7172948f549c56e705726e8a33 | Ruby | NiratheB/httpServer | /server.rb | UTF-8 | 814 | 2.953125 | 3 | [] | no_license | require 'socket'
require_relative 'library'
require_relative 'thread_pool'
localhost = '192.168.2.40'
port = 3000
server = TCPServer.new(localhost, port)
initPrintFormat
initLogFile
serve = Proc.new do |socket|
header, body= socket.recv(1024).split(/\r\n\r\n/, 2)
if (header=~/POST.*/)
log = getResponse(b... | true |
0d2189a7375832d9104bc4197edd84771d3b8017 | Ruby | maxgrok/ttt-with-ai-project-cb-000 | /lib/game.rb | UTF-8 | 2,511 | 3.953125 | 4 | [] | no_license | require 'pry'
require 'players/human'
require 'board'
class Game < Players::Human
attr_accessor :board
attr_writer :player_1, :player_2
WIN_COMBINATIONS = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[6,4,2]]
def initialize(player_1 = Players::Human.new("X"), player_2 = Players::Human.new("O"), boa... | true |
4e6ca2fc3d06b8fb5e73db99ea6c940c1396a565 | Ruby | BenRKarl/WDI_work | /w01/d03/Heidi_Williams-Foy/wdispec.rb | UTF-8 | 733 | 4.21875 | 4 | [] | no_license | require 'rainbow'
def assert_equal(actual, expected, statement)
if actual == expected
#print the staement in green
puts Rainbow(statement).green
else
#print the statement in red
puts Rainbow(statement).red
end
puts actual
puts expected
end
def add (x,y)
x+y
end
def divide(x,y)
if y == 0
return "NaN... | true |
2305c70272c9361a5e91cea7a493c69967063cae | Ruby | mkeshita/scratchpad | /lib/scratchpad/models/smartcard.rb | UTF-8 | 3,296 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # :nodoc: namespace
module Scratchpad
# :nodoc: namespace
module Models
# Model for the trusted smart-card.
class Smartcard
# Instantiates a new smart-card model.
def initialize(attributes = nil)
if attributes
# Restoring existing card.
@endorsement_key = Crypto.key_pair attributes[:ekey]
... | true |
336eb1c94e06083f37488a0ddd5ef2b294148fd0 | Ruby | barbarabontempo/Chlarity | /db/seeds.rb | UTF-8 | 1,558 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
User.destroy_all
Charity.destroy_all
Review.destroy_all
barb = User.create(name: "Barbara", city: "NYC", user_name: "barb")
sally = User.create(name: "Sally", city: "NYC", user_name: "sallysaves")
c1 = Charity.create(name: "Robinhood Foundation", city: "NYC", url: "www.robinhood.org")
c2 = Charity.create(name: "Cit... | true |
bd17ed45252b28a5c4fc5c99a0345338644694d0 | Ruby | DemidenkoAndrey/Design-Pattern-in-Ruby | /command/spec/composite_command_spec.rb | UTF-8 | 1,037 | 2.609375 | 3 | [] | no_license | require_relative '../command'
require_relative '../composite_command'
require_relative '../create_file'
require_relative '../copy_file'
require_relative '../delete_file'
describe CompositeCommand do
let(:commposite_command) { CompositeCommand.new }
let(:create_file) { CreateFile.new('1.txt', 'Content') }
let(:co... | true |
e7b91ef082930bd0f711c1e0c52aea94a47b497c | Ruby | cbatsoula/OO-mini-project-nyc-web-career-042219 | /app/models/Recipe.rb | UTF-8 | 978 | 3.078125 | 3 | [] | no_license | class Recipe
attr_reader :recipe_name
@@all = []
def initialize(recipe_name)
@recipe_name = recipe_name
@@all << self
end
def self.all
@@all
end
def self.most_popular
freq = RecipeCard.all.group_by {|rc| rc.recipe}
result = freq.sort_by {|k, v| -v.join.length}
result[0][0]
end
... | true |
3f22abe89bc81ceeb55f4ecdcc96bf6fa733b40c | Ruby | johanlunds/SpotifyPlaylistComposer | /PlaylistComposer/Song.rb | UTF-8 | 562 | 2.671875 | 3 | [] | no_license | #
# Song.rb
# PlaylistComposer
#
# Created by Johan Lundström on 2011-06-18.
# Copyright 2011 __MyCompanyName__. All rights reserved.
#
class Song
attr_accessor :selected
def initialize(wrapped)
@wrapped = wrapped
@selected = false
end
def artist
@wrapped.arti... | true |
0ce028b7998b954f6342067ea3d552f6740bc37b | Ruby | jumichot/Everydays | /til/Ruby/LEARN_BY_TESTS/Ruby/module_order_inclusion_spec.rb | UTF-8 | 285 | 2.890625 | 3 | [] | no_license | module C
def hello
p "world:C"
super
end
end
module B
def hello
p "world:B"
super
end
end
class A
include B
include C
def hello
"world:A"
end
end
describe "Module inclusion" do
it "test" do
expect(A.new().hello).to eq "world:A"
end
end
| true |
447632262f9af7380d66c5296046bc275b128508 | Ruby | h4hany/yeet-the-leet | /algorithms/Easy/1086.high-five.rb | UTF-8 | 1,236 | 3.515625 | 4 | [] | no_license | #
# @lc app=leetcode id=1086 lang=ruby
#
# [1086] High Five
#
# https://leetcode.com/problems/high-five/description/
#
# algorithms
# Easy (79.94%)
# Total Accepted: 33.4K
# Total Submissions: 41.8K
# Testcase Example: '[[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]'
#
# Given a li... | true |
d0ede1790cf7f0ed44ab2f5115fe5ecf6fc23b6c | Ruby | amanda-santos/studying-ruby-on-rails | /hashes.rb | UTF-8 | 206 | 3 | 3 | [] | no_license | states = {
"Pennsylvania" => "PA",
# "Pennsylvania" => "PA2", ERROR!
"New York" => "NY",
"Oregon" => "OR",
:California => "CA"
}
puts states[:California] #CA
puts states["New York"] #NY | true |
d727ff2d1a9bffff4b78f049fad20e77b1ef65a2 | Ruby | eduardo-salazar/SOA_flip_flap-1 | /flip_flap.rb | UTF-8 | 337 | 2.65625 | 3 | [] | no_license | require_relative 'tsv_buddy'
require 'yaml'
class FlipFlap
# Mixin from module tsv_buddy
include TsvBuddy
# Process yml string.
# Return: a array of hash.
def take_yaml(yml)
@data = YAML.load(yml)
end
# converts @data into yml string
# Return: yml format string
def to_yaml
@data.to_y... | true |
c3422526a25305be0454f6e97100e663b2f3f5bc | Ruby | SarpongAbasimi/CodeWarsRuby | /8kyu/GrasshopperPersonalizedMessage.rb | UTF-8 | 98 | 3.125 | 3 | [] | no_license | def greet(name,owner)
name == owner ? "Hello boss" : "Hello guest"
end
puts greet("sarp","sar")
| true |
5fb7cae148d1b26b482a8777941b379877d77da5 | Ruby | LewisYoul/lewisyoul.github.io | /index.rb | UTF-8 | 559 | 2.703125 | 3 | [] | no_license | class Index
LAYOUT_TEMPLATE = './src/layouts/default.html.erb'.freeze
INDEX_TEMPLATE = './src/layouts/index.html.erb'.freeze
def initialize(posts)
@posts = posts
end
def publish
File.open("./docs/index.html", 'w') do |file|
page = with_layout { html }
file.write(page)
end
end
pr... | true |
dc2f8b5b03b36d938b784d1ab9fbef6353589115 | Ruby | Hackthings/LadyProblemsNYCHack2016 | /db/seeds.rb | UTF-8 | 6,135 | 2.609375 | 3 | [] | no_license | require 'faker'
Item.delete_all
Bill.delete_all
Entry.delete_all
User.delete_all
4.times do
User.create!({ username: Faker::Superhero.power,
bio: Faker::Lorem.sentence,
city: Faker::Address.city,
state: Faker::Address.state,
email: Faker::Internet.email... | true |
0cc822af221215a96d8738f53188e52e2380da97 | Ruby | SandoBP13049/solver_bp13049 | /solver/arai/src/composer/count_constraint_fu_cr_composer.rb | UTF-8 | 5,497 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'set'
require 'rubygems'
require 'csp/normalizer'
#$KCODE="u"
#coding:utf-8
#
# なるべくRS::UNREADABLE_CHAR (不可読文字)を含まない読みを合成する。
# 制約数の少ないノードから探索する
class RS::Composer::CountConstraintFUCRComposer < RS::Composer::CompleteReadingComposerBase
attr_accessor :constraint_of
public
# コンストラクタ... | true |
5ed3c5b685724dd0f1add2280aad28fb71f019bb | Ruby | devtoro/recipypuppy | /recipe_puppy/spec/models/recipe_spec.rb | UTF-8 | 1,184 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Recipe, type: :model do
context 'Validations' do
it 'Should raise RuntimeError if invalid arguments are passed to validation method' do
attributes = { title: 'sample', invalid_attr: 'invalid' }
new_recipe = Recipe.new
expect ... | true |
7b8b6bbb31a1bdbb347e48c9a9001da45aabb023 | Ruby | andydenenberg/nvestr | /spec/stock_price_spec.rb | UTF-8 | 2,450 | 2.65625 | 3 | [] | no_license |
require 'spec_helper'
# rake db:test:prepare
describe 'Functional tests DenVestR' do
describe 'Portfolio is a basket of Stocks and Cash' do
it 'should contain cash' do
portfolio = Portfolio.new
portfolio.cash = 10000.00
(portfolio.cash).should eq(10000.00)
end
it 'should belon... | true |
72de46923d87458e6c68ec228014279dd4f61698 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/12705.rb | UTF-8 | 813 | 3.859375 | 4 | [] | no_license | # input: ['cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams','scream']
# => output: [["cars", "racs", "scar"], ["four"], ["for"],["potatoes"], ["creams", "scream"]]
# HINT: you can quickly tell if two words are anagrams by sorting their
# letters, keeping in mind that upper vs lowercase doesn't matter
def combi... | true |
33bd9babbeb302c1a513076bb171c5244b938db3 | Ruby | YinnyF/codewars | /Ruby/5KYU/simple-pig-latin.rb | UTF-8 | 222 | 2.8125 | 3 | [] | no_license | =begin
https://www.codewars.com/kata/520b9d2ad5c005041100000f
=end
# my solution 13/09/21
def pig_it text
text.split(" ").map {|word| word.match(/\A\W*\z/) ? word : "#{word[1..-1]}#{word[0]}ay" }.join(" ")
end
# notes
| true |
0659dc033f1e8b73c5b7a5be3e28bfed38f573b2 | Ruby | MasatoraAtarashi/Programming-Competition | /AOJ/ALDS1/data_structure/stack.rb | UTF-8 | 203 | 3.171875 | 3 | [] | no_license | input = gets.chomp.split(' ')
stack = []
input.each do |i|
if ["+", "-", "*"].include?(i)
a, b = stack.pop(2)
stack.push(a.send(i.to_sym, b))
else
stack.push(i.to_i)
end
end
puts stack
| true |
7f2b65232667045e05c01fc95fb0a3ecab6264c0 | Ruby | puppetlabs/forge-ruby | /spec/unit/forge/lru_cache_spec.rb | UTF-8 | 3,982 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
describe PuppetForge::LruCache do
it 'creates a cache key from a list of strings' do
expect { subject.class.new_key('foo', 'bar', 'baz') }.not_to raise_error
end
it 'creates a new instance' do
expect { PuppetForge::LruCache.new(1) }.not_to raise_error
end
it 'raises an error ... | true |
540b5fcbacc22cedfc5ef4d8746ca7dfa5606df3 | Ruby | chrisarrow90/launch_school_ruby | /the_basics/ex5.rb | UTF-8 | 331 | 4.09375 | 4 | [] | no_license | # Factorial
puts 5 * 4 * 3 * 2 * 1
puts 6 * 5 * 4 * 3 * 2 * 1
puts 7 * 6 * 5 * 4 * 3 * 2 * 1
puts 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1
# def factorial (num)
# i = num - 1
# sum = num
# while i > 0
# sum *= i
# i -= 1
# end
# sum
# end
# puts factorial(5)
# puts factorial(6)
# puts factorial(7)
# puts f... | true |
243207b6fd91a9805ccd2b93c12f7c482665fd09 | Ruby | nickrim/qa_repo | /ITA/hw_31/common/master_key/lib/master_key_list.rb | UTF-8 | 5,729 | 3.15625 | 3 | [] | no_license | require 'highline/import'
require 'encrypted_strings'
require 'json'
require 'net/ssh'
module MasterKeyList
class Authentication
def initialize()
@authentication_file = File.join(ENV['HOME'],'credentials_list.json')
end
def prompt_for_list_credentials()
credentials = {}
credentials[... | true |
7358a5387bdc935aad42b29a95514b3bb084ad7f | Ruby | mtadams007/ruby_mta_oop | /structure.rb | UTF-8 | 1,695 | 3.46875 | 3 | [] | no_license |
class Line
attr_reader :stops_arr, :name, :delays, :transfer_stations
def initialize (stops_arr,name)
@stops_arr = stops_arr
@name = name
@transfer_stations= {}
@delays = true
end
def stops
# puts @stops_arr
@stops_arr
end
def add_transfer(hash)
@transfer_stations = hash
en... | true |
2ec9cffe9709027a9514e0d74904a72e0ddc5102 | Ruby | dsimard/attr_object | /test/attr_object/value_test.rb | UTF-8 | 424 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
include AttrObject
describe Value do
let(:val) { Value.new AgeAttr, 30 }
let(:cast) { val.cast }
it "should return a `AgeAttr`" do
assert cast.is_a?(AgeAttr)
end
it "should call method on attribute" do
assert_equal 4, cast.decade
end
it "should change @value but keep the... | true |
107d08fcd5637c2c4b9b7d30d73488c254b720dd | Ruby | ilidnew/rails-longest-word-game | /app/controllers/spiel_controller.rb | UTF-8 | 1,283 | 3.046875 | 3 | [] | no_license | require 'open-uri'
require 'json'
class SpielController < ApplicationController
def game
@grid = generate_grid(9)
@start_time = Time.now.to_s
end
def score
@attempt = params[:guess]
grid = params[:grid].chars
start_time = params[:start_time].to_time
end_time = Time.now
@result = run_... | true |
060c8a763053d1364eac611c518741ba74c476c0 | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/rexml-3.2.5/lib/rexml/comment.rb | UTF-8 | 2,170 | 3.203125 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | # frozen_string_literal: false
require_relative "child"
module REXML
##
# Represents an XML comment; that is, text between \<!-- ... -->
class Comment < Child
include Comparable
START = "<!--"
STOP = "-->"
# The content text
attr_accessor :string
##
# Constructor. The first argume... | true |
e192b3e5aae161c70047b47afd0d87f5b0e05d02 | Ruby | dinobox/ruby_tools | /pbm/pbm2arr.rb | UTF-8 | 258 | 3.3125 | 3 | [] | no_license | def pbm2arr(file)
File.open(file,"r") do |file|
i = 0
arr = []
while line = file.gets #标准输入流
i +=1
if i > 3
arr << line.chomp
end
end
arr
end
end | true |
87b2e6769a6f39c7c51bbdbc1ca523d7ddbcb2dd | Ruby | ShawnCodes/oo-meowing-cat-nyc-web-040218 | /lib/meowing_cat.rb | UTF-8 | 113 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
## code your solution here.
class Cat
attr_accessor :name
def meow
puts "meow!"
end
end
| true |
72d3766c597259188aff3c2b7c56071ce250e81e | Ruby | leikind/oauth_client | /app/services/move_authentication.rb | UTF-8 | 916 | 2.5625 | 3 | [] | no_license | module MoveAuthentication
require 'openssl'
require 'net/http'
module_function
def move(from_user, to_user, auth_type, auth_uid)
do_move(auth_type, auth_uid, from_user.access_token, to_user.access_token)
end
def do_move(auth_type, auth_uid, from_jurid_token, to_jurid_token)
uri = BASE_IDP_URL +... | true |
a556ce35d031e9871e4e01d13fedda23f3f20220 | Ruby | ttaylorr/slacker | /lib/plugins/remember_plugin.rb | UTF-8 | 1,783 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'terminal-table'
require_relative 'plugin'
module Slacker
module Plugins
class RememberPlugin < Plugin
def ready(robot)
robot.respond /remember (.*) is (.*)/i do |message, match|
key, value = match[1], match[2]
remember(key, value, robot)
message << "Okay, I'... | true |
3df78e9dd2df83aa2e4a87569f126ba08f8327d2 | Ruby | imranraja85/ruby_skynet | /lib/ruby_skynet/simple_linear_regression.rb | UTF-8 | 920 | 3.4375 | 3 | [
"MIT"
] | permissive | require 'ruby_skynet/mean'
require 'ruby_skynet/variance'
module RubySkynet
class SimpleLinearRegression
attr_reader :x_coordinates, :y_coordinates, :x_mean, :y_mean
def initialize(coordinates)
raise "You should pass in an array of coordinates" if coordinates.empty?
@x_coordinates = coordinates... | true |
70a3f571f676dbd098efe9b89db2afa280af1404 | Ruby | jjuarez/life_simulator | /lib/life_simulator/tile.rb | UTF-8 | 363 | 3.109375 | 3 | [] | no_license | require 'life_simulator/location'
module LifeSimulator
##
# This class tries to represent a tile in our world
class Tile
def initialize(location)
@location = location
self
end
def inspect()
"Tile{ location: #{location} }"
end
def to_s()
inspect()
... | true |
7c48f7031e6b7ef746941f86f4c7f008966cb033 | Ruby | Steven-Galvin/shoe_store | /spec/brand_integration_spec.rb | UTF-8 | 1,788 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe("add brand path", {:type => :feature}) do
it("allows user to add brands") do
visit("/brands")
fill_in("name", :with => "Tester")
fill_in("price", :with => 25)
click_button("Add Brand")
expect(page).to have_content("Brand added successfully!")
end
end
describe("up... | true |
b969069b7e8885e8353276d2012812f3f9d3808e | Ruby | pbrumm/Cal_Capstone | /test/test_month.rb | UTF-8 | 5,496 | 3.34375 | 3 | [] | no_license | require 'month'
require 'minitest/autorun'
class TestMonth < MiniTest::Unit::TestCase
def test_01_test_zellers_base_case_01_2012
new_month = Month.new(1, 2012)
assert_equal(1, new_month.zeller)
end
def test_02_test_zellers_leap_year_02_2012
new_month = Month.new(2, 2012)
assert_equal(4, new_mon... | true |
3a17dd534119df581e795a686d909974bd6a9379 | Ruby | Cowskin/Design-patterns | /碎片代码/ruby_unit_test.rb | UTF-8 | 154 | 2.515625 | 3 | [] | no_license | require 'test/unit'
class EemptyTest < Test::Unit::TestCase
def setup
@ab= ''
end
def test_empty_on_string
assert @ab.empty?
end
end
| true |
a16d262c0addeadbda5f4ae8ad13848b74472827 | Ruby | sugaryourcoffee/secondhand | /spec/helpers/carts_helper_spec.rb | UTF-8 | 637 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the CartsHelper. For example:
#
# describe CartsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
de... | true |
33350ea04042970a545159dff69db7b3feada491 | Ruby | AJFaraday/ruby-jam | /lib/restore_game.rb | UTF-8 | 633 | 2.625 | 3 | [
"MIT"
] | permissive | class RestoreGame
attr_reader :data
def self.run(window)
restorer = self.new(window)
restorer.run if restorer.data
rescue Errno::ENOENT => er
puts er.message
end
def initialize(window)
@window = window
file_path = File.join(
File.dirname(__FILE__),
'..',
'data',
... | true |
cb37564a49d83f60c67f899666c8a4de8a52eda8 | Ruby | i09158knct/c6t-proto | /c6t-server/db/seeds.rb | UTF-8 | 1,367 | 2.875 | 3 | [] | no_license | # encoding: utf-8
RANDOM_SEED = 0
RANDOM = Random.new(RANDOM_SEED)
BASE_TIME = Time.new(2013, 9, 1)
def random_location_string
latitude = 34.0 + RANDOM.rand
longitude = 134.0 + RANDOM.rand
"#{latitude},#{longitude}"
end
def random_recently_time
random_offset = 60 * 60 * 24 * 30 * 2 * (RANDOM.rand - 0.5)
Ti... | true |
43badfc94c4d953803abb87175f157cc8680de93 | Ruby | jozr/damerau-levenshtein-distance | /damerau_levenshtein_distance.rb | UTF-8 | 1,544 | 3.984375 | 4 | [] | no_license | require "matrix"
require "pry"
# Still just levenshtein
class DamerauLevenshtein
def initialize(string_a, string_b)
@string_a = string_a
@string_b = string_b
@a_length = string_a.length
@b_length = string_b.length
@matrix = mutable_matrix(a_length, b_length)
end
def distance
return a_l... | true |
75d0332da36fc201d2fbed1457d67bc62c275903 | Ruby | oxywtf/ogden | /lib/og/model/orderable.rb | UTF-8 | 5,734 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | require 'facets/paramix'
module Og::Mixin
def Orderable(options)
options = options.rekey(&:to_sym)
mod = Orderable[*options]
#Paramix.new(Orderable) do
mod.module_eval do
alias_method options[:position], :position if options[:position]
#attr_accessor options[:type] if options[:type]
end
mod
end
... | true |
74f36e969290f7409449da43141c120479f6e9c5 | Ruby | tinchogon34/8puzzle | /lib/pieza.rb | UTF-8 | 230 | 2.921875 | 3 | [] | no_license | class Pieza
attr_accessor :valor, :fila, :columna, :direccion
attr_writer :direccion
def initialize(valor,fila,columna, direccion)
@valor, @fila, @columna, @direccion = valor, fila, columna, direccion
end
end
| true |
552a63340aa50620676516944e85e13d59b47d47 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/089bb72381734665ba79aab729c37a2b.rb | UTF-8 | 615 | 3.984375 | 4 | [] | no_license | class Anagram
def initialize(word)
@word = word
end
def match(words = [])
words.select(&anagram)
end
private
def anagram
->(word) { SortedWord.new(word) == SortedWord.new(@word) }
end
end
class SortedWord
def initialize(word)
@word = word
end
def ==(word)
not identical?(word... | true |
48c7d3e5c68c3d872b73e806e35ad8e7365ce058 | Ruby | shibainu-sakura/groupChallenge | /recommendrecipe.rb | UTF-8 | 521 | 2.890625 | 3 | [] | no_license | class Recipe
def initialize(mix )
@mix =mix
end
attr_accessor :mix
def pancake()
@milk_mixture = milk_mixture
@a_large_bowl = a_large_bowl
@eggs
@flour
@suger
@butter
puts "#{@mix} #{@eggs}, milk and vanilla essence to make #{@milk_mixture}."
puts "Shift #{@flour} into a... | true |
3012f816f2a73801b04727f8702f2587c86b06a7 | Ruby | tam-borine/Battle | /spec/player_spec.rb | UTF-8 | 421 | 2.765625 | 3 | [] | no_license | require 'spec_helper'
require_relative '../lib/player'
describe Player do
subject(:player_1) { Player.new("James") }
subject(:player_2) { Player.new("Tam") }
describe '#name' do
it 'has a name' do
expect(player_2.name).to eq 'Tam'
end
end
describe '#take_a_hit' do
it 'reduces the player... | true |
02e227726517540ee900830b44aedb65bc0c2adf | Ruby | thefonso/SOLID | /ocp_notes.rb | UTF-8 | 892 | 3.609375 | 4 | [] | no_license | # 1. OCP
# original - not open but closed
def main
puts "Welcome"
puts "Thanks for coming"
end
#
#
#
# But now the client wants to add multiple lanquages.
#
# So we abstract our main so we can plugin any lanquage we want
def main (welcome_statement, thanks_statement)
p welcome_statement
p thanks_stateme... | true |
0aade2980be1c983a33e09b0c7b28f9abe10a3d1 | Ruby | jacobdmartin/Go-Fish-Application | /tdd_ruby_card_game_war/spec/war_socket_server_spec.rb | UTF-8 | 2,535 | 3.046875 | 3 | [] | no_license | require 'socket'
require_relative '../lib/war_socket_server'
class MockWarSocketClient
attr_reader :socket
attr_reader :output
def initialize(port)
@socket = TCPSocket.new('localhost', port)
end
def provide_input(text)
@socket.puts(text)
end
def capture_output(delay=0.1)
sleep(delay)
@... | true |
34da794aecda00359a06a92d02c7d8ea91191506 | Ruby | g2belin/Week3 | /object.rb | UTF-8 | 467 | 3.640625 | 4 | [] | no_license | class Person
def initialize(first, last, age)
@first_name = first
@last_name = last
@age = age
end
def name
"#{@first_name} #{@last_name}"
end
def can_vote?
@age >= 18
end
end
belinda=Person.new("Belinda","Chan",30)
aileen=Person.new("Aileen","Chan",15)
people = [belinda, aileen]
... | true |
c16b265f12ea637f26ed000b6ecff25d7bff06ac | Ruby | kmdsbng/roguelike_ruby | /lib/roguelike/game_factory.rb | UTF-8 | 1,030 | 3.078125 | 3 | [] | no_license | # -*- encoding: utf-8 -*-
class Roguelike::GameFactory
def self.build_game
game = Roguelike::Game.new
game.hero = Roguelike::Hero.new(game, 2, 2)
game.enemies = [
Roguelike::Enemy::Bandit.new(game, 5, 5),
Roguelike::Enemy::Bandit.new(game, 3, 5),
]
game.map = generate_map
game
en... | true |
70c27d67e2559bf59300a908378208c8399df5d0 | Ruby | scalableinternetservicesarchive/TheShambles | /test/models/gamer_test.rb | UTF-8 | 1,926 | 2.8125 | 3 | [] | no_license | require 'test_helper'
class GamerTest < ActiveSupport::TestCase
def setup
@gamer = Gamer.new(gamername: "Paul", email: "paul@example.com", password: "password", password_confirmation:"password")
end
test "should be valid" do
assert @gamer.valid?
end
test "name should be present" do
@game... | true |
a7269c9be17b1ee32c991615e64a46972588bbae | Ruby | codeisawesome/coffee_and_code | /sept6.rb | UTF-8 | 677 | 3.984375 | 4 | [] | no_license | # Narcissistic Number
# sudo code
# 0. check if input to make sure it's a string of numbers
# 1. split the string input into an array_of_numbers
# 2. loop through each element of the array, and exponetiate each number to the power of the length of the str
# 3. sum each number cumulatively.
# 4. compare the ending sum ... | true |
e17163a320090b2ecf5e4e71b4d6d44043a5765c | Ruby | Joellehelm/silicon-valley-code-challenge-austin-web-091619 | /app/models/venture_capitalist.rb | UTF-8 | 1,267 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "funding_round"
class VentureCapitalist
attr_accessor :name, :total_worth, :all
@@all = []
def initialize(name, worth)
@name = name
@total_worth = worth
@@all << self
end
def self.tres_commas_club
self.all.select { |a| a.total_worth >= 1000000 }
... | true |
d46330dae6326774130b29e513e21ace08dc44ca | Ruby | sumnerjj/antcat | /out/test/antcat/models/reference_formatter_cache_spec.rb | UTF-8 | 3,266 | 2.515625 | 3 | [] | no_license | # coding: UTF-8
require 'spec_helper'
describe ReferenceFormatterCache do
it "is a singleton" do
expect {ReferenceFormatterCache.new}.to raise_error
expect(ReferenceFormatterCache.instance).to eq(ReferenceFormatterCache.instance)
end
describe "Invalidating" do
it "should do nothing if there's nothing... | true |
3bec4f9d2c64e5ba91c0160f21ffbcb93bc253c8 | Ruby | DarkToothDev/RailsTestProject | /db/seeds.rb | UTF-8 | 3,610 | 2.828125 | 3 | [] | no_license | require 'json'
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Ri... | true |
339e446c970ca78f3da0d9d443cc7166a47fd6cc | Ruby | RallyTools/Rally-Recycle-Bin-Utilities | /rally_empty_recycle_bin.rb | UTF-8 | 3,631 | 2.890625 | 3 | [] | no_license | # Copyright 2002-2013 Rally Software Development Corp. All Rights Reserved.
#
# This script is open source and is provided on an as-is basis. Rally provides
# no official support for nor guarantee of the functionality, usability, or
# effectiveness of this code, nor its suitability for any application that
# an end-use... | true |
11697d73e782cfbbebea8a25bd289f943e3c0df5 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/nucleotide-count/81c122e178e74f148afa515d1ead0a56.rb | UTF-8 | 684 | 3.59375 | 4 | [] | no_license | class DNA
attr_accessor :strand
def initialize(strand)
@strand = strand
strand.split("").each do |letter|
raise ArgumentError unless
accepted_nucleotides_for_dna.include?(letter)
end
end
def count(nucleotide)
raise ArgumentError unless
accepted_nucleotides_for_dna_and_rna.i... | true |
e34a7518a5b6f946447bc15151683ef8d06e6a21 | Ruby | abhinav-srivastav/basic-ruby | /hotel_reservation/hotel_reservation.rb | UTF-8 | 2,066 | 3.453125 | 3 | [] | no_license | require 'json'
require 'date'
require 'pp'
def hotel_reservation(from, till)
arrival = Date.parse(from)
departure = Date.parse(till)
duration = (departure - arrival).to_i
json = JSON.parse(File.read('hotels.json'))
sea_dur = 0
spl_rate = 0
json.each do |hotel_detail|
hotel_name = hotel_detail['Hotel_name']... | true |
8675348b44e337e0351c9f5daeafd129c2abb25f | Ruby | uddystyle/perfect_ruby_sample | /binding_object.rb | UTF-8 | 519 | 3.296875 | 3 | [] | no_license | class BindingCreator
def create_binding
a = 1
binding
end
end
creator = BindingCreator.new
binding_object = creator.create_binding
binding_object.receiver
creator == binding_object.receiver
binding_object.local_variables
binding_object.local_variable_defined?(:a)
binding_object.local_variable_defined?(:b... | true |
ac765dc39c0c389231f517fd8a1a83ce0f27e90e | Ruby | geelen/dollhouse | /lib/dollhouse/instance.rb | UTF-8 | 2,362 | 2.546875 | 3 | [
"MIT"
] | permissive | module Dollhouse
class Instance < Struct.new(:instance_name, :deployment_name, :server_name, :ip)
attr_accessor :user, :password
def bootstrap args = []
cloud_adapter.execute(instance_name, %Q{bash -c "`wget -O- babushka.me/up/#{[*args].push('hard').uniq.join(',')}`"}, default_opts)
end
def ba... | true |
b601d8afd272bd800140880d119ea14b66c81964 | Ruby | hiroshiuk1991/ruby-objects-has-many-lab-london-web-102819 | /lib/post.rb | UTF-8 | 203 | 3.078125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Post
@@all = []
attr_accessor :title, :author
def initialize(title)
@title = title
@@all << self
end
def author_name
author.name if author
end
def self.all
@@all
end
end | true |
003ed46ff79a914401b0b2dddc991a116c1483af | Ruby | gatchan0807/it-assingment01 | /Deposit.rb | UTF-8 | 1,529 | 3.3125 | 3 | [] | no_license | class Deposit
def initialize
@last_inputted_money = 0
@total = 0
end
def get_last_inputted_money
@last_inputted_money
end
def get_total
@total
end
def set_last_inputted_money(_last_inputted_money)
@last_inputted_money = _last_inputted_money
end
... | true |
c2ba9fc52e7856cf75eeb611dd2af7dd3489371f | Ruby | trevorrjohn/carbon-challenges | /carbon_calculation.rb | UTF-8 | 2,203 | 3.171875 | 3 | [] | no_license | # frozen_string_literal: true
require "json"
class CarbonAnalyticCalculator
def initialize(total_energy_use:, total_co2_equivalents_emissions:,
renewable_energy_purchased:, renewable_energy_produced:,
carbon_credit_value:)
@total_energy_use = total_energy_use
@total_co2_equ... | true |
bcb170149d65ee7fbb4513a9a287e39824396126 | Ruby | KrystleJustine/operators-dumbo-web-career-010719 | /lib/operations.rb | UTF-8 | 247 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def unsafe?(speed)
if speed > 60
true
else if speed < 40
return true
else
return false
end
end
end
def not_safe?(speed)
speed >= 60 ? true : false
speed < 40 ? true : false
speed >= 60 || speed <= 40 ? true : false
end
| true |
374a4a1377276e20d1f5aa41e6d88302c66aa977 | Ruby | zaptot/parser | /lib/parser/types/money.rb | UTF-8 | 543 | 3.015625 | 3 | [] | no_license | # frozen_string_literal: true
module Types
class Money
attr_reader :precision
def initialize(value, precision = 2)
@value = value.to_s.strip.to_f.round(precision)
@precision = precision
end
def to_s
integer_part, fractional_part = ("%.#{precision}f" % value).split('.')
integ... | true |
42d3ba4809cc3f60d184164d5957565b14217b71 | Ruby | katta/gk_cricket | /lib/over.rb | UTF-8 | 603 | 3.359375 | 3 | [] | no_license | require 'weighted_randomizer'
require 'innings'
require 'score'
class Over
MAX_BALLS = 6
def initialize(innings, current_over)
@innings = innings
@current_over = current_over
end
def play
MAX_BALLS.times do |current_ball|
current_striker = @innings.striker
weighted_randomizer = Weight... | true |
6749a270544f9b7f3fcc47965161d560af12d477 | Ruby | juan267/ruby-intro | /notes/OOP/oranges_solution/orange_tree.rb | UTF-8 | 1,676 | 4.34375 | 4 | [] | no_license | class NoOrangesError < StandardError
end
class OrangeTree
attr_accessor :age, :height, :dead, :orange
# Envejece el arbol
def initialize
@age = 0
@height = 0
@dead = false
@oranges = []
end
# condition = true
# unless !condition
# end
def dead?
if @age > 10
@dead = true
end
... | true |
81247aacb25a09a286113d8e2c2269bdbcc08531 | Ruby | davidtanxc/fitness_hypo | /app/models/user.rb | UTF-8 | 782 | 2.765625 | 3 | [] | no_license | class User < ActiveRecord::Base
validates :full_name, :email, :phone_number, :topic, presence: true
# TOPICS = ["Tennis", "Squash", "Table Tennis", "Badminton", "Bowling" ]
# CLASSTYPES = ["Private", "Group" ]
# attr_accessor :topics, :classtypes
# def topic_selectors
# TOPICS.collect { |topic| [(self.... | true |
6530e71b6481983b34caefd3bf904a13a11c79c1 | Ruby | Katy600/RSpec-EquivalenceMatchers-examples | /spec/observation_matchers_spec.rb | UTF-8 | 2,091 | 3.265625 | 3 | [] | no_license | describe 'observation matchers' do
# note that all of these use "expect{}", not expect()",
# It is a special block format that allows a process
# to take place inside of the expectation.
it 'will match when events change objects attributes' do
# it calls the test before the block,
# then again after th... | true |
588b40d9344e00cf274d39eedaad7734c4af19ee | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/crypto-square/d84a8705a78e4202af657ba997945bbb.rb | UTF-8 | 1,039 | 3.59375 | 4 | [] | no_license | class Crypto
def initialize(message)
@message = message
@normalize_text = normalize_plaintext
end
def size
message_length = @normalize_text.length
size = is_perfect_square?(message_length) ? message_length : find_next_perfect_square(message_length)
Math.sqrt(size).to_i
end
def normalize_... | true |
c98409f80b7a7308037b04709fc17bb3681f16aa | Ruby | PureMVC/puremvc-ruby-standard-framework | /src/org/puremvc/ruby/patterns/facade/facade.rb | UTF-8 | 5,715 | 2.953125 | 3 | [] | no_license | # In PureMVC, the Facade class assumes these responsibilities:
#
# * Initializing the Model, View and Controller Singletons.
# * Providing all the methods defined by the Model, View, & Controller.
# * Providing the ability to override the specific Model, View and Controller Singletons created.
# * Providing a single... | true |
9e8a7f0700eee7aeb44de18cc09ae23f2d85c86d | Ruby | sleepingkingstudios/sleeping_king_studios-tools | /spec/sleeping_king_studios/tools/integer_tools_spec.rb | UTF-8 | 8,660 | 3.09375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
require 'sleeping_king_studios/tools/integer_tools'
RSpec.describe SleepingKingStudios::Tools::IntegerTools do
let(:instance) { described_class.instance }
describe '#count_digits' do
it { expect(instance).to respond_to(:count_digits).with(1).argument }
... | true |
5eeeac3cd9a2a4522152826c68d38c973275d2d7 | Ruby | apouille/Badaboum | /app/models/child.rb | UTF-8 | 426 | 2.515625 | 3 | [] | no_license | class Child < ApplicationRecord
belongs_to :profile
enum sex: { Fille:1, Garçon:2 }
validates :nickname, :birthday, :sex, presence: { message: "Merci de remplir tous les champs du formulaire!" }
validate :birthday_cannot_be_in_the_futur
def birthday_cannot_be_in_the_futur
errors.add(:birthday, "La date de na... | true |
e7cd7d8ccb4a43921e39abf49c30f6597134f848 | Ruby | lucaslmmanoel/ruby-learnings | /basics/compare_operations.rb | UTF-8 | 136 | 3.046875 | 3 | [] | no_license | # Compare operations
v1 = 10
v2 = 11
puts v1 < v2
puts v1 <= v2
puts v1 > v2
puts v1 >= v2
puts v1 == v2
puts v1 != v2
puts v1.eql?v2
| true |
033fb871758e4381484a0a2214755a8a99422b62 | Ruby | mieki256/animepveasymakerzero | /test_script/select_folder_use_win32ole.rb | SHIFT_JIS | 967 | 2.515625 | 3 | [
"LicenseRef-scancode-public-domain",
"mplus"
] | permissive | #!ruby -Ks
# -*- mode: ruby; encoding: sjis -*-
# Last updated: <2013/08/04 03:32:16 +0900>
#
# DXRuby + WIN32OLE ̏ԂŃtH_I_CAOJĂ݂eXg
#
# DXRuby 1.5.1dev ł̓G[邪A1.5.2dev Ȃ薳B
require 'dxruby'
require 'win32ole'
fnt = Font.new(12)
dpath = ""
Window.loop do
break if Input.keyPush?(K_ESCAPE)
if Inpu... | true |
bef376576611475f09f54627d6a3f24026f77bb9 | Ruby | camillesalvador/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 566 | 3.859375 | 4 | [] | no_license | #write your code here
def echo(word)
return word
end
def shout(word)
return word.upcase
end
def repeat(word, num)
a = word
while num > 1 do
a = a + ' ' + word.to_s
num--
end
end
def start_of_word(word, num)
return word[0, num]
end
def first_word(str)
arr = str.split(" ")
return arr[0]
end
d... | true |
3f1ff7c5252410a8f11548ae4380177edeeb6b3e | Ruby | praveendhawan/training-exercises | /advanceruby/classes_from_csv_exercise/bin/main.rb | UTF-8 | 334 | 2.828125 | 3 | [] | no_license | require_relative '../lib/class_generator.rb'
require_relative '../lib/csv_reader.rb'
file_path = Dir.pwd + '/../data/employee.csv'
csv_reader = CsvReader.new(file_path)
klass = ClassGenerator.create_class(csv_reader.file_name, csv_reader.column_names)
rows = csv_reader.data
x = ClassGenerator.create_objects(klass,... | true |
d33031c1a1a3e8e438435fe56b7adaf2382cb718 | Ruby | yogeshjain999/office_automation_invoice | /spec/models/office_automation_invoice/invoice_spec.rb | UTF-8 | 2,478 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module OfficeAutomationInvoice
describe Invoice do
context 'checks for invoice fields' do
it { should have_field(:number).of_type(Integer) }
it { should have_fields(:issue_date, :due_date).of_type(Date) }
it { should have_fields(:total_amount, :due_amount, :discount).of_t... | true |
ffdd2bf5958f287fc84a2ed3dde4baaf16f92da4 | Ruby | branfull/backend_mod_1_prework | /section4/exercises/burrito.rb | UTF-8 | 865 | 4.09375 | 4 | [] | no_license | # Add the following methods to this burrito class and
# call the methods below the class:
# 1. add_topping
# 2. remove_topping
# 3. change_protein
class Burrito
attr_accessor :protein, :base, :toppings
def initialize(protein, base, toppings)
@protein = protein
@base = base
@toppings = toppings
e... | true |
a9e66cc4a7cde1eedc6b2b871940ff02c7d0727d | Ruby | DouglasAllen/mongo-Sinatra-Login-LouisSayers | /spec/unit/user_spec.rb | UTF-8 | 1,937 | 2.5625 | 3 | [] | no_license | require_relative '../test_setup'
describe 'user' do
before(:each) do
@user_info = {:name => "louis required", :email => "this and the rest are optional"}
@auth_details = UserAuthDetails.new("user_id", "provider", @user_info)
@user = User.new(@auth_details)
@user_as_hash = {'session_id' => @user.ses... | true |
24f610eb30478c3718fca43c76422834abab2baf | Ruby | marcokrikke/pdf-burst | /spec/burst_spec.rb | UTF-8 | 3,366 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe PDF::Burst do
context "page count" do
it "generates the command" do
burst = PDF::Burst.new("my.pdf")
expect(burst.send(:page_count_command)).to eq("pdfinfo 'my.pdf' | grep 'Pages:' | grep -o '[0-9].*'")
end
it "is the correct number" do
burst = P... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.