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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8ae00ce5905feb2bd43ced0274dfd4e69a01128e | Ruby | youngmanr/battle-tom | /spec/player_spec.rb | UTF-8 | 1,047 | 3.234375 | 3 | [] | no_license | require 'player'
describe Player do
subject(:player_1) { described_class.new(player_1_name)}
let(:player_1_name) {"Yev"}
subject(:player_2) { described_class.new(player_2_name)}
let(:player_2_name) {"Andy"}
describe '#initialize' do
it {is_expected.to respond_to(:name)}
end
describe '#hp' do
it 'is... | true |
78aa4ec787a85615affd5817519d8b039bd1d9a8 | Ruby | AlexanderRD/rby-money | /lib/rby/converter.rb | UTF-8 | 936 | 3.125 | 3 | [
"MIT"
] | permissive | module Rby
class Converter
attr_accessor :currency_hash
def initialize(base_currency=nil, currency_hash={})
configure_rates(base_currency, currency_hash)
end
def configure_rates(base_currency, currency_hash={})
@currency_hash = currency_hash.merge({ base_currency => 1 })
end
def... | true |
83b77d6c937f566ccd871915a20eb7c9dc47fd6a | Ruby | harrifeng/leet-in-ruby | /086_partition_list.rb | UTF-8 | 759 | 3.140625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'ds/list_node'
# MiniTest class
class MyTest < Minitest::Test
def test_leet_086
a1 = ListNode.get_ln_from_array([1, 4, 3, 2, 5, 2])
e1 = ListNode.get_ln_from_array([1, 2, 2, 4, 3, 5])
assert ListNode.two_ln_equal(e1, partition(a1, 3))
end
end
# @param {ListN... | true |
37295fd77f70f8a5ca59b76684055a6a64a3466f | Ruby | bsingr/opal | /spec/language/string_spec.rb | UTF-8 | 667 | 3.46875 | 3 | [
"MIT"
] | permissive |
describe "Ruby character strings" do
it "don't get interpolated when put in single quotes" do
@ip = 'xxx'
'#{@ip}'.should == '#{@ip}'
end
it 'get interpolated with #{} when put in double quotes' do
@ip = 'xxx'
"#{@ip}".should == "xxx"
end
it "interpolate instance variables just with the... | true |
f2ad62cc77e428d683d19d8531a91d0c08472480 | Ruby | theoluyi/ruby-oo-fundamentals-instance-variables-lab-dumbo-web-010620 | /lib/dog.rb | UTF-8 | 311 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Dog
def name=(dog_name)
@this_dogs_name = dog_name
end
def name
@this_dogs_name
end
def bark
puts "Woof!"
end
end
lassie = Dog.new
lassie.name = "Lassie"
lassie.name #=> "Lassie"
fido = Dog.new
fido.name = "Fidospectacular"
| true |
eb9c47fff41a05951494f69078b1344df5cd5a8f | Ruby | juuh42dias/kind | /test/kind/maybe_test.rb | UTF-8 | 14,691 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class Kind::MaybeTest < Minitest::Test
def test_maybe_constructor
optional = Kind::Maybe.new(0)
assert_equal(0, Kind::Maybe.new(optional).value)
end
def test_maybe_result
object = Object.new
maybe_result = Kind::Maybe::Result.new(object)
assert_same(object, maybe_res... | true |
e966cfd87ede9eee7522783e39261d9097735cc8 | Ruby | ocruse7/apples-and-holidays-onl01-seng-pt-110319 | /lib/holiday.rb | UTF-8 | 1,710 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def second_supply_for_fourth_of_july( holiday_hash )
# given that holiday_hash looks like this:
# {
# :winter => {
# :christmas => ["Lights", "Wreath"],
# :new_years => ["Party Hats"]
# },
# :summer => {
# :fourth_of_july => ["Fireworks", "BBQ"]
# },
... | true |
c00f4bb18047be53539a038e2e83f72107dac433 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/db10dd4181c94c79a92936797397de12.rb | UTF-8 | 244 | 3.34375 | 3 | [] | no_license | class Phrase
def initialize(sentence)
@words = sentence.split(/\W+/).map {|word| word.downcase }
end
def word_count
@words.each_with_object(Hash.new(0)) do |word, counts|
counts[word] = counts[word] + 1
end
end
end
| true |
7b0b30a74809b1d80e1658a974b4bfcbd2800d97 | Ruby | FranklinHarry/aws-logs | /lib/aws_logs/tail.rb | UTF-8 | 4,963 | 2.546875 | 3 | [
"MIT"
] | permissive | require "json"
module AwsLogs
class Tail
include AwsServices
def initialize(options={})
@options = options
@log_group_name = options[:log_group_name]
# Setting to ensure matches default CLI option
@follow = @options[:follow].nil? ? true : @options[:follow]
@loop_count = 0
... | true |
94cd99053e3f17004afec170695b8c3697a4fe08 | Ruby | esegredo/LPP_Pract_7 | /test/fraction_spec.rb | UTF-8 | 5,199 | 3.796875 | 4 | [] | no_license | require 'fraction'
describe Fraction do
it "Debe existir un numerador" do
Fraction.new(1, 5).num.should == 1
end
it "Debe existir un denominador" do
Fraction.new(1, 5).denom.should == 5
end
it "Debe de estar en su forma reducida" do
Fraction.new(20, 30).should == Fraction.new(2, 3)
Fraction.new(-30, 4... | true |
641093000aca20b93cbea73fb1be34ab3da90102 | Ruby | MillsProvosty/dog_walker | /test/walker_test.rb | UTF-8 | 2,373 | 3.15625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/dog'
require './lib/walker'
require 'pry'
class WalkerTest < Minitest::Test
def test_walker_exists
@Jerimiah = Walker.new("Jerimiah", 10)
assert_instance_of Walker, @Jerimiah
end
def setup
@Jerimiah = Walker.new("Jerimiah", 10)
@... | true |
ef30e99a603df9a1d8e9f230832a262d39ca9a54 | Ruby | jbedley/SiblingRivalry | /gin_rummy/Deck.rb | UTF-8 | 719 | 4.15625 | 4 | [] | no_license | require "./Card.rb"
class Deck
def initialize()
@cards = Array.new(52)
card_index = 0;
for suit in 0..3
for value in 1..13
@cards[card_index] = Card.new(suit, value)
card_index = card_index + 1
end
end
end
# Makes a string of the whole deck
def to_s
ret = "["
... | true |
73a7e0623d55ebd67fb14b11926d733c758c1181 | Ruby | rajkiransingh/Challenge | /features/support/helpers/pages_helper.rb | UTF-8 | 279 | 2.546875 | 3 | [] | no_license | # Page Object helpers
module PagesHelper
def elem_name(name)
name.to_s.downcase.tr(' ', '_')
end
def elem_with_name(name)
send("#{elem_name(name)}_element")
rescue NoMethodError
raise NameError, "Undefined '#{name}' element for #{self.class} page"
end
end
| true |
bfa872fadbc1feeb107937ebf44f904fdb0f8891 | Ruby | fentontaylor/sweater-weather | /app/models/forecast_summary.rb | UTF-8 | 180 | 2.71875 | 3 | [] | no_license | class ForecastSummary
def initialize(obj)
@today = obj.summary_today
@tonight = obj.summary_tonight
@temp_high = obj.temp_high
@temp_low = obj.temp_low
end
end
| true |
b8da9d2b9538f558accfa1fcddc1c11db5aa827c | Ruby | masa7303/mountain_hut | /db/seeds/development/entries.rb | UTF-8 | 634 | 2.609375 | 3 | [] | no_license | body =
"今日の天気は晴れでした。\n\n" +
"登山客もいっぱい!。" +
"周辺には高山植物も顔を出すようになりました。" +
"周辺には高山植物も顔を出すようになりました。" +
"周辺には高山植物も顔を出すようになりました。" +
"周辺には高山植物も顔を出すようになりました。" +
"今週末はぜひ立山ロッジへお越しください!"
%w(Taro Jiro Hana).each do |name|
0.upto(9) do |idx|
Entry.create(
title: "今日の景色#{idx}",
body: body,
posted... | true |
99b2de53cb0d7d7e161bb86009188011615a72a7 | Ruby | Serenity911/week2-ruby-hw-fish-bear-river | /river.rb | UTF-8 | 307 | 3.53125 | 4 | [] | no_license | class River
attr_reader :name
def initialize(name)
@name = name
@fish = Array.new()
end
def populate_with_fish(fish_names)
for name in fish_names
@fish << Fish.new(name)
end
end
def lose_a_fish()
@fish.shift()
end
def fish_counter
@fish.length
end
end
| true |
6ec84aea89ca69456b39bcb5ccc1c81fc4af2775 | Ruby | AAMani5/learn-to-program | /chap08/ex0.rb | UTF-8 | 218 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env ruby
puts "please type as many words as you want but only one word per line"
input = gets.chomp
array = []
while (input.downcase !='')
array.push input.downcase
input = gets.chomp
end
puts array.sort
| true |
41266d797f4867f41e918325c6dbe47185e88c6a | Ruby | jwhitis/dintg | /app/domain/progress_calculator.rb | UTF-8 | 1,770 | 3.203125 | 3 | [] | no_license | class ProgressCalculator
attr_reader :dictionary
def initialize(user, time_period, target)
@user = user
@dictionary = TimeRangeDictionary.new(time_period, target)
end
def on_pace_for_period?
progress_score >= 1
end
def progress_score
unless @dictionary.period_in_progress?
raise OutO... | true |
7f692b74cf6417ea159094c3c27c78e5c8c7fa95 | Ruby | dtroydev/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 2,984 | 3 | 3 | [] | no_license | require 'open-uri'
COCKTAIL_DB_API = 'http://www.thecocktaildb.com/api/json/v1/1/'.freeze
INGREDIENTS = 'list.php?i=list'.freeze
COCKTAILS = 'filter.php?c=Cocktail'.freeze
COCKTAIL = 'lookup.php?i='.freeze
cocktails__cache = {}
define_method :cocktails_cache do
cocktails__cache
end
def cdb_ingredients
ingredie... | true |
b34e5a13ca8551a3c3004e959299c4d338689a6f | Ruby | belinskidima/Rubyschool | /app.rb | UTF-8 | 1,795 | 2.53125 | 3 | [
"MIT"
] | permissive | #encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'sqlite3'
db = SQLite3::Database.new 'barbershop.db'
configure do
db.execute 'CREATE TABLE IF NOT EXISTS "
Users"
(
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"username" TEXT,
"phone" TEXT,
"dat... | true |
5daeb9e49fb20d0b3d37e8da59f16ddfc202374b | Ruby | saqib-nadeem/sugar_utils | /lib/sugar_utils.rb | UTF-8 | 674 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | # -*- encoding : utf-8 -*-
require 'sugar_utils/version'
require 'sugar_utils/file'
module SugarUtils
# @param [Object] value
#
# @return [Boolean]
def self.ensure_boolean(value)
return false if value.respond_to?(:to_s) && value.to_s.casecmp('false').zero?
value ? true : false
end
# @param [Strin... | true |
a52211d7e6b4b4f210c05dd8214ef0523cad90d5 | Ruby | metade/music_service_example | /music-cucumber/features/support/music_client.rb | UTF-8 | 3,923 | 2.515625 | 3 | [] | no_license | require 'ostruct'
require 'rest-client'
module Music
def self.destroy_all_users
users = Music::User.all.inject({}){ |h,u| h[u.username] ||= u; h }.values
users.each do |user|
user.collections.each do |collection|
collection.clips.each do |clip|
RestClient.delete "#{Music::HOST}/collec... | true |
478525f3ea2293231429b91cb06063cd01147784 | Ruby | fkhalili/wdi | /w08/d03/Homework/bttf/back_to_the_future.rb | UTF-8 | 1,826 | 3.125 | 3 | [] | no_license | require "./vehicle.rb"
require "./train.rb"
require "./skateboard.rb"
require "./bicycle.rb"
require "./car.rb"
require "pry"
#Vehicle
v1 = Vehicle.new("horse and buggy", 4, "Burton, OH")
v1.description
#=> "horse and buggy"
v1.passengers
#=> []
v1.go_to('the barn dance!')
#=> "This horse and buggy is empty!"
v1.loc... | true |
cb6006345ed9b71ea39e56bee1f726a8ad24a4a7 | Ruby | ybakos/processing-sublime-util | /syntax_comparator.rb | UTF-8 | 1,449 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'open-uri'
require 'nokogiri'
class SyntaxComparator
XML_NODE_NAME = "string" # Typically "string", which wraps the regex you're after.
# There's got to be a better way to do this...
EXTRACTION_REGEX = /\\b\((.*)\)\\b/
SPLIT_CHARACTER = '|'
API_REFERENCE_DOM_SELECTOR = "a.re... | true |
a504c89619c77e22e8f46f3b8b54fd5c0eea201f | Ruby | ValeriyaKunichik/MY_SQLITE | /my_sqlite_request.rb | UTF-8 | 4,303 | 2.984375 | 3 | [] | no_license | require 'csv'
require "./methods.rb"
class MySqliteRequest
def initialize
@data_table = nil
@file_name =nil
@table_2 =nil
@all_columns = []
@select_cols = []
@where_filter = []
@where_count = 0
@join_tables = []
@sort_data = []
@insert_new_row = false... | true |
9d91becab62d71834370cd8c03a62c3d68198c54 | Ruby | webdev1001/twss | /script/collect_twss.rb | UTF-8 | 515 | 2.765625 | 3 | [] | no_license | require 'rubygems'
require 'open-uri'
require 'hpricot'
# Grab the first 2000 stories from twssstories.com (10 per page)
f = File.open(File.expand_path("../../data/twss.txt", __FILE__), "w")
domain = "http://twssstories.com"
200.times do |i|
url = domain + "/node?page=#{i}"
puts url
doc = Hpricot(open(url).rea... | true |
5827145b6020b2196ad76a58c2734f185141d2a2 | Ruby | pineman/code | /ruby/irb.rb | UTF-8 | 802 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
begin
gem 'listen'
rescue Gem::LoadError
Gem.install('listen')
gem 'listen'
end
require 'listen'
require 'irb'
def reload(file)
old = $VERBOSE
$VERBOSE = nil
load file
$VERBOSE = old
end
def watch_and_reload(dir_path)
listener = Listen.to(File.dirname(dir_path),... | true |
d0c7090c4cff00e38645d3ff7019069680011731 | Ruby | ruby/tk | /sample/demos-jp/browse2 | UTF-8 | 2,244 | 3.171875 | 3 | [
"BSD-2-Clause",
"Ruby"
] | permissive | #!/usr/bin/env ruby
# browse --
# This script generates a directory browser, which lists the working
# directory and allow you to open files or subdirectories by
# double-clicking.
require 'tk'
class Browse
BROWSE_WIN_COUNTER = TkVariable.new(0)
def initialize(dir)
BROWSE_WIN_COUNTER.value = BROWSE_WIN_COUN... | true |
091c00da1f0892c08cf734c0f7df6e3cc51e41da | Ruby | vladL2C/stockPicker | /stockPicker.rb | UTF-8 | 479 | 3.65625 | 4 | [] | no_license |
def stockPicker(array)
best_buy = 0
best_sell = 0
best_profit = 0
array.each do |buy|
array.each do |sell|
profit = sell - buy
if profit > best_profit
best_profit = profit
best_buy = array.index(buy)
best_sell = array.index(sell)
end
end
end
p... | true |
6a3f54c00ca7aaa5329e5db8e0b48180897d38d8 | Ruby | LucyMHall/Bookmark-Manager-2 | /spec/bookmark_spec.rb | UTF-8 | 834 | 2.65625 | 3 | [] | no_license | require 'bookmark'
require 'spec_database_helper.rb'
describe Bookmark do
describe '::create' do
it 'takes a url and a title as arguments and add them to the database' do
Bookmark.create('www.fakeurl.com','FakeUrl')
expect(Bookmark.create('www.fakeurl.com','FakeUrl')).to be_an_instance_of(PG::Result... | true |
ecef019b2f50b7d30cd9a1aac9990eda67d94532 | Ruby | eac/redio | /lib/redio/cluster.rb | UTF-8 | 1,702 | 2.703125 | 3 | [] | no_license | module Redio
class Cluster
attr_accessor :nodes, :distributed_methods
def initialize(nodes)
@nodes = nodes
end
def method_missing(method_id, *args, &block)
options = distributed_methods[method_id]
command = DistributedCommand.new(nodes, options)
command.execute(method_id, ar... | true |
7299df92dfe8cba0651102f4bdf7f2c774c36207 | Ruby | londonbridges13/adevacademy | /app/helpers/topics_helper.rb | UTF-8 | 11,362 | 3.03125 | 3 | [] | no_license | module TopicsHelper
#Display articles
def get_articles_from(topics)
@size = topics.count * 3
@amount = 0
@articles = []
i = 0
# while @articles.count < @size
topics.each do |t|
i += 1
# unless i == topics.count #@articles.count < @size
add_articles(t) #add_an_article(t)
... | true |
ae46cf41802ad742b7937319108b29e78556a39c | Ruby | slstevens/boris_bikes | /lib/garage.rb | UTF-8 | 259 | 2.703125 | 3 | [] | no_license | require_relative 'bike_container'
class Garage
include BikeContainer
def initialize(options = {})
self.capacity = options.fetch(:capacity, capacity)
end
def fix_broken_bike(broken_bike)
broken_bikes.each do |bike|
bike.fix!
end
end
end
| true |
d2841f96e08e110c70f65434c5ae811e65e5872b | Ruby | zhangem/to_do_list_2_ruby | /to_do.rb | UTF-8 | 1,141 | 3.828125 | 4 | [] | no_license | require './lib/to_do_list'
@list = []
@done =[]
def main_menu
puts "Press 'A' to add a task"
puts "Press 'L' to list all of your tasks"
puts "Press 'D' to delete task"
puts "Press 'X' to exit"
puts "Press 'F' to show finished taskes"
main_choice = gets.chomp
if main_choice == 'a'
add_task
elsif m... | true |
6441985f7c2982136d0485ad19456efb11d88322 | Ruby | jrabeck/weekend_two | /demo.rb | UTF-8 | 1,205 | 3.734375 | 4 | [] | no_license | class Superhero
attr_accessor :name, :attack, :hitpoints, :alive, :has_secret_weapon
def initialize(superhero)
@name = superhero[:name]
@hitpoints = superhero[:hitpoints]
@attack = superhero[:attack]
@alive = true
@has_secret_weapon = false
end
def hits(opponent)
opponent.hitpoints = o... | true |
b67fa3934066f381747483da23bb67d2824a01d2 | Ruby | tungnguyenvan/Ruby-Basic | /Baitap/phan5/cau1/tinh_toan.rb | UTF-8 | 329 | 3.328125 | 3 | [] | no_license | a = 0
b = 0
f = File.open("in.txt", "r")
f.each_line do |line|
so = line.split(" ")
a = so[0]
b = so[1]
end
a = a.to_i
b = b.to_i
tong = a+b
hieu = a-b
tich = a*b
thuong = a/b
puts "tong cua 2 so a,b : #{tong}"
puts "hieu cua 2 so a,b : #{hieu}"
puts "tich cua 2 so a,b : #{tich}"
puts "thuong cua 2 so a,b: #{... | true |
d387b2f4adfbdce54a0f776394fe16dc55b9ef2f | Ruby | mgsx-dev/processing-glsl | /ProcessingSample/tomd.rb | UTF-8 | 5,205 | 2.578125 | 3 | [] | no_license | require 'date'
require 'fileutils'
module GLSLParser
class Context
attr_accessor :site, :dir, :group, :text, :code, :file
end
def self.empty?(line)
line.strip.empty?
end
def self.comment_begin?(line)
line.strip.start_with?("/**")
end
def self.comment_end?(line)
line.strip.end_with?("*/")
end
de... | true |
3412af84a909763976e6c27e7ce777f2c11f891c | Ruby | listiani13/coursera | /SaaS/week2/public/lib/rock_paper_scissors.rb | UTF-8 | 1,178 | 3.4375 | 3 | [] | no_license | class RockPaperScissors
# Exceptions this class can raise:
class NoSuchStrategyError < StandardError ; end
def self.winner(player1, player2)
# YOUR CODE HERE
w = ["RS", "PR", "SP"];
valid = ["R", "P", "S"];
if w.index(player1[1].upcase + player2[1].upcase)
return player1
elsif !valid.in... | true |
cd2f26e7b0954257381d25f3fab987840e122621 | Ruby | mapi8808/practice-ruby | /add.rb | UTF-8 | 386 | 3.90625 | 4 | [] | no_license | amounts = {"リンゴ"=>2, "イチゴ"=>5, "オレンジ"=>3}
amounts.each do |fruit, amount| #ハッシュの内容を順にキーをfruit、値をamountに代入して繰り返す
puts "#{fruit}は#{amount}個です。"
end
i = 1
while i <= 10 do
if i == 5
puts "処理を終了します"
break # iが5になると繰り返しから抜ける
end
puts i
i += 1
end | true |
840d704cd01bbd13e2e41ebee15c4eb6b7f4e90a | Ruby | nelyj/dagger | /lib/dagger.rb | UTF-8 | 6,209 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'dagger/version'
require 'dagger/response'
require 'dagger/parsers'
require 'net/https'
require 'base64'
module Dagger
REDIRECT_CODES = [301, 302, 303].freeze
DEFAULT_RETRY_WAIT = 5.freeze # seconds
DEFAULT_HEADERS = {
'Accept' => '*/*',
'User-Agent' => "Dagger/#{VERSION} (Ruby Net::HTTP W... | true |
db8ccfeb69f42f777707e6db43efd3875d88e8bc | Ruby | TSSaint/ruby-misc | /ruby_conditionals.rb | UTF-8 | 558 | 3.9375 | 4 | [] | no_license | # conditionals, allows code to react to some data
# not the same as methods though
# we can use statements like else and else if to add other conditions
# chains start with plain ifs; new conditional statements result new outputs
num = 3
# if num > 0
# puts "num is bigger than 0"
# elsif num < 0
# puts "num is ... | true |
8da8484ceb787ff4d7494b01b9eab5dd8afea54d | Ruby | avitus/Assetcorrelation | /app/models/security.rb | UTF-8 | 5,774 | 3.03125 | 3 | [] | no_license | class Security < ActiveRecord::Base
has_many :price_quotes, :dependent => :destroy
has_many :positions, :dependent => :destroy
validates :ticker, :uniqueness => true
# ----------------------------------------------------------------------------------------------------------
# Get historical prices and save ... | true |
2e44a2fe1b666c6d4043b2824677333a94bc2320 | Ruby | zizhang/the_odin_project | /ruby_building_blocks/substrings.rb | UTF-8 | 482 | 3.6875 | 4 | [] | no_license | def substrings(input_text, dictionary)
substrings_found = Hash.new(0)
words = input_text.downcase.split(" ")
words.each do |word|
dictionary.each do |dictionary_word|
if word.include?(dictionary_word)
substrings_found[dictionary_word] += 1
end
end
end
return substrings_found
end
puts "Enter text... | true |
1d125a494e7b5d59a0ddc1b4eab9306835f46b80 | Ruby | wzcolon/listings_scraper | /app/services/create_scrape.rb | UTF-8 | 1,143 | 2.84375 | 3 | [] | no_license | class CreateScrape
CouldNotScrapeError = Class.new(StandardError)
attr_reader :scrape_type, :scrape
def initialize(scrape_type:)
@scrape_type = scrape_type
@listings = 0
end
def call
scrape!
end
private
def scrape!
begin
while @listings < 1000
results.each do |result|
... | true |
0578f9bcb31456002b6568ac734b2c58a3fa8464 | Ruby | jstoebel/code-workout | /app/representers/exercise_representer.rb | UTF-8 | 2,274 | 2.515625 | 3 | [] | no_license | require 'representable/hash'
class ExerciseRepresenter < Representable::Decorator
include Representable::Hash
collection_representer class: Exercise, instance: lambda { |fragment, i, args|
if fragment.has_key? 'external_id'
e = Exercise.where(external_id: fragment['external_id']).first
e || Exercis... | true |
84350cb87898eb87e48e7e85043bd78ef635f0f8 | Ruby | piercus/XMPePer | /vendor/plugins/canhaschat/generators/chat_system/templates/mongrel_handler.rb | UTF-8 | 1,827 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'json'
require 'drb'
require 'erb'
require 'yaml'
# basic form of this file
# taken from:
# http://adam.blogs.bitscribe.net/
class PushHandler < Mongrel::HttpHandler
def initialize
config_file = File.read("config/chat_server.yml")
evaluated = YAML.load(ERB.new(config_file).res... | true |
f51abe38d0b2a018eab7e2907cf6926f988e3f21 | Ruby | MariaVla/memcached | /spec/item_spec.rb | UTF-8 | 3,568 | 2.5625 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../Memcached.rb'
require_relative '../MemcachedValue.rb'
memcached = Memcached.new("memcached")
value_one = MemcachedValue.new()
value_one.key = 'foo'
value_one.time = 4444
value_one.bytes = 4
value_one.data = 'hola'
value_two = MemcachedValue.new()
value_two.key = 'b... | true |
68382452243d29dae2586ac0e88768ac05f523d1 | Ruby | canikwe/oo-counting-sentences-dc-web-career-010719 | /lib/count_sentences.rb | UTF-8 | 380 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
# binding.pry
del = [".", "?", "!"]
count = self.split(Regexp.union(del)) #looked up documentaion on splitting by speci... | true |
47c19f0b24c65f2af6cf3f207f638f86bb432e24 | Ruby | mojaz-io/mojaz-backend | /app/services/website_logo_service.rb | UTF-8 | 2,557 | 2.765625 | 3 | [] | no_license | class WebsiteLogoService
attr_reader :home_url
def initialize(home_url = nil)
@home_url = home_url
end
def call
find_media_link
end
private
def find_media_link
return unless @home_url
response = HTTP.follow(max_hops: 3).timeout(3).get(@home_url)
html = Nokogiri::HTML(response.to_s... | true |
13bab92d48bab790ecb59e842a594db7a61bb59e | Ruby | mtwentyman/dotfiles | /git_template/hooks/commit-msg | UTF-8 | 1,108 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
msg_file = ARGV[0]
commit_msg = File.read(msg_file).to_s.strip
def empty_commit?(commit_msg)
return true if commit_msg.empty?
commit_msg.split("\n").each do |line|
# Lines starting with '#' will be ignored
return false if commit_msg.strip[0] != '#'
end
true
end
# if the commit... | true |
263cd7d7cae04f371132c13b02b1dc54183b6f10 | Ruby | vimalvnair/web_hunt | /rasp_push_act_broadband_usage.rb | UTF-8 | 5,079 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "nokogiri"
require 'net/http'
require 'yaml'
require 'logger'
require 'time'
require_relative './way2sms'
AUTH_FILE = "#{Dir.home}/.act_broadband.yml"
PUSH_BULLET_TOKEN = "#{Dir.home}/.push_bullet_token.yml"
AUTH_EXPIRY = (2*60*60) # 5.hours
LOG = Logger.new('act_broadband_usage.log', 10, ... | true |
3da207613deb2ac48fe8e9492a674b798dca2ef7 | Ruby | lucascppessoa/ruby-dev-test-1 | /spec/models/directory_spec.rb | UTF-8 | 4,565 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Directory, type: :model do
context "with a clean slate" do
it "accepts an initial orphaned record" do
node = FactoryBot.build_stubbed(:directory)
expect(node).to be_valid
end
it "refuses nameless records" do
node = FactoryBot.build_stubbed(:director... | true |
a9aa532f17170c576d8097213ed4ef94936382ba | Ruby | pjpalla/collabora | /lib/tasks/tester.rb | UTF-8 | 7,212 | 2.59375 | 3 | [] | no_license | require '../../config/environment'
require_relative 'processor'
@uids = User.where(:place => "medio campidano")
indicator = "i8_1"
i = Indicator.where(:uid => @uids).where("#{indicator} <> 0 and #{indicator} is not NULL").count
puts i
# lower_limit = 1
# upper_limit = 6
# sub_range = (lower_limit..upper_limit)
# sub... | true |
9bdd1d155c8dff4c2108132da48b3d3320623b04 | Ruby | nimam1992/programming-univbasics-4-square-array-nyc-web-030920 | /lib/square_array.rb | UTF-8 | 140 | 3.15625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
i = 0
list = []
while i < array.length do
list.push(array[i]*array[i])
i += 1
end
return list
end
| true |
8a1bd2a1ed8875a75418c26265afcb94c0af7ce6 | Ruby | andrewbaldwin44/Rails_React_Library | /app/helpers/books_helper.rb | UTF-8 | 1,159 | 2.515625 | 3 | [
"MIT"
] | permissive | module BooksHelper
BOOK_FIELDS_SELECTION = [
'title',
'authors',
'published_date',
'description',
'imageLinks',
'categories'
]
private
def safe_format_list(list)
if list then list.join(", ") else "" end
end
public
def adapt_books_response(search_response)
if search_resp... | true |
cee8cfc15f0882be0b9d0ed10f3638080ae0c1df | Ruby | michaelklishin/kiev_ruby_barcamp_2009 | /examples/04_module_included_multiple_times.rb | UTF-8 | 981 | 2.859375 | 3 | [
"LicenseRef-scancode-public-domain-disclaimer"
] | permissive | #!/usr/bin/env ruby -Ku
#
# Example #4:
#
# Beware of Module.included being called multiple times when classes in large
# application load via ActiveSupport's or Merb's classloaders.
#
# Imagine you have a.rb with reference to B, and b.rb with reference to A.
# No matter what order you are going to load them, first ti... | true |
234bbf8511e08b1193a2ffca992ae0e915eabf12 | Ruby | wookay/da | /ruby/ruby19/test_each.rb | UTF-8 | 350 | 3.4375 | 3 | [] | no_license | # test_each.rb
# wookay.noh at gmail.com
def assert_equal expected, got
puts expected == got ?
"passed: #{expected}" :
"Assertion failed\nExpected: #{expected}\nGot: #{got}"
end
class A
include Enumerable
def each
yield 1
yield 2
end
end
for a in A.new
assert_equa... | true |
db49fbf569967fc02d9e7642d7d89e34f0c9ffcd | Ruby | JeffBenton/cartoon-collections-online-web-sp-000 | /cartoon_collections.rb | UTF-8 | 404 | 3.234375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(arr)
arr.each_with_index {|dwarf, i| puts "#{i+1}. #{dwarf}"}
end
def summon_captain_planet(arr)
arr.collect {|x| "#{x.capitalize}!"}
end
def long_planeteer_calls(arr)
arr.find {|x| x.length > 4} != nil
end
def find_the_cheese(arr)
cheese_types = ["cheddar", "gouda", "camembert"]
chee... | true |
1485144fb44d84f286b4718f8b3ade518ef4f655 | Ruby | PatrickA226/get-help-with-tech | /app/services/responsible_body_exporter.rb | UTF-8 | 1,244 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'csv'
require 'string_utils'
class ResponsibleBodyExporter
include StringUtils
attr_reader :filename
def initialize(filename = nil)
@filename = filename
end
def export_responsible_bodies(query = responsible_bodies)
if filename
CSV.open(filename, 'w') do |csv|
render(csv, quer... | true |
616ced0f36c31a043e996659fff82f460cf8093d | Ruby | ddrscott/stocking | /lib/stocking/yahoo.rb | UTF-8 | 980 | 2.71875 | 3 | [
"MIT"
] | permissive | module Stocking
# Fetch data from Yahoo
module Yahoo
module_function
def default_url
'https://finance.yahoo.com/quote/%s/financials'
end
def build_url(ticker)
default_url % [ticker.upcase]
end
def ticker_cache
@ticker_cache ||= {}
end
def fetch(ticker, url: buil... | true |
2a6c5e5c310552284a55ac25b01e93ba586b85e7 | Ruby | Eritiel/Ruby | /L1/3.rb | UTF-8 | 1,101 | 3.578125 | 4 | [] | no_license | puts "Введите свой любимый язык программирования"
name=gets.chomp()
if name=="Ruby"
puts "Иу, подлиза"
elsif name=="Python"
puts "А ты мне нравишься"
elsif name=="R"
puts "Согласна!"
elsif name=="C++"
puts "Плюсики в карму"
elsif name=="C#"
puts "Минус в карму, даже руби лучше"
elsif name=="Petooh"
puts "... | true |
7d31db68ae33e8d43d713f183ef58780c7ecb217 | Ruby | mikekelly/blue_bank | /lib/blue_bank/account.rb | UTF-8 | 1,022 | 2.546875 | 3 | [
"MIT"
] | permissive | module BlueBank
class Account
def initialize(id:, client:, json: nil)
@id, @client, @json = id, client, json
end
def current?
account_type == "Standard Current Account"
end
def savings?
account_type == "Standard Current Account"
end
def account_type
json.fetch("a... | true |
0cfdf473a8e13d7fa8ee3edb39d54898c53f62b7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/e4abe8c64feb4aa68d3f624681469fe4.rb | UTF-8 | 443 | 3.703125 | 4 | [] | no_license | class Bob
def hey message
@message = message.strip
case
when silence?
return "Fine. Be that way!"
when yelling?
return "Woah, chill out!"
when question?
return "Sure."
else
return "Whatever."
end
end
def silence?
@message... | true |
42071d1eda399b9edf3726d9bc7e019692501ebe | Ruby | anwarhamdani/nlp_arabic | /lib/nlp_arabic.rb | UTF-8 | 8,741 | 3.671875 | 4 | [] | no_license | require "nlp_arabic/version"
require "nlp_arabic/characters"
module NlpArabic
def self.stem(word)
# This function stems a word following the steps of ISRI stemmer
# Step 1: remove diacritics
word = remove_diacritics(word)
# Step 2: normalize hamza, ouaou and yeh to bare alef
word = normalize_... | true |
6d6f115c9265871f8fc2affae03bad725e816280 | Ruby | dmeskis/connect_four | /lib/board.rb | UTF-8 | 1,426 | 3.65625 | 4 | [] | no_license | require './lib/win_conditions'
class Board
include WinConditions
attr_reader :game_over, :column_key, :player_piece, :computer_piece
attr_accessor :board
def initialize
@column_key = ["A", "B", "C", "D", "E", "F", "G"]
@board = [[".", ".", ".", ".", ".", ".", "."],
["... | true |
cbc1e6cf0eb17b69c8ff1d9167c338de09e71bd7 | Ruby | joeainsworth/programming_exercises | /Tealeaf Academy - Object Oriented Ruby Exercises Workbook/Easy/Quiz 3/exercise_5.rb | UTF-8 | 535 | 3.921875 | 4 | [] | no_license | # If I have the following class:
class Television
def self.manufacturer
# method logic
end
def model
# method logic
end
end
# What would happen if I called the methods like shown below?
tv = Television.new # instantiate a new Televesion object and assign to tv
tv.manufacturer # error... | true |
05287700da4367924c6f3adf8fc3104d510a50d6 | Ruby | esteedqueen/simple-http-server | /lib/path_response_parser.rb | UTF-8 | 830 | 2.953125 | 3 | [] | no_license | class PathResponseParser
def initialize(path)
@path = path
parse
end
def parse
if root_path?
handle_homepage_response
elsif File.exist?(file_path)
handle_file_response
else
handle_404_response
end
self
end
attr_reader :status_code, :content
private
def h... | true |
5766a89c2499c44fc1da1821dff29941544b43e4 | Ruby | waasifkhaan/prime-ruby-v-000 | /prime.rb | UTF-8 | 232 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Add code here!
def prime?(int)
if int < 2
return false
elsif int == 2
return true
elsif
(2..int-1).to_a.each do |num|
if int % num == 0
return false
end
end
return true
end
end
| true |
8b7711370234d534da9cb431e570491302c17492 | Ruby | Lucasdfg07/OneBitExchange | /app/services/bitcoin_service.rb | UTF-8 | 459 | 2.796875 | 3 | [] | no_license | require 'rest-client'
require 'json'
class BitcoinService
def initialize(target_currency, amount)
@target_currency = target_currency
@amount = amount.to_f
end
def perform
begin
base_url = "https://blockchain.info/tobtc?currency=#{@target_currency}&value=#{@amount}"
response = RestClient.... | true |
fe7555dff57acc33b7b64a028ce6d620b161920a | Ruby | LLHolmes/spellwork_cli | /lib/spellwork_cli/cli.rb | UTF-8 | 8,199 | 3.5 | 4 | [
"MIT"
] | permissive | class SpellworkCli::CLI
def initialize
@input = "menu!"
end
def start
welcome
build_encyclopedia
while @input != "exit!"
if @input == "menu!"
self.menu
elsif @input == "word"
self.choose_keyword
elsif @input == "type"
self.choose_spell_type
elsif @... | true |
0dbbb10dba735bb126c704466a565576b5f76fa0 | Ruby | gonzalotraverso/bcn_weather | /lib/bcn_weather/forecast.rb | UTF-8 | 468 | 3.3125 | 3 | [
"MIT"
] | permissive | class Forecast
attr_reader :city_name
def initialize(where:, min_temps:, max_temps:)
@city_name = where
@min_temps = min_temps
@max_temps = max_temps
end
def today
{
min: @min_temps[0][:forecast],
max: @max_temps[0][:forecast]
}
end
def week_min_avg
avg(@min_temps)
e... | true |
a61c0fb5b589bce3299e82c190d7d2bf12931338 | Ruby | JosemyAB/ruby-martian-robots | /test/helpers/command/move_fordward_command_test.rb | UTF-8 | 1,326 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | require 'test_helper'
require_all './app/models/landscape'
require_all './app/helpers/command'
require_relative '../../../app/models/vehicle/rover'
class MoveForwardCommandTest < ActiveSupport::TestCase
planet = Planet.new(5, 5)
test "move forward from north" do
position = Position.new(2, 3)
rover = Rov... | true |
bb738dad135c1cdf83629ed9debba3518f5b804a | Ruby | sebapobletec/E7CP2A1 | /Ejercicio2.rb | UTF-8 | 392 | 3.390625 | 3 | [] | no_license | nombres = ["Violeta", "Andino", "Clemente", "Javiera", "Paula", "Pia", "Ray"]
b = nombres.select { |e| e.length >5 }
print b
puts ''
min = nombres.map { |e| e.downcase }
print min
puts ''
withp = nombres.select { |e| e[0] == 'P' }
print withp
puts ''
length = nombres.map { |e| e.length }
print length
puts ''
wit... | true |
aebe9f28319a0c9ea59e31734c13f893e4512f6f | Ruby | sashite/gan.rb | /lib/sashite/gan/piece.rb | UTF-8 | 3,808 | 3.265625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Sashite
module GAN
# A piece abstraction.
class Piece
# The abbreviation of the piece.
#
# @!attribute [r] abbr
# @return [String] The abbreviation of the piece.
attr_reader :abbr
# The piece's style.
#
# @!attribute [r] ... | true |
2fd05842ddc8da0b0d0210377d79165e2fa62337 | Ruby | yovasx2/cars | /lib/cars/enemy_generator.rb | UTF-8 | 991 | 3.4375 | 3 | [
"MIT"
] | permissive | module Cars
class EnemyGenerator
attr_reader :score, :level
def initialize(window)
@window = window
@gap = 0
@enemies = []
@score = 0
@level = 1
end
def update
add_enemy if @gap % @window.height == 0
@gap += 2
update_enemies(level)
delet... | true |
1b26432a14522f59658ba179267a6975188006d0 | Ruby | samstarling/creative-works | /lib/navigation.rb | UTF-8 | 448 | 3.109375 | 3 | [] | no_license | class Navigation
attr_reader :items
def initialize items
@items = items.sort
end
end
class NavigationItem
attr_reader :title, :path, :order
def initialize title, path, order=0
@title = title
@path = path
@order = order
end
def active_for? request
request.path == @path
end
... | true |
445e8963f691845c6af53626fadb9e139d340f29 | Ruby | akito1986/ocs | /lib/ocs/api_error.rb | UTF-8 | 657 | 2.546875 | 3 | [
"MIT"
] | permissive | module Ocs
class ApiError < OcsError
attr_reader :api, :parameters, :error_response
def initialize(api, parameters, error_response)
@api = api
@parameters = parameters
@error_response = error_response
end
def error_code
error_response.content[:cserrorcode]
end
def er... | true |
b03e179ff92d10e1fbf27ad392f3f88cf8b63d3f | Ruby | sphilip/CSCI598-Elements_of_Computing_Systems | /project11/VMWriter.rb | UTF-8 | 1,834 | 3.203125 | 3 | [] | no_license | # write VM command to file using VM command syntax
class VMWriter
attr_accessor :op_table, :write
# create new file & open for writing
def initialize(name)
@op_table = {
"+" => "add",
"&" => "and",
"|" => "or",
"*" => "call Math.multiply 2",
"/" => "call Math.divide 2",
"-... | true |
f4a7ccb7989ce96b10bbca878227432e0069b65d | Ruby | halokin/lrthw | /ex6.rb | UTF-8 | 1,474 | 4.09375 | 4 | [] | no_license | # variable types_of_poeple avec valeur = a 10
types_of_people = 10
# variable x = au nombre de la varibale types_of_people, 10
# string inside a string : #{types_of_people} est dans le string enter guillemets
x = "There are #{types_of_people} types of people."
# variable binary correspond a la valeur binary
binary = "... | true |
fdb1d509fea9bb21dab982dc597916e446bdd94b | Ruby | cristianriano/reconciliaTIC | /app/helpers/sessions_helper.rb | UTF-8 | 469 | 2.734375 | 3 | [] | no_license | module SessionsHelper
#Loguea al usuario
def log_in(user)
session[:user_id] = user.id
end
#Almacena al usuario en la variable global "current_user"
def current_user
if(user_id = session[:user_id])
@current_user ||= User.find_by(id: user_id)
end
end
#Elimina la session de las cookies
def log_out
... | true |
c6c351d6e466702f36ad5fa41f8a07a9dc1df9a6 | Ruby | MASisserson/rb120 | /practice_problems/easy_1/2.rb | UTF-8 | 957 | 4.5 | 4 | [] | no_license | # What's the Output
require 'pry'
class Pet
attr_reader :name
def initialize(name)
@name = name.to_s
end
def to_s
@name.upcase!
"My name is #{@name}."
end
end
# name = 'Fluffy'
# fluffy = Pet.new(name)
# puts fluffy.name # Will output `Fluffy` ; If attr_reader is specified, calling puts on th... | true |
8941ebf7a1e5c45157ece25444d9f131e48eb79d | Ruby | zokioki/jun | /lib/jun/active_record/base.rb | UTF-8 | 1,070 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative "../connection_adapters/sqlite_adapter"
require_relative "./persistence"
module ActiveRecord
class Base
include ActiveRecord::Persistence
def initialize(attributes = {})
@attributes = attributes
@new_record = true
end
def method_missing(na... | true |
97ff4c0d4281ef5c13330d0cdc45d7717ff3e175 | Ruby | cubicool/qimpy | /lib/qimpy.rb | UTF-8 | 4,775 | 2.765625 | 3 | [] | no_license | # @todo: MAKE ALL OF THE RESPONSE-HANDLING ASYNCHRONOUS! This is so basic! Perhaps this means
# creating a Qimpy::Connection and Qimpy::ASyncConnection, or something.
require 'socket'
require 'io/wait'
require 'base64'
require 'json'
module Qimpy
class Error < StandardError; end
# @todo: Somehow make this in ins... | true |
f3a58d34da26f0893e8160556d95b5b5c78bdb5f | Ruby | ceclinux/rubyeveryDAMNday | /53.MaximumSubarray.rb | UTF-8 | 294 | 3.328125 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer}
def max_sub_array(nums)
min = 0
final = nums[0]
curr = 0
nums.each_with_index do |a, index|
curr += a
final = [curr - min, final].max if index != 0
min = [curr, min].min
end
final
end
| true |
a82593538b73bfd22da785c97c0c301386cc50d0 | Ruby | AaronJHarvey/ruby-objects-has-many-through-readme-onl01-seng-pt-032320 | /lib/waiter.rb | UTF-8 | 536 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #customer to meal, waiter to meal, so customer to waiter
class Waiter
attr_accessor :name, :yrs_experience
@@all = []
def initialize(name, yrs_experience)
@name = name
@yrs_experience = yrs_experience
@@all << self
end
def self.all
@@all
end
def new_meal(customer,total,tip=0)
Meal.new(self, customer, ... | true |
6b3bb33c2a07973ca024843e05e7dac24e8d153c | Ruby | thebravoman/software_engineering_2013 | /class23_homework/B-Georgi-Ivanov-09/Ruby/Plane.rb | UTF-8 | 3,095 | 4.15625 | 4 | [] | no_license | require_relative "Group"
class Plane
def initialize rows, seats_per_row, after_which_seat_is_the_walkway
@seats = Array.new(rows+1) { Array.new(seats_per_row+1, 0) } # Creating array and filling it with 0. 0 means a seat is empty
@num_of_rows = rows
@num_of_seats_per_row = seats_per_row
@after_which_seat_is_t... | true |
cd0e5e9f10876fe3ae521d6a14c080e855ca31f5 | Ruby | mmabraham/Chess | /lib/pieces/slidable.rb | UTF-8 | 493 | 2.71875 | 3 | [] | no_license | module Slidable
def moves
moves = []
move_dirs.each do |diff|
new_pos = pos
while true
new_pos = next_after(new_pos, diff)
break unless new_pos.all? { |idx| idx < 8 && idx > -1 }
if board[new_pos].symbol
moves << new_pos unless board[new_pos].color == color
... | true |
fe21b1add92dd5f22794f290b3ac661fa4214d65 | Ruby | zerothabhishek/talk-rspec-and-testing | /samples-proper/lib/1.rb | UTF-8 | 61 | 2.6875 | 3 | [] | no_license | class MyCalculator
def self.add(x,y)
x + y
end
end
| true |
7f23de6da344cdac34eba8562de0e60b30faf5e2 | Ruby | budmc29/ruby_sandbox | /exercism/raindrops/raindrops.rb | UTF-8 | 539 | 3.734375 | 4 | [] | no_license | # Convert a number to a string, the contents of which depend on the number's factors.
class Raindrops
FACTORS = [3, 5, 7]
SOUNDS = {
3 => 'Pling',
5 => 'Plang',
7 => 'Plong'
}
def self.convert(number)
string = ''
FACTORS.each do |factor|
string << SOUNDS[factor] if has_factor?(number... | true |
c062b70fe7740b249ee68f0aeb95c67479466051 | Ruby | pp3n/ruby | /calculator.rb | UTF-8 | 930 | 4.28125 | 4 | [] | no_license | def multiply(first_number, second_number)
first_number.to_f * second_number.to_f
end
def add(first_number, second_number)
first_number.to_f + second_number.to_f
end
def divide(first_number, second_number)
first_number.to_f / second_number.to_f
end
def sub(first_number, second_number)
first_number.to_f - second_... | true |
ad5bd08ecee47499fe8328ba292053167003b09c | Ruby | meisyal/sastrawi-ruby | /lib/sastrawi/stemmer/context/visitor/remove_derivational_suffix.rb | UTF-8 | 1,042 | 2.8125 | 3 | [
"MIT",
"CC-BY-NC-SA-3.0"
] | permissive | require 'sastrawi/stemmer/context/removal'
##
# Remove derivational suffix
# Asian J. (2007) "Effective Techniques for Indonesian Text Retrieval" page 61
# http://researchbank.rmit.edu.au/eserv/rmit:6312/Asian.pdf
module Sastrawi
module Stemmer
module Context
module Visitor
class RemoveDerivationa... | true |
9e4138c3bcba179e43d04b8f25dcbc83dbcc093d | Ruby | yana-gi/atcoder | /abc191/a/main.rb | UTF-8 | 123 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
v, t, s, d = gets.split.map(&:to_i)
second = d / v.to_f
puts second >= t && second <= s ? 'No' : 'Yes'
| true |
f767aedd82feba664800d83073777b1a60214fcb | Ruby | mattiasbergbom/gcovtools | /lib/file.rb | UTF-8 | 3,512 | 3.109375 | 3 | [
"MIT"
] | permissive | require_relative './line'
require 'pathname'
class TrueClass
def to_i
return 1
end
end
class FalseClass
def to_i
return 0
end
end
module GCOVTOOLS
class File
attr_reader :name, :lines, :meta, :stats
def initialize name
fail "name required" unless name and name.is_a? String
@n... | true |
0e24bfb07ce5f9595abbecdf2c5b0352643e6693 | Ruby | lindig/ring3tools | /size.rb | UTF-8 | 3,601 | 2.765625 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env ruby
#
# Report code size by OCaml module in a native binary
#
require 'set'
require 'getoptlong'
class OCamlModule
include Comparable
attr_reader :name, :start, :stop
def initialize(name, start)
@name = name
@start = start
@stop = nil
end
def <=>(other)
return self.n... | true |
9188afe68bcf94c1359a9cc9ea853af9b89fc1d7 | Ruby | sarthak19-qait/Ruby | /Ruby/27).Modules.rb | UTF-8 | 179 | 3.203125 | 3 | [] | no_license | module Tools
def sayHii(name)
puts "hello #{name}"
end
def sayBie(name)
puts "hello #{name}"
end
end
include Tools
Tools.sayHii("Somil") | true |
1b21815fcc9089dc5bad11c90b37485457bc0be5 | Ruby | mwagner19446/wdi_work | /w01/d05/Kirsten/rental.rb | UTF-8 | 5,264 | 3.65625 | 4 | [] | no_license |
class Apartment
def initialize
end
def apartment_name=(apartment_name)
@apartment_name = apartment_name
end
def apartment_name
return @apartment_name
end
def price=(price)
@price = price
end
def price
return @price
end
def sqft=(sqft)
@sqft = sqft
end
def sqft
return @... | true |
1d3fec3a5900e57a045c1bc05560aab5afc5817b | Ruby | justonemorecommit/puppet | /spec/unit/util/windows/api_types_spec.rb | UTF-8 | 7,267 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # encoding: UTF-8
require 'spec_helper'
describe "FFI::MemoryPointer", :if => Puppet::Util::Platform.windows? do
# use 2 bad bytes at end so we have even number of bytes / characters
let(:bad_string) { "hello invalid world".encode(Encoding::UTF_16LE) + "\xDD\xDD".force_encoding(Encoding::UTF_16LE) }
let(:bad_st... | true |
8319dc4d3d36ea507d1b68235eedba2c998fc86d | Ruby | Muhidin123/ruby-oo-complex-objects-school-domain | /lib/school.rb | UTF-8 | 621 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_accessor :school_name, :name, :grade
def initialize(school_name, hash={}, *grade)
@school_name = school_name
@name = name
@grade = grade
@hash = hash
end
def roster
@hash
end
def add_student(name, grade)
if roster.length == ... | true |
34ad7a30dc809a12412566a7fe37da3aa5962a98 | Ruby | Segrelove/ruby-friday | /exo_07_c.rb | UTF-8 | 169 | 3.046875 | 3 | [] | no_license | user_name = gets.chomp
puts user_name
# la différence entre trois programmes est l'affichage alors que la fonctionnalité est la même, qui est d'afficher l'user input | true |
fd180d5c59362a237f52cfba1d14eadc9227bb63 | Ruby | bright-spark/mobilize-base | /lib/mobilize-base/extensions/google_drive/worksheet.rb | UTF-8 | 8,852 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | module GoogleDrive
class Worksheet
def to_tsv(gsub_line_breaks=" ")
sheet = self
rows = sheet.rows
header = rows.first
return nil unless header and header.first.to_s.length>0
#look for blank cols to indicate end of row
col_last_i = (header.index("") || header.length)-1
#i... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.