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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4c7899cc2cd82cd1723502408a279d83bf4b7ad7 | Ruby | GLSea1979/earlyruby | /array.rb | UTF-8 | 804 | 3.46875 | 3 | [] | no_license | puts ''
names = ['Gary', 'Julia', 'Laramie', 'Bob']
puts names
puts ''
puts names[0]
puts names[1]
puts names[2]
puts names[3]
puts names[4]
other = []
other [1] = 'hot dog'
other [4] = 'franks'
other [2] = 'beans'
puts other
puts ''
languages = ['English', 'Hebrew', 'Arabic', 'Italian']
languages.each do |lang|
... | true |
c66dcada90d9a3bae97f1a13a897435d1c77164e | Ruby | loicteixeira/summer-school-2016 | /01_array_enumerable_enumerator/ruby/MyEnumerator.rb | UTF-8 | 1,152 | 3.84375 | 4 | [] | no_license | #
# This class is a re-implementation of Ruby's `Enumerator`:
#
# https://docs.ruby-lang.org/en/2.0.0/Enumerator.html
#
# Example:
#
# a = MyArray[2, 3]
# enum = a.to_enum
# enum.next # => 2
# enum.next # => 3
# enum.next # raises StopIteration
#
# A class that extends this class should implement these meth... | true |
bcdb8cf6f084a7b416f6fba9f4fe69eac90d6cf5 | Ruby | danangww/go-scholar-exercise | /day2-exercise5.rb | UTF-8 | 409 | 3.71875 | 4 | [] | no_license | def find_palindrom(m,n)
results = []
while results.size != n
if (m.to_s == m.to_s.reverse) && (m.to_s.size != 1)
results << m
end
m += 1
end
# until count==n
# if (m.to_s == m.to_s.reverse) && (m.to_s.size != 1)
# count += 1
# results << m
# end
# m += 1
# end
return results
end
print find... | true |
785d4c203ac2c77d361fcd4bb5d1a3333208cca8 | Ruby | noiob/potd_bot | /potd_bot.rb | UTF-8 | 1,664 | 2.65625 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/env ruby
# coding: utf-8
# Pokémon of the Day Mastodon bot
# Written in Ruby by Alexis « Siphonay » Viguié on the 23-01-2018
# Check the attached LICENSE file
# Load required gems
require 'rest-client'
require 'mastodon'
require 'json'
require 'open-uri'
require 'http/form_data'
# Initialize Mastodon acces... | true |
93516c07e87dcc3644d476a1b50c358e39c5d482 | Ruby | arturcp/advent-of-code-puzzles | /puzzle10/part2/solution.rb | UTF-8 | 1,158 | 3.96875 | 4 | [] | no_license | require_relative '../input.rb'
class Combination
attr_reader :list, :cache
def initialize
@list = [0] + INPUT.sort
@list << (@list.last + 3)
@cache = {}
end
def number_of_combinations(current_joltage)
if current_joltage == list.last
1
elsif @cache[current_joltage]
@cache[curre... | true |
ee94347227d70f84b3fe4760fa2692aa70b14930 | Ruby | SandoBP13049/rails_test | /test5/lib/solver/dic/build_da.rb | UTF-8 | 249 | 2.859375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#DoubleArrayを構築して保存する
require_relative '../src/double_array.rb'
if ARGV.size != 2
puts "build source out"
exit(2)
end
source = ARGV[0]
out = ARGV[1]
da = DoubleArray.new
da.build(source)
da.save(out) | true |
902a6693d114ec9a19f366b2c597c523f166ea0e | Ruby | mfiore/tom | /combat/tom_ability.rb | UTF-8 | 1,464 | 3.140625 | 3 | [] | no_license | class TomAbility
attr_reader :name
def initialize(name)
@name=name
end
def execute(character,target)
if target
applied_effects_to_target=checkAndApplyAbilityEffects(character.ability_effects,character,target)
applied_effects_to_character=checkAndApplyAbilityEffects(target.ability_effects,target,character)... | true |
7444ce6225448375aaf7f4a577263af1926a4aa6 | Ruby | tsurutan/mock_coinhack | /app/models/coin_history.rb | UTF-8 | 229 | 2.921875 | 3 | [] | no_license | class CoinHistory
attr_accessor :time, :close, :high, :low, :open
def initialize(time, close, high, low, open)
self.time = time
self.close = close
self.high = high
self.low = low
self.open = open
end
end | true |
46fe2451759d01bab7f0a028f4d82578f23d2945 | Ruby | LesnyRumcajs/advent-of-ruby-2019 | /src/day13.rb | UTF-8 | 767 | 3 | 3 | [
"MIT"
] | permissive | require_relative 'components/intcodeparser'
input = File.read('res/day13.txt').split(',').map(&:to_i)
# part 1
blocks = 0
computer = IntCodeParser.new(input.clone)
until computer.finished?
computer.calculate
computer.calculate
blocks += 1 if computer.calculate == 2
end
p blocks
# part 2
# hack the memory
inpu... | true |
f73af5d289e72fdef61a8d3eb5a9880024bb9fc0 | Ruby | angelinalblyth/Codeclan | /week_02/day_4/snakes_and_ladders/tile.rb | UTF-8 | 130 | 2.609375 | 3 | [] | no_license | class Tile
attr_reader :position, :effect
def initialize(postition, effect)
@position = position
@effect = effect
end
end
| true |
650bcb0860a411bce5c2866cac2a975fc0a6d155 | Ruby | xjunior/taskbag | /lib/taskbag/bag.rb | UTF-8 | 832 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'thread'
module TaskBag
class Bag
def initialize(jobs=Queue.new)
@closed = true
@jobs = jobs
@threads = []
end
def open(nworkers)
raise "Bag is already opened!" unless closed?
@closed = false
_self = self
@threads = nworkers.times.map do
Thread.n... | true |
b5ac01a1bfa7074d3e87a30ccbe86278b5ff8abb | Ruby | couplee/Ruby_for_future_professionals | /ruby/chapter2/2.12.rb | UTF-8 | 9,448 | 3.96875 | 4 | [] | no_license | 💠 2.12 その他の基礎知識
💠 2.12.1 ガベージコレクション(GC)の意味はP.59確認
💠 2.12.2 エイリアスメソッド
Rubyにはまったく同じメソッドに複数の名前が付いてることがよくある。たとえば、Stringクラスのlengthメソッドとsizeメソッドは、名前が違うだけでどっちもまったく同じメソッド
ex) lengthとsizeは、どっちも文字数を返す
'hello'.length #=> 5
'hello'.size #=> 5
上記のようにまったく同じ実装で名前だけ異な... | true |
4697face94d777f7375c7ec4ab4169b2d0d9618e | Ruby | moofmayeda/nth-prime | /spec/nth_prime_spec.rb | UTF-8 | 406 | 3.03125 | 3 | [] | no_license | require("rspec")
require("nth_prime")
describe("nth_prime") do
it("returns the 1st prime") do
nth_prime(1).should(eq(2))
end
it("returns the nth prime for n") do
nth_prime(7).should(eq(17))
end
it("returns the nth prime for a really large n") do
nth_prime(300).should(eq(1987))
end
it("retu... | true |
5d060afc4f635be7eb4d3d8431c8f0c240bb3de8 | Ruby | jkarenko/projeuler | /14.rb | UTF-8 | 463 | 3.3125 | 3 | [] | no_license | # https://projecteuler.net/problem=14
seq_start = 999999
num = seq_start
seq = 1
biggest_seq = 1
biggest_start = seq_start
until seq_start == 1
#puts "biggest: #{biggest_seq}"
#puts "num: #{num}"
until num == 1
if num % 2 == 0
num /= 2
else
num = 3 * num + 1
end
seq += 1
#puts "num: #{num}"
end
... | true |
344c0ac6d9c7d698cb1483a49aaae38f2befa7bc | Ruby | nanokana/first_app | /samples/sample09_30.rb | UTF-8 | 85 | 3.078125 | 3 | [] | no_license | str = "Apple,Potato:Carrot"
str.split(/[,:]/) #=> ["Apple", "Potato", "Carrot"]
| true |
350aaa532ed80f8e203fb87fa3ac344c6a575892 | Ruby | melindadiaz07/programming-univbasics-4-basic-hashes-lab-wdc01-seng-ft-082420 | /lib/intro_to_ruby_hashes_lab.rb | UTF-8 | 230 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def new_hash
empty_hash = Hash.new
end
def my_hash
my_new_hash = { name: "Melinda", age: 31}
end
def pioneer
pioneer = {
:name => "Grace Hopper"
}
end
def id_hash_generator(number)
id_hash = {
:id => number
}
end | true |
d2d43df2b2e44fc3e0829719d3b5149935304af6 | Ruby | jhgould/food_truck_event_2003 | /lib/event.rb | UTF-8 | 1,427 | 3.578125 | 4 | [] | no_license | class Event
attr_reader :name, :food_trucks
def initialize(name)
@name = name
@food_trucks = []
end
def add_food_truck(food_truck)
@food_trucks << food_truck
end
def food_truck_names
names = []
@food_trucks.each do |truck|
names << truck.name
end
names
end
def food_... | true |
a34d0eaa1abf561fb453cfe53a0c521d8c27c1d7 | Ruby | mixelpixel/POODR | /ch5/ch5d.rb | UTF-8 | 572 | 2.765625 | 3 | [] | no_license | =begin
http://pdf.th7.cn/down/files/1502/Practical%20Object-Oriented%20Design%20in%20Ruby.pdf
CHAPTER 5 - Reducing Costs with Duck Typing pg.96
=end
# Case Statements That Switch on Class
class Trip
attr_reader :bicycles, :customers, :vehicle
def prepare(preparers)
preparers.each {|preparer|
case prepa... | true |
2bb6c9540ccc2d6c2184bf2685de0c274ba9a052 | Ruby | rahmaniansyah/elxgo-ruby-intermediet | /week-3/exercise/noonsession/db_connector.rb | UTF-8 | 493 | 2.65625 | 3 | [] | no_license | require 'mysql2'
require './item.rb'
def create_db_client
client = Mysql2::Client.new(
:host => 'localhost',
:username => 'root',
:password => '1305438asep',
:database => 'food_oms_db'
)
client
end
def get_all_items
client = create_db_client
raw_data = client.query(... | true |
a0ad92ce9431c053e0e19db9651773063395e56e | Ruby | susestudio/kanban | /bin/kanban | UTF-8 | 1,988 | 2.859375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require File.expand_path('../../lib/kanban',__FILE__)
output_dir = "html"
input_file = InputFile.default_file
do_pull = false
compact_lanes = false
swimlanes = true
extra_css = nil
plain_table = false
opt = OptionParser.new
opt.banner = "Usage: kanban <input-file>"
opt.on( "-h", "--help", "Print thi... | true |
b9eabfaae7e6f2667a789b9a06a3acae48403ff3 | Ruby | franpad8/advent-of-code-solutions | /Day2/Puzzle1/main.rb | UTF-8 | 744 | 3.890625 | 4 | [] | no_license |
def count_recurrences(word)
dic = {}
word.each_char do |ch|
if dic.has_key? ch
dic[ch] += 1
else
dic[ch] = 1
end
end
has_exactly_two_count = 0
has_exactly_three_count = 0
dic.values.each do |rec|
if rec == 2
has_exactly_two_count = 1
elsif rec == 3
has_exactly_three_count = 1
end
if ha... | true |
8ec983e820528fc31b860b218936b5001ef9cbb9 | Ruby | kn-shimada/ruby-learning | /helloworld.rb | UTF-8 | 209 | 2.6875 | 3 | [] | no_license | =begin
色々な "hello world!"
=end
print "hello world!" #改行ナシ
print "hello world!"
puts "hello world!" #改行アリ
puts "hello world!"
p "hello world!" #形式が分かる
p "hello world!" | true |
48429f378e1744762514c56f7f1c87039df7d9e9 | Ruby | El-Treshka/Tasks_rb | /9/285.rb | UTF-8 | 143 | 3.390625 | 3 | [] | no_license | def task_280(n)
x = 0.0
for a in 1..n
if a >= 0
x += a
else
x *= a
end
puts "x #{x}"
end
end
task_280(25)
| true |
7f62e910ddefe037765d6c70d384a5fe0f446d61 | Ruby | adamgriffis/code-eval-solutions | /prime-ranged/test.rb | UTF-8 | 547 | 3.609375 | 4 | [] | no_license | def is_prime(num, primes)
primes.each do |prime|
return false if (num % prime) == 0
end
return true
end
def find_primes(m, n)
primes = []
resPrimes = []
(2..n).each do |num|
if is_prime(num, primes)
primes.push(num)
resPrimes.push(num) if num >= m
end
... | true |
c9153625838493864841608626461f60a2db1ad0 | Ruby | cspraggett/jungle | /spec/models/product_spec.rb | UTF-8 | 1,662 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Product, type: :model do
describe 'Validations' do
it 'product is valid with all fields filled in' do
@category = Category.new(name: "Electronics")
@product = Product.new(name: "useless thing", quantity: 20, price: 200000, category: @category)
@product.save! ... | true |
e994bfaa12d423f20bf62b4f41bd9887efa70db4 | Ruby | atombender/spritz | /lib/spritz/cli.rb | UTF-8 | 2,941 | 2.59375 | 3 | [
"MIT"
] | permissive | module Spritz
class CLI
def run!(args = ARGV)
args.options do |opts|
opts.banner = %{
Usage:
#{File.basename($0)} pack [OPTIONS] PACKAGE FILE ...
#{File.basename($0)} pack -h | --help
}
opts.on("-h", "--help", "Show this help message.") do
puts opts
exit
... | true |
a92edfcab44c53083aede3d77e56e321c531742a | Ruby | meilke/bewildr | /lib/bewildr/control_type_additions/menu_additions.rb | UTF-8 | 2,252 | 2.859375 | 3 | [
"BSD-2-Clause"
] | permissive | #Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
module Bewildr
module ControlTypeAdditions #:nodoc:
module MenuAdditions
#Returns an array containing the menu's root items
def root_menu_items
get(:type => :menu_item, :scope => :children, :how_many => :all)
end
... | true |
1d33361e55fe941f228dc01dd39fbfdbd24914c6 | Ruby | CocoJu/rbstudy | /src/screencasts/14_att_read_write_access.rb | UTF-8 | 227 | 2.96875 | 3 | [] | no_license | require_relative "../src/cls/item"
item1 = Item.new({ :price => 30, :weight => 10 })
puts item1.price
puts item1.weight
item2 = Item.new({})
puts item2.price
puts item2.weight
puts Item.new({ :price => 30}).price
| true |
bd8676645ead39b4314f80bbab02cacee254ba34 | Ruby | AlexandraMerkel/learning_portal | /app/helpers/community_disciplines_helper.rb | UTF-8 | 472 | 2.640625 | 3 | [] | no_license | module CommunityDisciplinesHelper
def discipline_types_to_string(chosen_types)
types = []
chosen_types.each do |t|
types << Discipline::DIS_TYPES[t]
end
types.join(", ")
end
def discipline_select_options(selected)
options_for_select(Discipline.all.map{ |ds| ["#{ds.discipline_name} (... | true |
646c647e85cf8019cbb6f814ee2713ac0d696d85 | Ruby | Laevos/wakeonlan | /spec/net/wol_spec.rb | UTF-8 | 841 | 2.671875 | 3 | [
"MIT"
] | permissive | require "net/wol"
require "net/mac_address"
module Net
describe Wol, "payload" do
before(:each) do
@mac_address = Net::MacAddress.new("01-23-45-67-89-0A")
end
it "should contain 102 bytes" do
Wol.send(@mac_address.octets) do |payload|
payload.length.should == 102
end
... | true |
9bff9c9b69690538a7625b95ed31b86ac4505bfa | Ruby | orionos-dei/repo-ruby-learn | /beginner_stuff/ruby_testing/lib/calculator.rb | UTF-8 | 160 | 2.875 | 3 | [] | no_license | class Calculator
def add(*a)
a.map!(&:to_i) unless nil
a.inject(:+)
end
def multiply(*a)
a.map!(&:to_i) unless nil
a.inject(:*)
end
end | true |
39605bc22a84330284d2100b677450891afe4a8e | Ruby | joseWilton/Testes-Automatizados | /ruby/unitarios/spec/avengers_spec.rb | UTF-8 | 1,547 | 3.328125 | 3 | [] | no_license | class AvengersHeadQuarter
attr_accessor :list
def initialize
self.list = []
end
def put(avenger)
self.list.push(avenger)
end
end
describe AvengersHeadQuarter do
it 'deve adicionar um vingador' do
hq = AvengersHeadQuarter.new
hq.put('Spi... | true |
8d72dee8f347f182556004fa583b41c51da2763f | Ruby | danpersa/edge-state-machine | /lib/edge-state-machine/event.rb | UTF-8 | 1,143 | 2.578125 | 3 | [] | no_license | module EdgeStateMachine
class Event
attr_reader :name, :success, :timestamp
def initialize(name, machine, &transitions)
@machine = machine
@name = name
@transitions = []
instance_eval(&transitions) if block_given?
end
def fire(obj, options = {})
current_state = obj.curr... | true |
e55fe5e2dbaaf2964d5d2fd15ccc089f2ff8957e | Ruby | andrewmbyrd/sep-assignments | /01-data-structures/05-hashes-part-2/separate_chaining/separate_chaining.rb | UTF-8 | 3,471 | 4.0625 | 4 | [] | no_license | require_relative 'linked_list'
class SeparateChaining
attr_reader :max_load_factor
#we'll go ahead and populate each space in the base array with an empty linked list from
# the outset. also keep track of num items to make calculating Load Factor easy
def initialize(size)
@max_load_factor = 0.7
@bucke... | true |
4e092c8d1f9e338f3d5172fee19d0887847c1d2d | Ruby | glebson1988/BlackJack | /gamer.rb | UTF-8 | 337 | 3.1875 | 3 | [] | no_license | class Gamer
attr_accessor :money, :used_cards
START_BALANCE = 100
def initialize
@money = START_BALANCE
@used_cards = []
end
def score
total = used_cards.map(&:value).reduce(0, :+)
if total > 21
used_cards.count(&:ace?).times do
total -= 10 if total > 21
end
end
... | true |
beec0ba8a4ac20c68f25b40dc52ab59be1a29a63 | Ruby | davidtom/hangman-cli-web060517 | /lib/word.rb | UTF-8 | 696 | 3.515625 | 4 | [
"MIT"
] | permissive | #<Description of class>
class Word
attr_reader :word
# ## Initial Testing Word Library
# @@library = ["potato", "unicorn", "quixotic", "sweater", "humidity", "mountain", "goldfish", "aquatic", "plebian", "zebra"]
## Production Word Library: 55,900 Words
#Find current directory of file
@@pwd = Dir.pwd
#A... | true |
6dbbe00c57dff67bbeddb46d6244a36f526e734d | Ruby | hugoabonizio/my_thread_pool | /examples/sleep.rb | UTF-8 | 448 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'benchmark'
require '../lib/my_thread_pool'
# Number of request
N = 32
Benchmark.bm do |bm|
# This should take 32, 16, 8 and 4 seconds
[1, 2, 4, 8].each do |threads|
bm.report "Using #{threads} thread(s)" do
thread_pool = MyThreadPool.new(threads)
N.times do |i|
thread_pool.perform... | true |
2cbc0215afbb4459e2386ed04d963fa4bb6a200c | Ruby | ultrasaurus/trie_example | /dictionary.rb | UTF-8 | 1,227 | 3.328125 | 3 | [
"MIT"
] | permissive | require 'set'
class Dictionary
def initialize
@words = Hash.new
end
def words(subtree = @words, prefix="")
result = []
#puts "words #{subtree.inspect} #{result.inspect} #{prefix}"
return [] if @words.empty?
return [ prefix ] if subtree.empty?
subtree.each do |key, value|
result +=... | true |
2ee9035a962a9532ae6cc2508cb8721483b18559 | Ruby | askl56/income-tax | /spec/income_tax/countries/philippines_spec.rb | UTF-8 | 4,816 | 2.859375 | 3 | [
"MIT"
] | permissive | describe IncomeTax::Countries::Philippines do
subject(:result) { described_class.new(income: income, income_type: type, tax_year: tax_year) }
let(:type) { :gross }
describe 'from gross income of 0' do
let(:tax_year) { 2015 }
let(:income) { 0 ... | true |
8a41bc1d7e5b48f811ae0e48f7f70abe941d0c2f | Ruby | XRayV5/Project2-FlyConnected | /lib/db_utility.rb | UTF-8 | 2,798 | 2.625 | 3 | [] | no_license | require 'pry'
require 'active_record'
require_relative '../DB/db_config'
require_relative '../models/airport'
require_relative '../models/flight'
def destin_filter originSch_result, destin_city
route_sch = [];
originSch_result.scheduledResult.scheduled.each do |flight|
if flight.destination == destin_city
... | true |
93386654bc03ebf3b6a6a1b2142d69a2c286c82f | Ruby | ethanmmay/ruby-training | /learn_hashes.rb | UTF-8 | 136 | 2.625 | 3 | [] | no_license | initials = {
"Ethan May" => "EM",
2 => "ML",
"Nehemiah Boone" => "NB",
"Bri Baldwin" => "BB"
}
puts initials["Ethan May"]
puts initials[2] | true |
4bc8fe8f163fa686a6ff8bad752a7ec6733b7ccd | Ruby | e-mc2/thinknetica | /lesson_09/van.rb | UTF-8 | 359 | 2.5625 | 3 | [
"MIT"
] | permissive | class Van
include Validation
include Manufacturer
include InstanceCounter
attr_reader :number, :kind
validate :number, :presence
validate :number, :type, Fixnum
def initialize(number)
@number = number
@kind = kind!
validate!
register_instance
end
protected
attr_writer :kind, :s... | true |
99a316a3554f949047f0d3339b1c4ca2be87e2ca | Ruby | Anujan/riot-api | /lib/riot_api/client.rb | UTF-8 | 1,240 | 2.78125 | 3 | [
"MIT"
] | permissive | module RiotAPI
class InvalidAPIRequest < StandardError
end
# This class is what handles the requests to the API.
class Client
#API Version. Be aware that this is only a default value. It CAN be overriden within the methods.
VERSION = 'v1.1'
# Issues a GET request the the API. Pass in the region, and resource... | true |
3a97b42b12443b3d6646d0776e14a4ccb8691397 | Ruby | davepearson/rpn_calculator | /lib/rpn_calc_text_adapter.rb | UTF-8 | 1,276 | 3.65625 | 4 | [] | no_license | ##
# Adapter class that takes text input, processes it, then passes it along
# to the RPN Calculator
#
require_relative 'rpn_calculator'
class RpnCalcTextAdapter
##
# Initialize our adapter. All that needs to be done is to instantiate
# an instance of the RPN Calculator
#
def initialize
@calc = RpnCal... | true |
d86ebb108eb311f0207d6b8bd3d88904898b24e0 | Ruby | oscar-stack/vagrant-auto_network | /lib/auto_network/pool_storage.rb | UTF-8 | 3,232 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | require 'pathname'
require 'yaml/store'
require 'auto_network/pool'
module AutoNetwork
# This is a specialized subclass of `YAML::Store` that manages data
# persistence for {AutoNetwork::PoolManager} instances.
#
# In addition to managing serialization, the `YAML::Store` parent class also
# provides faciliti... | true |
bf8264cef2aca78690aab6a0a8f520877f4ee110 | Ruby | nickvirden/Cingo-Watir | /scripts/basics.rb | UTF-8 | 5,371 | 2.78125 | 3 | [] | no_license | # Requirements
require 'rubygems'
require 'watir'
require 'watir-webdriver'
require 'headless'
require 'dotenv'
require 'fileutils'
# Load .env
# Must be on same level of the directory as the .env
# Dotenv.load("../../../../.env") # Since this gets shared to other files, it has to specify the path relative t... | true |
15fd5add46bb04286390d0ea42b843df1c3613d1 | Ruby | aboutNY/ginvite | /scraping.rb | UTF-8 | 1,264 | 2.640625 | 3 | [] | no_license | # ソース: http://shibuya-o.com/east/schedule/
require 'nokogiri'
require 'anemone'
# db読み込み
# 参考: http://shuzo-kino.hateblo.jp/entry/20120913/1347551619
# db = SQLite3::Database.new('./db/development.sqlite3')
# 引数
gigPlace = "O-EAST"
url = "http://shibuya-o.com/east/schedule"
# dbクリーンアップ
Gig.destroy_all(place: "#{gig... | true |
cec25f7118ed1e3cccb848aaa05b52f8d2a2a987 | Ruby | MahironEX/AttendanceManagement | /controllers/attendances_controller.rb | UTF-8 | 1,455 | 2.734375 | 3 | [] | no_license | require "date"
class Public < Sinatra::Base
get '/attendances' do
@attendances = Attendance.all
haml :"attendances/index"
end
# idmの登録を確認
post '/attendances/is-exists-idm' do
params = JSON.parse(request.body.read)
result = User.where(idm: params["idm"]).exists?
{result: result}.to_json
e... | true |
76db4d9a48ae5270212af97c7e0ea9fe73f2b76c | Ruby | kazarixx/ruby | /dice.rb | UTF-8 | 330 | 3.71875 | 4 | [] | no_license | dice = 0 # 変数diceに0を代入し、初期値を設定する
while dice != 6 do # サイコロの目が6ではない間、diceの初期値は0なので条件を満たす。以降はdiceに代入される数によって結果が異なる
dice = rand(1..6) # 1~6の数字がランダムに出力される
puts dice
end | true |
fd38153667b82fc41aa203d670de52cd2d5b1255 | Ruby | reighley-christopher/riskychimp_public | /spec/lib/explanatory_variable_spec.rb | UTF-8 | 10,770 | 2.765625 | 3 | [] | no_license | require 'spec_helper'
describe ExplanatoryVariable do
before :all do
@test_file = <<-DSL_EXAMPLE
explanatory_variable :test_variable do
type :boolean
input Object
description "this is a test variable that returns true for any input"
calculate do |trans|
next true
... | true |
bff06bbe76cb37b84013e6757a16779588d7df14 | Ruby | neoson9999/op_paso | /app/models/sub_category.rb | UTF-8 | 1,296 | 2.671875 | 3 | [] | no_license | class SubCategory < ActiveRecord::Base
attr_accessible :name
belongs_to :category
belongs_to :parent, class_name: 'SubCategory', foreign_key: 'parent_id'
has_many :children, class_name: 'SubCategory', foreign_key: 'parent_id'
has_many :items
before_save :assign_depth
before_destroy :remove_association
... | true |
4eef6cfd6ceb82a311b455fd43bdf9b7e24f6aef | Ruby | piaoyehong1107/ruby-project-guidelines | /app/models/item.rb | UTF-8 | 583 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Item < ActiveRecord::Base
has_many :carts
has_many :reviews
def self.search_by_name(brand_name)
list=[]
Item.all.each do |m|
if m.brand==brand_name
list.push(m)
end
end
list.each do |m|
puts "#{m.name}-> #{m.cost}"
... | true |
ae39454aec3cce7588a831b143a5f01dded13589 | Ruby | rhardih/aoc | /2020/14p2.rb | UTF-8 | 3,688 | 3.71875 | 4 | [] | no_license | =begin
--- Part Two ---
For some reason, the sea port's computer system still can't communicate with
your ferry's docking program. It must be using version 2 of the decoder chip!
A version 2 decoder chip doesn't modify the values being written at all.
Instead, it acts as a memory address decoder. Immediately before ... | true |
3025cf82f9cb6a127bb4665182b4a8e937c084a3 | Ruby | letmecheck/app | /spec/models/king_spec.rb | UTF-8 | 13,519 | 2.96875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe King, type: :model do
describe '.in_check?' do
context 'when different pieces threaten the black king' do
before(:each) do
@game = Game.create
@game.pieces.each(&:destroy)
@black_king = King.create(x_coord: 5, y_coord: 8, color: 'black')
... | true |
df4ae7c4625fad12f2b53534ccf41c412b5200e5 | Ruby | jmondo/learnings | /learnings.rb | UTF-8 | 5,865 | 2.953125 | 3 | [] | no_license | # Ruby tips and tricks
args.select { |arg| Hash === arg } # use the === comparison for is_a?
args.grep(Hash) # do the same thing, but more cleanly. grep uses ===
args.reject! {|a| a.blank? } # it's like compact, but for blank strings /and/ nils
# Rails tips and tricks
Array.wrap(value) ... | true |
f962bbb58cc8722cf67a9e0bfb2142bdfb2a71af | Ruby | ajh/speaky_csv | /lib/speaky_csv/active_record_import.rb | UTF-8 | 3,626 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'active_record'
module SpeakyCsv
# Imports a csv file as unsaved active record instances
class ActiveRecordImport
include Enumerable
QUERY_BATCH_SIZE = 20
TRUE_VALUES = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES
attr_accessor :logger
def initialize(config, in... | true |
bdbfbabbb0b51e5b9e7592a570ae8adb5b2d57a0 | Ruby | hlissner/practice | /codeeval/easy/021sumofdigits/solution.rb | UTF-8 | 152 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
File.open(ARGV[0]).each_line do |line|
next if line.strip.empty?
puts line.split("").reduce { |sum, n| sum.to_i + n.to_i }
end
| true |
87b99900683c666af2b2becaa882423e528081ec | Ruby | dtinth/codejom56 | /qualification/paren.rb | UTF-8 | 93 | 2.8125 | 3 | [] | no_license |
cases do
puts gets.strip.reverse.chars.map { |x| { '(' => ')', ')' => '(' }[x] }.join
end
| true |
befd69278579a794665125716727766c9ee845a1 | Ruby | lenriquez/Programing-Problems | /two_number_sum/two_numbers_sum.rb | UTF-8 | 667 | 4.0625 | 4 | [] | no_license |
#Two numbers sum
#Given an array of numbers and a target number, write a function to check if two numbers in the list sum equal to the target number.
#
#You should ask / they may ask - solve before looking at this. (select to view)
#What if the list is sorted?
#Can you do it without using additional memory?
def two_n... | true |
98e3d22a2ea88add39fc6c46a1cf4eb150e6d4c6 | Ruby | ULL-ESIT-LPP-1819/tdd-alu0100955903 | /lib/prct06/lista.rb | UTF-8 | 3,368 | 3.734375 | 4 | [
"MIT"
] | permissive | Node = Struct.new(:value, :nest, :prev)
class List
#Modulo Enumerable
include Enumerable
#Punteros head y tail
attr_reader :head, :tail
#Creamos una lista e inicializamos los valores
def initialize (head, tail)
@head = head
@tail = tail
end
#Metodo insertar nodo por cola
def insertar_por_cola(... | true |
914d1551c25f78c37cd91bfbc65eb5e7e26f1463 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/luhn/5dd4ff68011744b1a995751a75f0d529.rb | UTF-8 | 460 | 3.25 | 3 | [] | no_license | class Luhn
def Luhn.create (n)
(0..9).each do |i|
return n * 10 + i if Luhn.new(n * 10 + i).valid?
end
end
def initialize (n)
@n = n
end
def addends
n, res, double = @n, [], false
while n > 0
k, n = n % 10, n / 10
res << -> x {x > 9 ? x - 9 : x}[double ? 2 * k : k]
... | true |
8bda2c9588fe4e07ddde19d325d233e704ca8fdd | Ruby | newhitson/a-A-Homeworks | /W1D5/DIY_ADTs.rb | UTF-8 | 1,014 | 3.59375 | 4 | [] | no_license | class Map
attr_reader :map
def initialize(map = [])
@map = map
end
def assign(key, value)
if lookup(key) != nil
remove(key)
end
@map << [key, value]
end
def lookup(key)
@map.each do |k|
return k if k[0] == key
end
nil
end
def remove(key)
@map.each_with_ind... | true |
a021e8d1aaa24acf584e822afac1ccbec0396050 | Ruby | kchu17/Divvy | /backend/routing/test.rb | UTF-8 | 2,275 | 2.875 | 3 | [] | no_license | require 'uri'
require 'json'
require_relative '../group'
API_KEY = open('api_key', &:read).trim
BASE_URL = 'https://maps.googleapis.com/maps/api/distancematrix/json'
class Object
def to_uri_params
to_s
end
end
class Array
def to_uri_params
map(&:to_uri_params).join(first.is_a?(Array) ? '|' : ',')
end
end
cl... | true |
91697ff5bb8d0e2f50db201223f360ec1ba31581 | Ruby | kil0rome0/ruby_drills | /lib/ruby_drills/chomper.rb | UTF-8 | 657 | 2.875 | 3 | [
"Apache-2.0",
"Ruby"
] | permissive | require 'io/wait'
class Chomper
# Allows 'Press any key to continue' to work without requiring return.
def self.get_char
begin
# save previous tty state
state = `stty -g`
# -icanon - disable canonical input (ERASE and KILL processing)
# sig - checking characters against control characte... | true |
46e2c3268974403f7c889ff1ea40b16923afd826 | Ruby | karimmtarek/todo-wiz | /spec/models/item_spec.rb | UTF-8 | 1,203 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
describe 'Item' do
let(:item) { FactoryGirl.create(:item) }
it "a new one can be created, with valid params" do
# item = Item.new(name: 'name', completed: false)
item.save
expect(item.save).to eq true
expect(Item.all.size).to eq(1)
end
it "completed is false when create... | true |
6ef9f712db5939345f4019c3a5976884afb8c5fa | Ruby | yeastymobs/remarkable_mongomapper | /lib/remarkable_mongomapper/matchers/have_key_matcher.rb | UTF-8 | 955 | 2.53125 | 3 | [
"MIT"
] | permissive | module Remarkable
module MongoMapper
module Matchers
class HaveKeyMatcher < Remarkable::MongoMapper::Base
arguments :type, :collection => :attributes, :as => :attribute
collection_assertions :has_key?
# before_assert do
# @type = @options[:type]
... | true |
9268613bfde210380794aad258afffb94840c326 | Ruby | estum/covercache | /lib/covercache.rb | UTF-8 | 8,743 | 2.546875 | 3 | [
"MIT"
] | permissive | require "covercache/version"
require 'active_support/core_ext'
require 'active_support/concern'
require 'active_record'
# == Motivation
#
# * Quickly use <tt>Rails.cache</tt> for some tasks without rubbish code in models.
# * Don't worrying about generation and storing cache keys, but sometimes will be able to adju... | true |
720194aa17828cd1c7eafae8382d2ae356fba1c5 | Ruby | JumpstartLab/sales_engine | /solutions/1337807/lib/sales_engine/invoice.rb | UTF-8 | 1,768 | 2.671875 | 3 | [] | no_license | require 'model'
module SalesEngine
class Invoice
include Model
attr_reader :customer_id, :merchant_id, :status
def initialize(attributes)
super(attributes)
@customer_id = clean_integer(attributes[:customer_id])
@merchant_id = clean_integer(attributes[:merchant_id])
@status = at... | true |
b747b39258a793d18dc3b756adcb8470260515e6 | Ruby | jhawthorn/adventofcode2017 | /04b.rb | UTF-8 | 210 | 2.8125 | 3 | [] | no_license | eval(File.read('data/04.rb'))
phrases =
DATA.lines.map do |line|
line.split.map do |word|
word.chars.sort.join('')
end
end.select do |phrase|
phrase.uniq == phrase
end
p phrases.count
| true |
c8b98664b799c0ac07b83fa9e243ee8e3d767bf4 | Ruby | ahjuice-learn-labs/OO-mini-project-dumbo-web-042318 | /app/models/User.rb | UTF-8 | 924 | 3.1875 | 3 | [] | no_license | require 'pry'
class User
attr_reader :name
ALL = []
def self.all
ALL
end
def initialize(name)
@name = name
ALL << self
end
#Tested Passed
def allergens
Allergen.all.select do |allergen|
allergen.user == self
end
end
#Tested Passed
def recipe_cards
RecipeCard.all.sele... | true |
f15b7a24bdb7079993bb8b75ead45c5c18607517 | Ruby | ramanujan/ticketee | /factories/user_factory.rb | UTF-8 | 2,845 | 3.1875 | 3 | [] | no_license | =begin
--Factory Girl--
FactoryGirl è utilizzato come rimpiazzo delle fixture. In pratica ci serve per simulare un oggetto
del nostro MODEL. In pratica possiamo simulare situazioni come, istanza salvata nel database,
istanza non ancora salvata,ecc...
Definiamo un ogge... | true |
8782a88745bfcbed14b74d03662c98185a71deb1 | Ruby | tsdeng/ruote | /test/functional/a_test.rb | UTF-8 | 12,164 | 2.546875 | 3 | [
"MIT"
] | permissive | #
# testing ruote
#
# Sun Aug 16 14:25:35 JST 2009
#
require 'yajl'
require 'ruote'
require 'ruote/storage/fs_storage'
require 'test/unit'
require 'ruote/participant'
require 'fileutils'
#define ruote extension
class Ruote::ProcessStatus
def current_work_items
current_positions=self.position
items=current_p... | true |
9d51659c9d71fba3c982c1e1040b64a5c3e463ac | Ruby | jbyrnesshay/launchschool_enrolled | /small_problems/easy_6/fib_simple.rb | UTF-8 | 474 | 3.71875 | 4 | [] | no_license |
def find_fibonacci_index_by_length(length)
first = 1
second = 1
index = 2
loop do
index+=1
fibonacci = first + second
break if fibonacci.to_s.size == length
first = second
second = fibonacci
end
index
end
p find_fibonacci_index_by_length(2) == 7
p find_fibonacci_index_by_len... | true |
37e6873a6ba8a008995614cf2740980f3f699938 | Ruby | ajamarco/ruby-project-guidelines-london-web-012720 | /modules/inventory.rb | UTF-8 | 3,310 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Inventory
@prompt = TTY::Prompt.new
def self.open_inventory
Printing.printing("Inventory", 0.0001)
table = TTY::Table.new [['Item', 'Owner']]
items = HeroItem.all
items.map{|i|
[i.item.name, i.hero.name]
}.each{|i| table << i}
puts "
====... | true |
a7b320446d36edd41bf339555da9dc8a7a44c530 | Ruby | shiftcommerce/flex-ruby-gem | /lib/paypal_express/process/response_parser.rb | UTF-8 | 5,231 | 2.796875 | 3 | [
"MIT"
] | permissive | # @module FlexCommerce::PaypalExpress::Process
module FlexCommerce
module PaypalExpress
module Process
# @class ResponseParser
class ResponseParser
def initialize(response:, shipping_method_model:)
self.response = response
self.shipping_method_model = shipping_method_model... | true |
0029a94c14ca6278e0f0ae5b2b86664909adda36 | Ruby | rajsolanki/homework_assignments | /warm_ups/number_guessing_practice2.rb | UTF-8 | 855 | 4.15625 | 4 | [] | no_license | # generates a random number from 1-5
number = Kernel.rand(5) + 1
# sets initial guess outside range to enter loop
guess = 0
# base tries to add to with each guess
tries = 0
# prompt user to guess a number
print "I'm thinking of a number from 1-5. Take a guess: "
# loop that runs if guess does not equal number
while gue... | true |
bfeececd6ecb1ad6e55d1337e398f80580d75000 | Ruby | rodrigovp/banco | /ruby/leitor_de_transacoes.rb | UTF-8 | 1,160 | 2.765625 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__)) + '/leitor_de_arquivos_csv_do_banco.rb'
require File.expand_path(File.dirname(__FILE__)) + '/dinheiro.rb'
require File.expand_path(File.dirname(__FILE__)) + '/credito.rb'
require File.expand_path(File.dirname(__FILE__)) + '/debito.rb'
class L... | true |
c73d97ba254956a7c6f1a29a7e50dbe202786e64 | Ruby | Neodelf/numbers_and_words | /spec/numbers_and_words/i18n/i18n_spec.rb | UTF-8 | 899 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe NumbersAndWords::I18n do
describe '.local_language' do
it 'checks validity of given language and return it as symbol' do
expect(NumbersAndWords::I18n.local_language(:de)).to eq(:de)
end
context "when string given instead of symbol" do
it "correctly normalizes ... | true |
9cff276b1e09256db9bb11af686c2274281463b5 | Ruby | mohammadaliawan/ls-prep | /ruby_basics/user_input/launch_school_printer_2.rb | UTF-8 | 542 | 3.984375 | 4 | [] | no_license |
def valid_number?(number_string)
number_string.to_i.to_s == number_string
end
loop do
puts "How many output lines do you want?\n>>Enter a number >= 3:" +
"(Q or q to quit)"
number = gets.chomp
if number.downcase == "q"
break
elsif valid_number?(number)
if number.to_i >= 3
number.to_i.... | true |
b2d2eda42625785afea32b01324c55bf326c8ecb | Ruby | jamartinezvillar/econfig | /lib/econfig/redis.rb | UTF-8 | 309 | 2.8125 | 3 | [
"MIT"
] | permissive | module Econfig
class Redis
def initialize(redis)
@redis = redis
end
def keys
Set.new(@redis.keys)
end
def has_key?(key)
@redis.exists(key)
end
def get(key)
@redis.get(key)
end
def set(key, value)
@redis.set(key, value)
end
end
end
| true |
0b523f702ac8effd2a639b40bd82d17b3ba2bbb1 | Ruby | molit-korea/main | /Pages/2017 국토교통 빅데이터 해커톤 참가작/molit_HAB-master/elastic/logstash-5.5.2/vendor/bundle/jruby/1.9/gems/sequel-4.49.0/lib/sequel/adapters/ibmdb.rb | UTF-8 | 14,518 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | # frozen-string-literal: true
require 'ibm_db'
Sequel.require 'adapters/shared/db2'
module Sequel
module IBMDB
# SEQUEL5: Remove
@convert_smallint_to_bool = true
class << self
def convert_smallint_to_bool
Sequel::Deprecation.deprecate("Sequel::IBMDB.convert_smallint_to_bool", "Call this m... | true |
c1c64e0cad526a12d91f178d23a86203264588be | Ruby | isaichenko/joblisting89 | /app/services/stripe_charges_service.rb | UTF-8 | 1,687 | 2.515625 | 3 | [] | no_license | class StripeChargesService
DEFAULT_CURRENCY = 'usd'.freeze
attr_accessor :stripe_email, :stripe_token, :job, :plan, :company
def initialize(params, related_params)
@stripe_email = params[:stripeEmail]
@stripe_token = params[:stripeToken]
@job = related_params[:job]
@plan = related_params[:plan]... | true |
5967874365d74ef10222694cbf8bba63b7ffe027 | Ruby | ryt11/module_3_assessment | /app/models/store.rb | UTF-8 | 542 | 3.140625 | 3 | [] | no_license | class Store
attr_reader :long_name, :city, :phone, :store_type, :distance
def initialize(store_info = {})
@long_name = store_info["longName"]
@city = store_info["city"]
@phone = store_info["phone"]
@store_type = store_info["storeType"]
@distance = store_info["distance"]
end
def self.store... | true |
1d147efc04e42607cc16f55a5b77ba18340da5c7 | Ruby | pzavolinsky/bauxite | /lib/bauxite/actions/assertm.rb | UTF-8 | 2,067 | 2.734375 | 3 | [
"MIT"
] | permissive | #--
# Copyright (c) 2014 Patricio Zavolinsky
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | true |
0086158abd76d761027cde607f028a02fa01dc63 | Ruby | nsnolen/keto_recipes | /lib/keto_recipe/cli.rb | UTF-8 | 814 | 3.1875 | 3 | [
"MIT"
] | permissive | class KetoRecipe::CLI #namespace
def call
puts "Welcome to Keto Recipes"
name
end
def name
#recipe lists come from scraping of webiste
puts "Please type the number of the recipe you'd like to learn more about."
@recipes = ["recipe_1", "recipe_2", "recipe_3", "recipe 4"]
@recipes.each_... | true |
8f179d9778a77a79ee2c6d1d2fce3eeb172f8208 | Ruby | ATLANTBH/TransactionStorage | /lib/soft_delete/active_record_wrapper.rb | UTF-8 | 518 | 2.515625 | 3 | [] | no_license | module SoftDelete
def self.included(base)
base.extend(ClassMethods)
end
def delete
self.update_attribute('deleted', true)
end
def undelete
self.update_attribute('deleted', false)
end
def deleted?
!!read_attribute(:deleted)
end
module ClassMethods
def delete_all(c... | true |
363f6be8464401a1f676b84615faa7d79405b28e | Ruby | teresa-m-knowles/battleship | /test/player_test.rb | UTF-8 | 529 | 2.75 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
require './lib/cell'
require './lib/ship'
require './lib/board'
require './lib/player'
class PlayerTest < MiniTest::Test
def test_it_exists
human = Player.new("Teresa")
assert_instance_of Player, human
end
def test_computer_places_five_s... | true |
571d6ae581d702c69201d2162d30fab98f346b9f | Ruby | eyaltoledano/shopify-app-reviews | /lib/shopify_app_reviews/cli.rb | UTF-8 | 5,725 | 3.234375 | 3 | [
"MIT"
] | permissive | # # CLI Controller
require_relative 'app_review.rb'
require_relative 'shopify_app.rb'
require_relative 'app_list_scraper.rb'
require_relative 'app_review_scraper.rb'
require 'colorize'
class ShopifyAppReviews::CLI
def run
welcome
scrape_and_create_apps
library_updated
get_input
goodbye
end
... | true |
89271c52aca54274e7b0f77a1ecce0f4dff656b3 | Ruby | SK-Sam/night_writer | /lib/writer.rb | UTF-8 | 676 | 3.015625 | 3 | [] | no_license | require './lib/en_to_braille_dict'
require './lib/braille_to_en_dict'
class Writer
def initialize(output_file_name, file_content)
@output_file_name = output_file_name
@file_content = file_content
@en_to_braille_dict = EnToBrailleDict.new
@braille_to_en_dict = BrailleToEnDict.new
... | true |
37aee42f81e3971238e0ca8a4145f074bb175de2 | Ruby | mjacobus/deutsch | /lib/pagination.rb | UTF-8 | 789 | 3.109375 | 3 | [] | no_license | class Pagination < Collection
attr_reader :current_page_number, :per_page
def initialize(collection: [], page: 1, per_page: 50)
super([])
self.per_page = per_page
self.current_page_number = page
collection_class = collection.class
collection.each_slice(self.per_page).map do |elements|
p... | true |
8e05d484f87a622e8cb7877ed3ca02929827d395 | Ruby | xablen/Semaine9_ruby_frequence | /exo_compteur.rb | UTF-8 | 737 | 3.765625 | 4 | [] | no_license | text = "Un homme nourrissait une chèvre et un âne. Or la chèvre bla bla bla..."
=begin
* Créer un hash pour stocker les mots
* Obtenir un tableau des mots de notre texte (split())
* Itérer sur le tableau précédent
* Remplir le hash
* Afficher les informations
** Organiser les mots pour sortir les mots les plus fréqu... | true |
8f16eb8b84ef8d8e8f70b2a68b77da6b22925617 | Ruby | plapicola/company | /lib/company.rb | UTF-8 | 862 | 3.671875 | 4 | [] | no_license | class Company
attr_reader :name
def initialize(name)
@name = name
@departments = []
end
def add_department(department)
@departments << department
end
def payroll
@departments.sum {|department| department.total_payroll}
end
def average_age
total_age = 0
count = 0
@departm... | true |
443291d54d08f46749873cb3472797994d5cccca | Ruby | shokunin-kishitsu/currency-data-challenge | /app.rb | UTF-8 | 1,827 | 2.625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/base'
require 'sinatra/activerecord'
require 'chartkick'
require_relative 'models/currency_converter'
require_relative 'models/current_rate'
require_relative 'models/historical_rates'
require_relative 'models/rate'
set :bind, '0.0.0.0'
set :port, 8080
class CurrencyDataChallenge < ... | true |
bc93effcd6cb2df481fc15a247708510ad3efcae | Ruby | cpcsacggc/RubySchool.US | /arc/07/app2.rb | UTF-8 | 264 | 3.546875 | 4 | [] | no_license | print "Вы довольны своей зарлатой? (1 - Да / 0 - Нет)"
answer = gets.to_i
if answer == 1
puts "Очень Хорошо"
end
if answer == 0
puts "Очень Плохо"
end
print "Тут идут сложные вычесления" | true |
af3254dc775c06bf83478d214680431c7f695cdd | Ruby | brandonlafave/compound_interest_calculator | /lib/compound_interest_calculator.rb | UTF-8 | 178 | 2.890625 | 3 | [] | no_license | class CompoundInterestCalculator
def amount_earned(principle, interest, compound, time)
@result = (principle*(1 + (interest/100)/compound)**(compound*time)).round(2)
end
end | true |
88e51cf1a7cb42122b1592f9913a68151182b709 | Ruby | thebitcorps/sacc2.0 | /app/helpers/appointments_helper.rb | UTF-8 | 2,876 | 3.078125 | 3 | [] | no_license | module AppointmentsHelper
def time_distance_to_now(appointment)
distance = (appointment.date - Date.today).to_i
#Years
years = distance / 365.0
if years.to_i > 0
if years.to_i <= 1
return t 'time.next_year'
else
return t 'time.from_now', time: years.to_i.to_s + ' ' + t('ti... | true |
b82438483cccff23a20955b6612d3aa5f15aba6f | Ruby | Psiale/100-years-of-quotes | /spec/helperable_spec.rb | UTF-8 | 1,652 | 2.890625 | 3 | [] | no_license | require_relative '../lib/modules/helperable.rb'
require 'nokogiri'
require 'open-uri'
describe Helperable do
let(:dummy_class) { Class.new { extend Helperable } }
let(:url) { 'https://www.microverse.org' }
let(:nokogiri) { Nokogiri::HTML(URI.parse(url).open) }
let(:hash_for_testing) { { '1' => 'Hello' } }
d... | true |
e32d0b53200f6fea63c562ebe145e6fe5fa220a7 | Ruby | ongaeshi/grn_mini | /test/test_micro_blog.rb | UTF-8 | 1,892 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'minitest_helper'
class TestMicroBlog < MiniTest::Test
def test_micro_blog
GrnMini::tmpdb do
engine = MicroBlog.new
# Add user
engine.add_user("aaa", "Mr. A", "Hello.")
engine.add_user("bbb", "Mr. B", "Good Afternoon.")
engine.add_user("ccc", "Mr. C", "Hi.")
# Follow... | true |
c93344742a1993d56eca9cf5efc96c8a508f6b32 | Ruby | cesartalves/star-wars-imdb | /app/policies/vote_policies.rb | UTF-8 | 190 | 2.53125 | 3 | [] | no_license | class VotePolicies
DOWNVOTE = "downvote".freeze
UPVOTE = "upvote".freeze
def self.valid_type?(vote_type)
return vote_type == DOWNVOTE || vote_type == UPVOTE
end
end | true |
342ecd4dd91fe0ea98db1096b80426e3015294ea | Ruby | puppetlabs/puppetdb | /puppet/spec/unit/util/puppetdb/char_encoding_spec.rb | UTF-8 | 2,170 | 2.640625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | #!/usr/bin/env rspec
# encoding: utf-8
require 'spec_helper'
require 'puppet/util/puppetdb/char_encoding'
describe Puppet::Util::Puppetdb::CharEncoding do
describe "#coerce_to_utf8" do
describe "on ruby >= 1.9" do
# UndefinedConversionError
it "should replace undefined characters and warn when conv... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.