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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
51a107c8653be0cbc22b4e118a89e372f17c5ce6 | Ruby | Chanic/Ruby-Projects | /CalcSlap.rb | UTF-8 | 2,281 | 3.65625 | 4 | [] | no_license | puts 'Welcome to CalcSlap v0.6'
puts ''
puts ''
puts 'What type of calculation would you like to run?'
puts ''
puts 'Please use \'Add\' for addition, \'Sub\' for subtract, \'Div\' for divide or \'Mul\' for multiplication. Please type \'Close\' to close.'
command = gets.chomp
while command != 'Close'
#if command != ... | true |
0347523068fbf855d80a84e9525278b810c0a399 | Ruby | yxia521/solutions-to-intro-to-programming | /Chapter_9_More_Stuff/exercise_5.rb | UTF-8 | 501 | 3.34375 | 3 | [] | no_license | def execute(block)
block.call
end
execute { puts "Hello from inside the execute method!" }
# Error
# block.rb1:in `execute': wrong number of arguments (0 for 1) (ArgumentError) from test.rb:5:in `<main>'
# This error message informs you that Ruby can't execute line 5, because on line 1 the number of a... | true |
e82ff57103ecd6d380d4f73aa64e3dcc3e481513 | Ruby | smhaggerty/hackerrank_challenges | /ruby/ruby-tutorial/enumerables/reduce.rb | UTF-8 | 98 | 3.078125 | 3 | [] | no_license | def sum_terms(n)
# your code here
(1..n).reduce(0) {|sum, num| sum += (num * num + 1)}
end | true |
ea055690804a7af816f3b44bc90200c373afec3d | Ruby | ShadowManu/SigulabRails | /app/models/consumable.rb | UTF-8 | 1,008 | 2.75 | 3 | [
"MIT"
] | permissive | require "unicode_utils"
class Consumable < ActiveRecord::Base
validates :name, :presence => {:message => "no puede ser blanco"}
validates :dependency, :presence => {:message => "no puede ser blanco"}
validates :location, :presence => {:message => "no puede ser blanco"}
validates :responsible, :presence => {:message... | true |
f0a6da83d3a0fea81df4aa36fde8a9b68dd2d2be | Ruby | rymon23/w2d4 | /execution_time_diffs_algos/execution.rb | UTF-8 | 2,276 | 3.703125 | 4 | [] | no_license | require "byebug"
# list = [ 0, 3, 5, 4, -5, 10, 1, 90 ]
def my_min(list)
current_min = nil #o(1)
list.each_with_index do |el, i| #O(n)
list.each_with_index do |el2, j| #O(n)
if j > i #O(1)
current_min ||= el #O(1)
current_min = (current_min < el2) ? current_min : el2 #O(1)
current... | true |
1d7e343fe2fdb67ff3acab3c655cd0115af8e7fb | Ruby | Nimzyow/boris_bikes | /spec/docking_station_spec.rb | UTF-8 | 1,652 | 2.859375 | 3 | [] | no_license | require "docking_station"
require "bike"
shared_context "common" do
let(:bike) {Bike.new}
end
describe DockingStation do
include_context "common"
context "methods" do
it "responds to #release_bike" do
expect(subject).to respond_to(:release_bike)
end
it "#release_bike prevents release if curre... | true |
214bde8783427e98562bccf657d331319540845e | Ruby | kzk/holt-winters | /lib/holt_winters_factory.rb | UTF-8 | 396 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require 'holt_winters.rb'
class HoltWintersFactory
def self.create(alpha, attrs={})
if (attrs.has_key? :beta)
HoltWintersDouble.new(alpha, attrs[:beta])
elsif (attrs.has_key? :beta) && (attrs.has_key? :gamma) && (attrs.has_key? :period)
HoltWintersTriple.new(alpha, attrs[:beta], attrs[:gamma], at... | true |
c711467bcf82318c0692e40d099cf14f04d62e8c | Ruby | jimmikmak/Ruby_course | /Strings I/case_bang_methods.rb | UTF-8 | 822 | 4.0625 | 4 | [] | no_license | # frozen_string_literal: true
# Case Methods
puts 'hello12'.capitalize
puts 'heLLo!@'.capitalize
puts 'Hello 56'.capitalize
puts 'hello world'.capitalize.class
puts 'james123'.upcase
puts 'wa wa wa wa wa'.upcase
lowercase = "I'm patient"
uppercase = lowercase.upcase
p uppercase
p 'JAMES'.downcase
p 'jaMEs'.swapc... | true |
2c85ab1291549c8890800e8f112012a9b90285b9 | Ruby | cybool/junos-automation-examples | /ruby/ruby-language-intro.rb | UTF-8 | 316 | 2.875 | 3 | [] | no_license | #!/usr/bin/ruby
def process_interface(interface)
if interface =~ /ge-.*/
yield "#{interface} is gigabit"
else
yield "#{interface} is of unknown speed"
end
end
interfaces = ["ge-1/0/5", "fxp0"]
interfaces.each do |intf|
process_interface(intf) { |str| puts str }
end
3.times { puts "---------" }
| true |
4f8eee5001ed2c5fc554fbcc88b7eea004be4946 | Ruby | PaulGTN/Exo-Ruby | /exo_07_c.rb | UTF-8 | 231 | 2.921875 | 3 | [] | no_license | user_name = gets.chomp
puts user_name
# a Pose question, obtient réponse et répète, b idem mais avec une meilleure ergonomie utilisateur, c juste un écran noir si on ne sait pas ce qu'on doit faire, moins complet que les autres | true |
49155ba4082ad4ce497f1e0ff115601d1af83be9 | Ruby | SoniaDumitru/collections_practice_vol_2-chicago-web-career-040119 | /collections_practice.rb | UTF-8 | 891 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #'Return true if every element of the tools array
#starts with an "r" and false otherwise.
def begins_with_r(array)
array.all? do |word|
word[0] == "r"
end
end
#return all elements that contain the letter 'a' (filter)
def contain_a(array)
array.select do |word|
word.include?("a")
end
end
#Return the fir... | true |
ca1aa8f8f99736b3080f42c94260f8fc4af06950 | Ruby | daniellacosse/app-academy | /Week 2; OO Design/W2D4_Checkers/lib/checker.rb | UTF-8 | 2,741 | 3.21875 | 3 | [] | no_license | # coding: utf-8
require "debugger"
class Checker
attr_accessor :pos, :kinged
attr_reader :color, :board
def initialize(pos, color, board)
@pos, @color, @board = pos, color, board
@kinged = false
end
def to_s
kinged ? "☹" : "☺"
end
def perform_moves(dirs)
if valid_move_seq?(dirs)
... | true |
981b7c15d2f4751e3d87dd2596d32d3c73565506 | Ruby | cbp10/chitter-challenge | /spec/peep_spec.rb | UTF-8 | 796 | 2.578125 | 3 | [] | no_license | require 'peep'
describe '.all' do
describe 'can see all peeps' do
it 'returns all peeps sent' do
connection = PG.connect(dbname: 'chitter_test')
connection.exec("INSERT INTO peeps (peep, user_id) VALUES ('Hello', '#{user_id}');")
connection.exec("INSERT INTO peeps (peep, user_id) VALUES ... | true |
fcd015678045e442adab9ae255762acf1a9cbf9c | Ruby | jlonetree/ruby-enumerables-cartoon-collections-lab-part-1-atx01-seng-ft-082420 | /cartoon_collections.rb | UTF-8 | 230 | 3.828125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def greet_characters(array)
array.each do |list_dwarves|
puts "Hello #{list_dwarves.capitalize}!"
end
end
def list_dwarves(array)
array.each_with_index do |dwarves, number|
puts "#{number + 1}. #{dwarves}"
end
end | true |
e992272cfa73b5eb6fb3c21d49803c26574e5d09 | Ruby | andersontylerb/week1-input_output | /input_output.rb | UTF-8 | 105 | 2.9375 | 3 | [] | no_license | puts "welcome name"
name = []
name << gets.chomp
puts "hi #{name}"
name << gets.chomp
puts "hi #{name}"
| true |
7162f9d86f3a22b4a6ffcfa6ae40defe87309b9b | Ruby | msynko/ruby_fundamentals2 | /exercise7.rb | UTF-8 | 215 | 3.109375 | 3 | [] | no_license | def wrap_text(word1,word2)
return (word2 + word1 + word2)
end
puts wrap_text("Marina", "~~~")
hashtags = wrap_text("new message", "###")
equals= wrap_text(hashtags, "===")
puts wrap_text(equals, "---")
| true |
519c1ad790b6ebe6088cbc1020a9f7aacb581681 | Ruby | maximpertsov/upwords | /test/game_test.rb | UTF-8 | 669 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class GameTest < Minitest::Test
include Upwords
def setup
@game = Game.new
@game.add_player("Max")
@game.add_player("Jordan")
end
def teardown
@game.exit_game if @game.running?
end
def test_has_game_objects
assert_kind_of(Board, @game.board)
end
def test_... | true |
31c8c321e30401db460fa504b9dc9ce659f0715d | Ruby | eedgarr/Block | /chain/etc/ac.rb | UTF-8 | 197 | 2.5625 | 3 | [] | no_license | aaaaaaaa = ["pork steak", "noodle", "orange", "sapporo beer"].sort.reverse
1.upto(10) do
aaaaaaaa.each do |bbbbbbb|
puts bbbbbbb.capitalize + "!." + "good".upcase.capitalize + ".$"
end
end
| true |
6e582f2bc15d4152c96945bd571a2515c53dc5e6 | Ruby | wulymammoth/rom-cassandra | /lib/rom/cassandra/migrations/migrator.rb | UTF-8 | 2,831 | 2.9375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module ROM::Cassandra
module Migrations
# Class Migrator finds the migration files and migrates Cassandra cluster
# to the required version using method [#apply].
#
# The class is responcible for searching files and deciding,
# which of them should be runned up and down. Every... | true |
f5229e303eece21b20a976e7f0ec775725c36f7e | Ruby | obsidian-btc/subst-attr | /test/bench/strict_null_object_attribute.rb | UTF-8 | 615 | 2.5625 | 3 | [
"MIT"
] | permissive | require_relative 'bench_init'
module Strict
class SomeDependency
def a_method; end
end
class Example
extend SubstAttr::Macro
subst_attr :some_attr, SomeDependency
end
end
context "String" do
example = Strict::Example.new
context "Methods not on the impersonated class" do
test "The attri... | true |
d026393afcb6526252c9533b0a0071ddbfaa7b0f | Ruby | kvokka/activevalidation | /lib/active_validation/registry.rb | UTF-8 | 1,108 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module ActiveValidation
class Registry
include Enumerable
attr_reader :name
def initialize(name)
@name = name
@items = Concurrent::Map.new
end
def clear
@items.clear
end
def each(&block)
@items.values.uniq.each(&block)
end
... | true |
c68fa384307eef7acf0ed4f44f74038f527d1bd0 | Ruby | pfspence/rubicon | /generators/sequencer.rb | UTF-8 | 340 | 2.796875 | 3 | [] | no_license | class Sequencer
attr_accessor :settings
def initialize(args)
set_settings({"key"=> "foobar"})
end
def set_settings(settings)
@settings = settings
end
def process()
data = []
metadata =[]
data = ["10","11","12","13","14","15"]
result = Hash.new
result['data'] = data
result['metadata'] = []
re... | true |
0834693fb4c5206657a251b09cfe1457920d27bf | Ruby | NREL/OpenStudio-analysis-spreadsheet | /measures/AedgSmallToMediumOfficeRoofConstruction/measure.rb | UTF-8 | 31,247 | 2.59375 | 3 | [] | no_license | #see the URL below for information on how to write OpenStudio measures
# http://openstudio.nrel.gov/openstudio-measure-writing-guide
#see the URL below for information on using life cycle cost objects in OpenStudio
# http://openstudio.nrel.gov/openstudio-life-cycle-examples
#see the URL below for access to C++ ... | true |
0e252a1dec3bbad5aa51272acddda057ecb8f37c | Ruby | catd825/ruby-enumerables-hashes-and-enumerables-nyc01-seng-ft-062220 | /lib/cruise_ship.rb | UTF-8 | 534 | 3.65625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # passengers = {
# suite_a: "Amanda Presley",
# suite_b: "Seymour Hoffman",
# suite_c: "Alfred Tennyson",
# suite_d: "Charlie Chaplin",
# suite_e: "Crumpet the Elf"
# }
def select_winner(passengers)
winner = "" #create new variable
passengers.each do |suite, name| #iterate over passenger array - suite & name. u... | true |
05d09268d140e77a057665b41ef54d4a3f7fabc5 | Ruby | abwinkler999/minormud | /minormud.rb | UTF-8 | 2,633 | 3.5625 | 4 | [] | no_license | require 'socket'
require 'term/ansicolor'
require 'colorize'
require 'pry'
# a Player has an associated Character, and a socket through which he is connecting
class Player
attr_accessor :character, :socket
def initialize(incoming_socket)
@socket = incoming_socket
end
def create_character(name)
@character = C... | true |
bcd63701b59b4045a937f1fe0ce6a5bb14518a37 | Ruby | DanielSLew/Ruby_Small_Problems | /Object_Oriented_Programming/OOBasics_Class_Objects2/public_secret.rb | UTF-8 | 308 | 4.0625 | 4 | [] | no_license | # Use the following code
# create a class named Person with an instance variable named @secret
# use a setter method to add a value to @secret
# use a getter method to print @secret
class Person
attr_accessor :secret
end
person1 = Person.new
person1.secret = 'Shh.. this is a secret!'
puts person1.secret | true |
5df12818606825f860d5d07c4ee4b43094f1928b | Ruby | gavinmcgimpsey/launch-school-3 | /reduce.rb | UTF-8 | 168 | 3.1875 | 3 | [] | no_license | def reduce(arr, accumulator = 0)
counter = 0
while counter < arr.length
accumulator = yield(accumulator, arr[counter])
counter += 1
end
accumulator
end
| true |
454c9f569c9d471de14ed42dd38d74d7c1f64b47 | Ruby | fosterv2/ruby-array-practice-oxford-comma-lab-seattle-web-030920 | /lib/oxford_comma.rb | UTF-8 | 254 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
# count = 0
# while count < (array.length - 1)
#
# end
if array.length == 1
array[0]
elsif array.length == 2
array.join(" and ")
else
ending = array.pop
"#{array.join(", ")}, and #{ending}"
end
end
| true |
dd02b226dcb84a98871147aaa52a162f7992cc4c | Ruby | ForEverRoice/arreglos_archivos | /presencial1/startwatch1.rb | UTF-8 | 347 | 3.015625 | 3 | [] | no_license |
pasos = ['100', '21', '231as', '2031', '1052000', '213b', 'b123']
def clear_steps(steps)
filtrado_letras = steps.reject do |x|
/[aA-zZ]/.match(x)
end
convertido = filtrado_letras.map do |x|
x.to_i
end
filtrado_pasos = convertido.select do |x|
x >= 200 and x <= 10000
end
return filtrado_pas... | true |
56f2fb578d3fde51c77388a84c3a3a35df890fce | Ruby | cha63506/Purrfect-Match | /app/models/pet.rb | UTF-8 | 1,352 | 2.59375 | 3 | [] | no_license | class Pet < ActiveRecord::Base
belongs_to :shelter
has_many :pet_breeds
has_many :breeds, through: :pet_breeds
has_many :favorite_pets
has_many :users, through: :favorite_pets
# def self.species
# @species = ["barnyard", "bird", "cat", "dog", "horse", "pig", "reptile", "smallfurry"]
# end
def sea... | true |
e0623edc22ca979a9873da480f6eebf4e64d4b43 | Ruby | adamsanderson/cesspit | /lib/cesspit/cli.rb | UTF-8 | 576 | 2.734375 | 3 | [
"MIT"
] | permissive | class Cesspit::CLI
attr_reader :cesspit
attr_reader :in, :out
def initialize(options)
@cesspit = Cesspit.new
@in = options[:in]
@out = options[:out] || STDOUT
options[:css_paths].each do |path|
cesspit.read_css(path)
end
if options[:html_paths]
options[:html_path... | true |
52b792f25e38ab81ef01da0af1b0dcdc2a409c1b | Ruby | Ido-Efrati/tripper | /app/models/exchange.rb | UTF-8 | 1,143 | 2.90625 | 3 | [] | no_license | # @author Jesika Haria
class Exchange < ActiveRecord::Base
belongs_to :trip
has_many :costs, dependent: :destroy
validates :units, presence: true, uniqueness: { scope: :trip_id }
validates :rate, presence: true, numericality: { greater_than: 0 }
# Default resources and rates associated with trip on creation
... | true |
b9d84c4f0f645a8f7ebebe7597523d2c9ff61e51 | Ruby | minnonong/Codecademy_Ruby | /05. Loops & Iterators/05_11.rb | UTF-8 | 300 | 3.890625 | 4 | [] | no_license | # 05_11 The .each Iterator
=begin
each : 객체의 각 요소에 하나씩 수식 적용 가능.
사용법 - object.each { |item| 실행 할 코드 } or
object.each do |item| 실행 할 코드 end
=end
array = [1,2,3,4,5]
array.each do |x|
x += 10
puts "#{x}"
end
| true |
a54fc1424438daaaf166e9a25742f51286ba34ea | Ruby | sinventor/my-list | /scripts/sort_by_date_asc.rb | UTF-8 | 734 | 2.65625 | 3 | [] | no_license | file = ARGV.first
lines = File.readlines(file)
first_indexes = []
no_sorted_indexes = []
lines.each_with_index do |line, i|
first_indexes << i if line.strip[0] != "*"
no_sorted_indexes << i if line.strip[0] == "*" && line.match(/.+hab.+post\/.+/).nil?
end
listed_lines = lines.select{ |line| line.strip[0] == "*" &... | true |
2adec523aafcb3f831190bee1387f62a2f134dbb | Ruby | snowhork/type_struct | /lib/type_struct/hash_of.rb | UTF-8 | 488 | 3 | 3 | [
"MIT"
] | permissive | require "type_struct/union"
class TypeStruct
class HashOf
include Unionable
attr_reader :key_type, :value_type
def initialize(key_type, value_type)
@key_type = key_type
@value_type = value_type
end
def ===(other)
return false unless Hash === other
other.all? do |k, v|
... | true |
9c98f9be1aca7cb012b05e30b00ff1635fc44d43 | Ruby | DeveloperAlan/WDI_SYD_7_Work | /w01/d02/eugenius/while.rb | UTF-8 | 433 | 4.09375 | 4 | [] | no_license | =begin
puts "what is 2 to the 16th power?"
answer = gets.chomp.to_i
while (2**16) != answer
print "wrong try again"
answer = gets.chomp.to_i
end
puts "good job"
=end
# Use a while loop to let the user guess again until he/she gets the answer right.
# Once the user guesses right, print "Good Job"
begin
puts "W... | true |
7dd44745748c9145b5bbff0e39b9a71922b93a73 | Ruby | szek/redbubble-challenge | /spec/slugger_spec.rb | UTF-8 | 420 | 2.828125 | 3 | [] | no_license | require_relative '../app/modules/slugger'
class Foo
include Slugger
end
describe Slugger do
it "returns a valid slug" do
expect(Foo.new.slug_for('valid slug')).to eq 'valid-slug'
end
it "downcases" do
expect(Foo.new.slug_for('VALID SLUG')).to eq 'valid-slug'
end
it "strips slugs of non alphanu... | true |
ee4f55532c52a2bc449e0873662a78969475ab5f | Ruby | Watson-Derek/RB101 | /Exercises/Medium1/fibonacci_procedural.rb | UTF-8 | 303 | 3.5625 | 4 | [] | no_license | def fibonacci(num)
return 1 if num <= 2
num1 = 1
num2 = 1
final = 0
(num - 2).times do
final = num1 + num2
num2 = num1
num1 = final
end
final
end
p fibonacci(20) == 6765
p fibonacci(100) == 354224848179261915075
# p fibonacci(100_001) # => 4202692702.....8285979669707537501 | true |
e87d1223a6058d76d5b3c6737ef0cae7bde0a4d1 | Ruby | hybitz/hyacc | /app/models/career.rb | UTF-8 | 652 | 2.5625 | 3 | [
"MIT"
] | permissive | class Career < ApplicationRecord
belongs_to :employee
belongs_to :customer
validates :project_name, :presence => true
before_save :update_names
# マスタの名称を明細自身に設定する
def update_names
self.customer_name = customer.formal_name_on(end_to)
end
def duration_ym
duration = (end_to_or_t... | true |
95b4c192a3b95d5228079b7be3b5a319710bfbff | Ruby | KMyatThu/Bulletin_Board | /app/models/post.rb | UTF-8 | 830 | 2.546875 | 3 | [] | no_license | class Post < ApplicationRecord
belongs_to :created_user, class_name: "User", foreign_key: "create_user_id"
belongs_to :updated_user, class_name: "User", foreign_key: "updated_user_id"
validates :title, presence: true
validates :description, presence: true
def self.to_csv
CSV.generate do |csv|
csv ... | true |
212d5f8e7b48169939893b590c7c49ba400fce8d | Ruby | gabe-vazquez-blk/silicon-valley-code-challenge-nyc-web-051319 | /tools/console.rb | UTF-8 | 890 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
s1 = Startup.n... | true |
baaba38cbfc88b8d428cb2bdb1c9f3c4cbafc2e7 | Ruby | red-data-tools/red-chainer | /lib/chainer/hyperparameter.rb | UTF-8 | 460 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Chainer
class Hyperparameter
attr_reader :parent
def initialize(parent: nil)
@parent = parent
end
def method_missing(name)
@parent.instance_variable_get("@#{name}")
end
def get_dict
d = @parent.nil? ? {} : @parent.get_dict
self.instance_variables.each do |m|
... | true |
7230d56ef94609e4c6400da84e676a55c5bd767b | Ruby | Jennifer-Wang/test-first-ruby | /lib/01_temperature.rb | UTF-8 | 87 | 3 | 3 | [] | no_license | def ftoc(f)
return (f - 32) * (5.0 / 9)
end
def ctof(c)
return c*(9.0/5) +32
end
| true |
76b5648adc566da643d804512879c28fdaad0f1e | Ruby | jverbosky/minedminds_homework | /modules/mined_mineds_puts/Custom_Modulos.rb | UTF-8 | 690 | 3.328125 | 3 | [] | no_license | # Module for custom modulo methods
# Required by Method_Variations.rb module
module Custom_Modulos
# Custom modulo method that targets remainder after float division
def Custom_Modulos.evenly_divisible(dividend, divisor)
quotient = dividend.to_f / divisor
remainder = quotient - quotient.to_int
... | true |
bbbbaec727a4aa58c6118e569eda09773e298c55 | Ruby | ElliottAYoung/Dungeonator | /lib/dungeonator.rb | UTF-8 | 799 | 2.84375 | 3 | [
"MIT"
] | permissive | require "dungeonator/version"
module Dungeonator
def self.dungeon_name
"The #{Dungeonator.second_word.sample} Of #{Dungeonator.fourth_word.sample}"
end
private
def self.second_word
["Clearing", "Tomb", "Lair", "Peak", "Gathering", "Forest", "Mountain", "Island", "City", "Ascent", "Secret", "Rise", "P... | true |
7e17d53121543073766da0a8f3db7fdf8f0a0c7b | Ruby | LannTheStupid/pawn_inclination | /table_test.rb | UTF-8 | 267 | 2.96875 | 3 | [] | no_license | require 'text-table'
array = [
['S', '+', '!M!', 'C'],
[2, 43, 456, -123]
]
puts array.to_table(:first_row_is_head => false)
table = Text::Table.new
table.head = ['S', '+', '!M!', 'C']
table.rows << [2, 43, 456, -123]
table.align_row 2, :right
puts table
| true |
f0b792103bfad6129a1dfdd4216b70da5442e6bd | Ruby | XiaoA/tealeaf-precourse | /07_arrays/solution7_corrected.rb | UTF-8 | 116 | 2.953125 | 3 | [] | no_license | hachi = [1, 2, 3, 4, 5, 6, 7, 8]
hachi2 = []
hachi.each do |num|
hachi2 << num + 2
end
p hachi
p hachi2
| true |
7ffcc6606d2521ab71dd9fe95cba9e666d7e7592 | Ruby | kalina/project-euhler | /Project Euler/problem1.rb | UTF-8 | 168 | 3.3125 | 3 | [] | no_license |
#{{{
#1 to 999 filter { x => x % 3 == 0 || x % 5 == 0 } sum
#}}}
sum = 0
digits = Array(1..999)
puts digits.find_all{|x| x % 3 == 0 || x % 5 == 0 }.inject(:+)
| true |
d3a51a01e2f7530c9a7bf1d2e819dc78f093cd21 | Ruby | MatteoTHP/Morpion | /app.rb | UTF-8 | 1,459 | 3.15625 | 3 | [] | no_license | # lignes très pratiques qui appellent les gems du Gemfile. On verra plus tard comment s'en servir ;) -
# ça évite juste les "require" partout
require 'bundler'
Bundler.require
# lignes qui appellent les fichiers lib/game.rb et lib/player.rb
require_relative 'lib/game'
require_relative 'lib/player'
require_relative 'l... | true |
901de5a47acb98651b6a9da8b78ebb4ba3403972 | Ruby | gching/csc_sql | /test_input.rb | UTF-8 | 390 | 3.171875 | 3 | [] | no_license | ## test_input.rb
## Gavin Ching
## February 17, 2014
## This file is used to test files for input
#################### Reading from File ###########################
puts "Insert file name:"
## Get the file name of the file being read.
filename = gets.chomp
## Open the file to read each line and output it
File.open(f... | true |
110f69fde9a36c6653b531462f5d819fe9f97b67 | Ruby | lukeperrin10/ruby | /My_group.rb | UTF-8 | 266 | 3.5 | 4 | [] | no_license |
my_group = []
person_1 = %w{Kim 30 Man}
person_2 = %w{Jack 47 Man}
person_3 = %w{Sophie 19 Woman}
my_group = [person_1,person_2, person_3]
my_group.each do |person|
puts "Hi my name is #{person[0]} I am a #{person[2]} and am #{person[1]} years old!"
end
| true |
88ec17fd16f3a1b47147c46f4c68dd73a1fa86a5 | Ruby | craigaup/hcc_raceday_backend | /test/models/craft_test.rb | UTF-8 | 10,748 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class CraftTest < ActiveSupport::TestCase
def setup
Distance.all.each do |d|
d.year = DateTime.now.in_time_zone.year
d.save
end
%i[one two oneout twoout].each do |sym|
craft = crafts(sym)
craft.year = DateTime.now.in_time_zone.year
craft.save
end
... | true |
9b7e2c2f59bccbfd2270bbf1c9807fd00ba2c9c9 | Ruby | ifcwebserver/IFCWebServer-Extensions | /extensions/byclass/IfcDateTime.rb | UTF-8 | 793 | 2.734375 | 3 | [] | no_license | class IFCDATEANDTIME
def date_time
dateComponent= self.dateComponent.to_obj
timeComponent = self.timeComponent.to_obj
dateComponent.monthComponent = '0' + dateComponent.monthComponent.to_s if dateComponent.monthComponent.to_s.size == 1
dateComponent.dayComponent = '0' + dateComponent.dayComponen... | true |
02cc56ffe06370f9d2134f63a62a312011414fc3 | Ruby | cmoir97/Film-Shop-Inventory | /film_shop/models/production_company.rb | UTF-8 | 1,633 | 3.109375 | 3 | [] | no_license | require_relative('../db/sql_runner')
class ProductionCompany
attr_reader :id
attr_accessor :name
def initialize(options)
@id = options['id'].to_i
@name = options['name']
end
def save()
sql = "INSERT INTO production_companies
( name ) VALUES
( $1 ) RETURNING id"
values = [@name]
... | true |
ff0dd09c8676e77bb5923449b562fa0b0d0d08af | Ruby | skuan/src | /awesome.rb | UTF-8 | 621 | 4.28125 | 4 | [] | no_license | #Fizzbuzz
seq = (1..100)
#instinctually set a variable = to the range 1.100 inclusive although I saw online that you can directly run a .each on (1..100) w/o defining a variable.
seq.each do |i|
#element i for integer, with the following conditional block
if i % 15 == 0
puts "FizzBuzz"
#noticed when I didn't ... | true |
9adf3ed53a3cf63e8e77b5bd6bc5b9ee0ba87e53 | Ruby | RJ-Ponder/RB101 | /exercises/medium_2/4_matching.rb | UTF-8 | 1,756 | 4.53125 | 5 | [] | no_license | =begin
Write a method that takes a string as an argument, and returns true if all
parentheses in the string are properly balanced, false otherwise.
To be properly balanced, parentheses must occur in matching '(' and ')' pairs.
Note that balanced pairs must each start with a (, not a ).
Problem
- determine if the st... | true |
c357ecb4bd89d099647bad46e473c61fa3fc68ac | Ruby | antman999/project-02 | /lib/movie.rb | UTF-8 | 1,244 | 3.21875 | 3 | [] | no_license | require 'pry'
class Movie < ActiveRecord::Base
has_many :rentals
has_many :reviews
has_many :users, through: :rentals
has_many :critics, through: :reviews
end
# attr_accessor :title, :rating, :category
# @@all = []
# def initialize (title, rating, category)
# @title ... | true |
21581c957cc49e5cb98ed3b2a05bbcfcbdc51770 | Ruby | StephenWattam/ImputeCaT | /lib/impute/summarise/audience_level.rb | UTF-8 | 3,454 | 3.140625 | 3 | [] | no_license |
module Impute::Summarise
class AudienceLevel < Heuristic
# Initialise the audience level heuristic using a
#
# cat => Fleisch-Kincaid reading score hash
#
# ** Ensure that the categories are given in-order!
def initialize(categories)
@categories = categories
@fkscorer = ... | true |
4a7507a2948b253f31163c64e3cc8ff2150f10e2 | Ruby | pitr12/OpenCoroprate-mass-licences | /scraper.rb | UTF-8 | 1,915 | 2.765625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require 'json'
require 'turbotlib'
require 'nokogiri'
require 'faraday'
require 'roo'
def self.get_xls_links(doc, cell)
table = doc.search('table')[1]
list = []
table.search('tr').each do |tr|
td = tr.search('td')[cell]
links = td.search('a').map { |link| "http://www.mass.gov" + ... | true |
52960a96ef5993dd761c1a548f77917a8554050b | Ruby | npmcdn-to-unpkg-bot/KouhaiDash | /app/models/google_account.rb | UTF-8 | 1,551 | 2.625 | 3 | [] | no_license | # == Schema Information
#
# Table name: google_accounts
#
# id :integer not null, primary key
# user_id :integer
# access_token :string
# refresh_token :string
# expires_at :datetime
# gmail :string
# created_at :datetime not null
# updated_at :datetime ... | true |
27864dd42ba282b5887d1d4aa9dde3d5230312de | Ruby | brunovongxay/exercice-pair-programming | /exo_14.rb | UTF-8 | 119 | 3.34375 | 3 | [] | no_license | puts "Choississez un nombre"
number = gets.chomp.to_i
i=number
number.times do
puts "#{i-=1}"
end
| true |
c57b594445292b998e09ba8f5f881285acd992e3 | Ruby | quintel/merit | /spec/merit/participants/user/price_sensitive_spec.rb | UTF-8 | 3,983 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
# Users should be set up with "want" amounts of:
#
# point 0 = 1.0
# point 1 = 2.0
#
RSpec.shared_examples('a price-sensitive User') do
context 'when the "want" price is 15' do
let(:price_curve) { [15, 15] }
context 'when the "offer" price is 2.5 and ... | true |
09d705cf63224a838df71b350555f7073eb9319c | Ruby | MiguelSilva1997/battleship_rails | /app/models/turn_helper.rb | UTF-8 | 401 | 2.5625 | 3 | [] | no_license | module TurnHelper
def before_save_validation(game, player_id, coord)
return "game_over", false if game.phase == "game_over"
return "not_your_turn", false if game.next_player != player_id
unless ("A".."J").to_a.include?(coord[0]) && ("0".."9").to_a.include?(coord[1])
retu... | true |
84b3db6449caf1730e271c2cd70fdfd8e3dbdf52 | Ruby | starapor/slippers | /lib/engine/slippers_nodes.rb | UTF-8 | 4,539 | 2.625 | 3 | [
"MIT"
] | permissive | module Slippers
module AttributeToRenderNode
def eval(object_to_render, template_group)
[object_to_render].flatten.inject('') { |rendered, item| rendered + render(value_of(item, template_group), template_group) }
end
def value_of(item, template_group)
return default_string(template_group) if... | true |
4aa4a0746979b8b3fd180cc0254ad0f3dff9a039 | Ruby | stashchenkoksu/exercism | /queen_attack/main.rb | UTF-8 | 715 | 3.40625 | 3 | [] | no_license | require_relative 'lib/queen_attack'
require_relative 'lib/readme_viewer'
def get_argv(first_coord, second_coord)
2.times { |i| first_coord << ARGV[i].to_i }
2.times { |i| second_coord << ARGV[i + 2].to_i }
end
def get_user_input(first_coord, second_coord)
puts 'Enter first pair of coordinates'
print 'x: '
f... | true |
65fc81d0dad4be70d48d4b52e5fb73799bf59e2a | Ruby | blackjackshellac/giddy | /test/giddy/gstat_spec.rb | UTF-8 | 2,759 | 2.640625 | 3 | [] | no_license | #
#
#
require 'fileutils'
require './lib/giddy/gstat'
describe Gstat do
before(:all) do
@home_dir=FileUtils.pwd
@test_dir="test"
FileUtils.chdir(@test_dir) {
%x/echo > empty/
%x/echo "not empty" > file/
%x/ln -s file file_symlink/
%x/ln -s . dir_symlink/
@empty="empty"
@file ="file"
@fi... | true |
9d6434b9c4a7f2fe60febcb88acfd9857fd4a501 | Ruby | TheCalebThornton/slcsp | /spec/models/plan_spec.rb | UTF-8 | 2,861 | 2.515625 | 3 | [] | no_license | require 'models/plan'
describe Plan do
describe '.find_all_by_state_and_rate_area_and_metal_level' do
testCsvPath = "#{File.join(File.dirname(__FILE__), '../resources/plansSmallTest.csv')}"
context 'given nil state' do
it 'returns empty list' do
plans = Plan.find_all_by_state_and_rate_ar... | true |
7a3b5cad0d6f084fa4b3547ec26caba84b120472 | Ruby | mjrudin/twitter | /user.rb | UTF-8 | 2,162 | 2.9375 | 3 | [] | no_license | require 'json'
require_relative 'twitter_session'
require 'addressable/uri'
class User
@@users = []
def self.users
@@users
end
def self.make_new(user_array)
user_array.map do |user|
User.new(user["screen_name"])
end
end
def initialize(username)
@username = username
@@users << s... | true |
319cd2dc5fc0b199d88202e661f99692f9512d67 | Ruby | kristastadler/backend_module_0_capstone | /day_1/ex7.rb | UTF-8 | 523 | 4.25 | 4 | [] | no_license | #print "How old are you? "
#age = gets.chomp
#print "How tall are you? "
#height = gets.chomp
#print "How much do you weigh? "
#weight = gets.chomp
#puts "So, you're #{age} old, #{height} tall and #{weight} heavy."
print "Where were you born? "
location = gets.chomp
print "What is your birthday? "
birthday = gets.cho... | true |
31932929e7b41c7b125b2524c07bf2009b01f056 | Ruby | peppyheppy/jekyll | /lib/jekyll/migrators/mephisto.rb | UTF-8 | 3,960 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # Quickly hacked together my Michael Ivey
# Based on mt.rb by Nick Gerakines, open source and publically
# available under the MIT license. Use this module at your own risk.
require 'rubygems'
require 'sequel'
require 'fastercsv'
require 'fileutils'
require File.join(File.dirname(__FILE__),"csv.rb")
# NOTE: This conv... | true |
a05675e47d547c0e56634119cde77f06cf59bb61 | Ruby | jcovell/my-first-repository | /flow/cx4.rb | UTF-8 | 97 | 3.640625 | 4 | [] | no_license | # Example 4: must use "then" keyword when using 1-line syntax
if x == 3 then puts "x is 3" end
| true |
c7de705a8198c35355b6fba72619104189635779 | Ruby | bwarminski/tree | /tree.rb | UTF-8 | 811 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby
Counter =
Struct.new(:dirs, :files) do
def index(filepath)
File.directory?(filepath) ? self.dirs += 1 : self.files += 1
end
def output
"\n#{dirs} directories, #{files} files"
end
end
def tree(counter, directory, prefix = '')
filepaths = Dir[File.join(directory, '... | true |
b96b38c243dd2190b81691cbddb2b5313f091605 | Ruby | gearjosh/linda_the_sphinx | /spec/sphinx_spec.rb | UTF-8 | 547 | 2.953125 | 3 | [] | no_license | require 'pry'
require 'sphinx'
describe '#Sphinx' do
describe '#riddle' do
it 'returns a riddle' do
linda = Sphinx.new
expect(linda.riddle1).to(eq('What gets wetter and wetter the more it dries?'))
end
it 'returns a second riddle' do
linda = Sphinx.new
expect(linda.riddle2).to(eq... | true |
039dc14d6bd300fa71f2409b1622b88d771e10dd | Ruby | PhilippePerret/Collecte | /module/extract_formats/HTML/Film/Note/helper.rb | UTF-8 | 548 | 2.609375 | 3 | [] | no_license | # encoding: UTF-8
class Film
class Note
def as_link
link("note #{id}", {href: '#', onclick:"return ShowNote(#{id})"})
end
# Retourne le code HTML de la note comme fiche
def as_fiche
div(
closebox("return HideCurFiche()") +
div("Note #{id}", class: 'titre') +
libval('Description', con... | true |
634d4e859f3fad8eb06a3f954f90ff935d7b3e18 | Ruby | brightchimp/twitter | /lib/twitter/base.rb | UTF-8 | 314 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Twitter
class Base
def initialize(hash={})
hash.each do |key, value|
instance_variable_set(:"@#{key}", value) unless value.nil?
end
self
end
def to_hash
Hash[instance_variables.map{|ivar| [ivar[1..-1].to_sym, instance_variable_get(ivar)]}]
end
end
end
| true |
b6d63f0183c92e7f86fdbe46bed4ad8727a63f92 | Ruby | bbensky/dishlist | /recipe.rb | UTF-8 | 5,277 | 3.765625 | 4 | [] | no_license | # require 'pry'
# Display list of recipes
# Prompt user to add a recipe
# Recipes consist of ingredients, quantities, units of measurement
# Verbs:
# Add ingredients and quantities to a recipe
require 'yaml'
class Recipe
attr_accessor :title, :directions, :ingredients, :tags
def initialize
@title = ""
... | true |
3ca9e176ee8707fe2b28a74c2836cb65150c2b97 | Ruby | anikonchuk/crud-with-validations-lab-v-000 | /app/models/song.rb | UTF-8 | 755 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
validates :title, :artist_name, presence: true
validates :released, inclusion: { in: [true, false] }
validates :release_year, presence: true, if: :released?
validate :release_date_in_the_past?
validate :same_artist_same_year?
def release_date_in_the_past?
if release_year... | true |
26714b7c69cf5d41592090766cefcda281c47da0 | Ruby | kakuda/myfiles | /home/libs/ruby/japanese.rb | UTF-8 | 2,529 | 2.671875 | 3 | [] | no_license | $KCODE = 'u'
require 'jcode'
class JapaneseExtractor
def initialize
end
def extract_addr(str)
return str.scan(/([一-龠]+[都|道|府|県|][一-龠]+[市|区|町|村|])/u)
end
def is_zenkaku_katakana(str)
(?:\xE3\x81[\x81-\xBF]|\xE3\x82[\x80-\x93])
end
def extract_person_name(str)
return str.scan(/[、|の](.*?)[が... | true |
18416808c64b110c34ef54eb8386924ecc2d1e20 | Ruby | helloRupa/active-record-lite | /lib/02_searchable.rb | UTF-8 | 396 | 2.609375 | 3 | [] | no_license | require_relative 'db_connection'
require_relative '01_sql_object'
module Searchable
def where(params)
where_str = params.keys.join(' = ? AND ') + ' = ?'
res = DBConnection.execute(<<-SQL, *params.values)
SELECT
*
FROM
#{table_name}
WHERE
#{where_str}
SQL
re... | true |
10d697dfae76d1a0a22ec643873e603ba41efe68 | Ruby | alexcoplan/toomuchsupport | /lib/core_ext/string.rb | UTF-8 | 666 | 3.609375 | 4 | [] | no_license | class String
# remove last (or more) chars from string
def clip n=1
self[0..-n-1]
end
def clip! n=1
self.replace(clip n)
end
# this is truly a magnificent core extension
# it let's you do stuff like "foo".foo? # => true
# TODO: fuzzy matching for underscores/spaces
def method_missing sym
... | true |
f8742e286a694a246a73e2dd40106e814efe45a9 | Ruby | JohnAjaka/deli-counter-onl01-seng-ft-052620 | /deli_counter.rb | UTF-8 | 720 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | katz_deli = []
def line(line_array)
waiting_array = []
if line_array.size == 0
puts "The line is currently empty."
else
line_array.each_with_index do |name, index|
waiting_array.push("#{index + 1}. #{name}")
end
puts "The line is currently: #{waiting_array.join(... | true |
e09095e2e7e826741045864e091c4328e84e5bee | Ruby | minucos/ruby-challenge | /spec/receipt_spec.rb | UTF-8 | 978 | 3.0625 | 3 | [] | no_license | require "receipt"
require "basket"
require "item"
require "tax"
describe Receipt do
let(:basket) { Basket.new }
let(:gst) { Tax.new("GST",10)}
let(:import) { Tax.new("import",5)}
let(:item_1) { Item.new(qty: 1, name: "book", price: 12.49,taxes: [], imported: false) }
let(:item_2) { Item.new(qty: 1, name: "mu... | true |
81d654c467965152967e231099573673491f1970 | Ruby | aitchiss/music_collection | /console.rb | UTF-8 | 496 | 2.671875 | 3 | [] | no_license | require('pry')
require_relative('./models/artist.rb')
require_relative('./models/album.rb')
Album.delete_all
Artist.delete_all
artist1 = Artist.new(
{'name' => "David Bowie"}
)
artist1.save
artist2 = Artist.new(
{'name' => "Bruce Springsteen"}
)
artist2.save
album1 = Album.new({
'name' => 'Hunky Dory'... | true |
5fb05c537aee06ec9f9e7e80f6ceed1d0866773b | Ruby | LShiHuskies/todo-ruby-basics-prework | /lib/ruby_basics.rb | UTF-8 | 390 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
return num1/num2
end
def assign_variable(value)
return value = value
end
def argue (phrase)
return phrase
end
def greeting (greeting, name)
return "#{greeting}, #{name}"
end
def return_a_value
value = "Nice"
return value
end
def last_evaluated_value
return "expert"
end... | true |
b533d243e64a9ab546c8886ee0bb403b07225e0e | Ruby | petergoldstein/dalli | /test/test_ring.rb | UTF-8 | 2,641 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require_relative 'helper'
class TestServer
attr_reader :name
def initialize(attribs, _client_options = {})
@name = attribs
end
def weight
1
end
end
describe 'Ring' do
describe 'a ring of servers' do
it 'have the continuum sorted by value' do
servers = ['l... | true |
e6ac1a2521d1e455b142b6157f461d4b36d31ae6 | Ruby | jamesmoriarty/victoria-exposure-site-bot | /lib/services/download.rb | UTF-8 | 596 | 2.546875 | 3 | [] | no_license | require 'csv'
require 'open-uri'
require_relative '../models/site'
module ExposureBot
module Service
class Download
def self.call(logger, csv_url)
logger.info("Fetching: #{csv_url}")
io = URI.open(csv_url)
CSV.parse(io.read, headers: true).map do |row|
Site.new(
... | true |
cf4b7f5a5e4eaba53750071f37b0027ee347462f | Ruby | semyonovsergey/int-brosayZavod | /lesson 4-1/MyApp5.rb | UTF-8 | 34 | 2.96875 | 3 | [] | no_license | 20.downto(10) do |i|
puts i
end
| true |
16384d426c09202fe6ed8ab19f5a4284d6123ea6 | Ruby | danielmachado/kermitpfc-core | /lib/kermitpfc.rb | UTF-8 | 3,592 | 3.28125 | 3 | [
"MIT"
] | permissive | require_relative 'business/adapter/twitter_adapter'
require_relative 'business/converter/twitter_converter'
require_relative 'business/converter/random_converter'
require_relative 'business/adapter/random_adapter'
require_relative 'helper/DAO'
require_relative 'helper/websocket_server'
require_relative './logging'
requ... | true |
7a50c2cd6e115d0d91014a7cb9c76f605e61f107 | Ruby | Mstaso/programming-univbasics-2-statement-repetition-with-while-nyc04-seng-ft-060120 | /lib/count_down.rb | UTF-8 | 107 | 3.140625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your code here
count=10
while count > 0 do
puts count
count -= 1
end
puts "Happy New Year!" | true |
682c09cc8d953d53e8297b9e20ac4a43dd3e62d8 | Ruby | ReprodSuplem/RTSS_SUMO | /source_code/sumoutil/sample/2018.1005.Yokohama/RealData/bin/SavsLogEntry.rb | UTF-8 | 3,073 | 2.53125 | 3 | [] | no_license | #! /usr/bin/env ruby
# coding: utf-8
## -*- mode: ruby -*-
## = Savs Log Entry class
## Author:: Anonymous3
## Version:: 0.0 2018/12/23 Anonymous3
##
## === History
## * [2018/12/23]: Create This File.
## * [YYYY/MM/DD]: add more
## == Usage
## * ...
def $LOAD_PATH.addIfNeed(path)
self.unshift(path) if(!self.include... | true |
37d9ef219a31fa0b87499868014833ecdba5f474 | Ruby | jamesaanderson/trvlr | /app/models/destination.rb | UTF-8 | 434 | 2.65625 | 3 | [] | no_license | class Destination
attr_accessor :lat, :lng, :name
def initialize(name)
@name = name
coordinates = Geocoder.coordinates(name)
@lat = coordinates.first
@lng = coordinates.last
end
def venues
FOURSQUARE_CLIENT.search_venues(near: name).venues
end
def daily_forecast
ForecastIO.foreca... | true |
85d20427013670b643e929a92566f7dd7b51f7d8 | Ruby | GlyphGryph/thetitansmarket | /lib/data/wound/all.rb | UTF-8 | 2,265 | 2.734375 | 3 | [] | no_license | # Rules for decay targets:
# An array of options. Each option will be attempted in turn.
# Difficulty determines the odds of failing to achieve this goal. A difficulty of zero or a difficulty not set always suceeds.
# If no option succeeds, or an option with no id, the wound decays to nothing.
# An option with no messa... | true |
5977ccac2fd395a418435b7311245eac3df30783 | Ruby | hgodinot/hgodinot-Launch_School | /RB_challenges_new/easy/3.rb | UTF-8 | 744 | 4.0625 | 4 | [] | no_license | class RomanNumeral
ROMANS = { 0 => ["I", "V", "X"], 1 => ["X", "L", "C"], 2 => ["C", "D", "M"], 3 => ["M"]}
def initialize(num)
@num = num
raise ArgumentError.new "Number must be an integer between 1 and 3000" unless valid?
end
def to_roman
array = @num.digits
array.map.with_index { |x, idx| d... | true |
ce5491e13799543784c41e03f28a5fab527dcecb | Ruby | caj/vindinium | /src/tile_creator.rb | UTF-8 | 377 | 2.96875 | 3 | [
"MIT"
] | permissive | class TileCreator
class << self
def create str, x=0, y=0
case str
when /( )/ then OpenTile.new $1, x, y
when /(@[1234])/ then OpenTile.new $1, x, y
when /(##)/ then WallTile.new $1, x, y
when /(\$[\-1234])/ then MineTile.new $1, x, y
when /(\[\])/ then TavernTile.new $1, x, y
... | true |
a1a8d24a22f993345d1cef23f49321c4a72bc260 | Ruby | byronanderson/confinder | /bin/fetcher | UTF-8 | 618 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'redis'
require 'redis-queue'
require_relative '../lib/confinder/fetcher'
def fetch_queue
@fetch_queue ||= Redis::Queue.new('waiting', 'processing', redis: redis)
end
def output_queue
@output_queue ||= Redis::Queue.new('waiting_on_writer', 'processing_in_writer', redis: redis)
end
de... | true |
68bdfa478f885d6bb5f6e7ea66366992e19a557c | Ruby | QPC-WORLDWIDE/tem_ruby | /lib/tem/keys/key.rb | UTF-8 | 1,486 | 2.953125 | 3 | [
"MIT"
] | permissive | # Superclass for Ruby implementations of the TEM's key operations.
#
# Author:: Victor Costan
# Copyright:: Copyright (C) 2009 Massachusetts Institute of Technology
# License:: MIT
# Base class for the TEM keys.
#
# This class consists of stubs describing the interface implemented by
# subclasses.
class Tem::Key
# ... | true |
05d81e4a4df176de222fac10ebc527551e26ae0c | Ruby | ducktyper/polyglot-fun | /ruby/001_fibonacci_sequence.rb | UTF-8 | 227 | 3.375 | 3 | [] | no_license | class Fibonacci
def calculate index
return index if index == 0 || index == 1
if index < 0
calculate(index + 2) - calculate(index + 1)
else
calculate(index - 2) + calculate(index - 1)
end
end
end
| true |
354463590a0521de1d249f88895536f1e4c015af | Ruby | shu0000883/testreport1 | /tutorial1/whiletest.rb | UTF-8 | 35 | 2.671875 | 3 | [] | no_license | i=0
while i < 10
puts i
i += 1
end | true |
ec3f43fa729225e5f9ccc46bfad17a659ed5abaf | Ruby | jmichlitsch/war_or_peace | /lib/game.rb | UTF-8 | 2,475 | 4 | 4 | [] | no_license | require './lib/card'
require './lib/deck'
require './lib/player'
require './lib/turn'
def make_deck
shuffled_deck = []
suits = [:diamond, :heart, :spade, :club]
#Use to_a() to use all numbers in given range
value = (2..14).to_a
suits.collect do |suit|
value.collect do |num|
if num > 1 && num... | true |
3b0abb337d3f449565701af348baac213cc42732 | Ruby | eduardopoleo/algorithm_1 | /week_4/scc_dfs.rb | UTF-8 | 1,624 | 3.53125 | 4 | [] | no_license | # Get a stack of vertices ordered by dfs_topological_sort
# Reverses the graph
# Clear the visited bolean
# Pops the elements from the stack and uses the dfs_visit t
require 'pry'
require_relative './graph'
$scc = []
$all_scc = []
$sort = []
class DfsGraph < Graph
def dfs_topological_so... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.