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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9d1844a88afe9055b959e09354a7ea514c1f0faa | Ruby | RhadooPopescu/RubyStatePattern | /observer.rb | UTF-8 | 789 | 3.734375 | 4 | [] | no_license | # == Situation ==
# You are a developer in a large international organisation and have been
# approached by the head of human resources.
# The current system is great (see below), but when you change an employee's
# record only payroll get to know about it. HR need to know about it too!
# == Requirement ==
# Upda... | true |
f6fa728fa4de57de7ff7508e2d314af8eed6a2d3 | Ruby | zlotnika/gene-expressions | /app/models/probeset.rb | UTF-8 | 1,057 | 2.78125 | 3 | [] | no_license | class Probeset < ActiveRecord::Base
# attr_accessible :probeset_id
validates :number, uniqueness: true, presence: true
validates :gene_id, numericality: true, allow_nil: true
belongs_to :gene
has_many :expressions #LJ
def find_expression(body_part_id)
ex = self.expressions.where("tissue_id = #{body_pa... | true |
a8c355299523f0853d1b9b4dc6416eeaf59977b1 | Ruby | snltd/wavefront-sdk | /lib/wavefront-sdk/support/parse_time.rb | UTF-8 | 1,261 | 3 | 3 | [
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
require 'time'
module Wavefront
#
# Parse various times into integers. This class is not for direct
# consumption: it's used by the mixins parse_time method, which
# does all the type sanity stuff.
#
class ParseTime
attr_reader :t, :ms
# param t [Numeric] a timestamp... | true |
be32265369c8f3fac22875fc43b97af2ac897a03 | Ruby | yzlin/Omazing | /Rakefile | UTF-8 | 818 | 2.8125 | 3 | [
"MIT"
] | permissive | class String
def self.colorize(text, color_code)
"\e[#{color_code}m#{text}\e[0m"
end
def red
self.class.colorize(self, 31)
end
def green
self.class.colorize(self, 32)
end
end
desc 'Run the tests'
task :test do
verbose = ENV['VERBOSE']
ret = test_scheme('Omazing', 'Omazing', verbose)
pu... | true |
55465fb3fe544374471aaef2adf2d5079c1a625f | Ruby | LHJE/tech_challenges | /find_the_odd_int/lib/odd_int.rb | UTF-8 | 143 | 2.859375 | 3 | [] | no_license | class OddInt
def find_it(array)
array.sort.find do |unit|
if array.count(unit) % 2 == 1
unit
end
end
end
end
| true |
9bd2329ca4c352185141133940799a447b1ea682 | Ruby | jferoman/flowers | /app/models/block_color_flower.rb | UTF-8 | 2,550 | 2.578125 | 3 | [] | no_license | class BlockColorFlower < ApplicationRecord
validates :usage, inclusion: { in: [ true, false ] }
validates :block_id, uniqueness: { scope: [:flower_id, :color_id] }
belongs_to :block
belongs_to :flower
belongs_to :color
class << self
def import file_path
blocks_color_flowers = []
errors = ... | true |
42fc979546bf070a5751f390f64c6001ee95c85c | Ruby | apfeltee/siteget | /sget.rb | UTF-8 | 9,487 | 2.71875 | 3 | [] | no_license | #!/usr/bin/ruby
require "uri"
require "json"
require "yaml"
require "digest"
require "fileutils"
require "optparse"
require "http"
require "nokogiri"
require "trollop"
SGET_DEFAULTS = {
useragent: "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.80 Safari/537.36",
}
... | true |
935d0a8d2641dfa165cef04d384584f0758d50a9 | Ruby | buzzamus/jalapeno | /lib/jalapeno/musics.rb | UTF-8 | 679 | 3.140625 | 3 | [] | no_license | module Musics
quotes = ["I hurt myself today to see if I still feel. I focus on the pain. The only thing that's real",
"If there's a bustle in your hedgerow, Don't be alarmed now, It's just a spring clean for the May Queen",
"Nothing's gonna change my world", "The world is a game to be played"... | true |
9ede2be3f0d2e8d73e8bf646eac85bff785b4040 | Ruby | Raphael-dln/THP-Ruby | /exo_05.rb | UTF-8 | 1,964 | 3.78125 | 4 | [] | no_license | # Affiche "On va compter le nombre d'heures de travail à THP"
puts "On va compter le nombre d'heures de travail à THP"
# Va afficher travail : 550 (multiplication de 10 heures, 5 jours et 11 semaines)
puts "Travail : #{10 * 5 * 11}"
# Affiche ce qui est entre "" + Multiplication du précédent nombre par 60 pour afficher... | true |
b8b489db9d86accb5ee7713bffa03cae1f6d76f1 | Ruby | taisukef/micro_mruby_for_lpc1114 | /for2.0/blink5.rb | UTF-8 | 47 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | loop do
a = :puts
puts -1000
#break
end
| true |
f3ffb0daa39a6b271421d4e8b06ac69b9d460c7b | Ruby | esimonian/codeexamples | /ruby1.rb | UTF-8 | 1,592 | 3.9375 | 4 | [] | no_license | # Determine if a sentence is a pangram
class Pangram
VERSION = 1
def self.is_pangram?(str)
ans = ['a'..'z'] - str.downcase.chars
ans.empty?
end
end
# Find the difference between the sum of the squares
# and the square of the sums of the first N natural numbers
class Squares
VERSION = 2
def initial... | true |
700c22632d38d4584defd844c22454212ab4ff83 | Ruby | niorio/Chess | /lib/computer_player.rb | UTF-8 | 2,194 | 3.390625 | 3 | [] | no_license | class ComputerPlayer
attr_reader :color
def initialize(board)
@color = :b
@board = board
end
def play_turn
@possible = possible_moves
return checkmate_move unless checkmate_move.nil?
return check_moves.sample unless check_moves.empty?
return good_trade.sample unless good_trade.empty?... | true |
197c7b84fe0149a4a730b433ddd1f0f91aca1a79 | Ruby | reedstonefood/flamme_rubuge | /lib/flamme_rubuge/race.rb | UTF-8 | 2,057 | 3.265625 | 3 | [] | no_license | module FlammeRubuge
# A race, or game
class Race
class InvalidPlayerDetailsError < StandardError; end
attr_reader :players, :track, :state
# players_details looks like {name: "Bob", color: :red, cyclists: [SPRINTER, ROLLER]}
# The elements of cyclist array must be part of Cyclist.TYPES
def init... | true |
2f37816f8559dc1a5bcd377436fe3af5dec4f40d | Ruby | adamhundley/black_thursday | /lib/invoice_item.rb | UTF-8 | 716 | 2.890625 | 3 | [] | no_license | class InvoiceItem
attr_reader :invoice_item
attr_accessor :item, :invoice
def inspect
"#<#{self.class}>"
end
def initialize(invoice_item)
@invoice_item = invoice_item
end
def item_id
invoice_item[:item_id]
end
def id
invoice_item[:id].to_i
end
def invoice_id
invoice_item[:... | true |
3ca950ac8b805ff2477b654d93c5721dbfd29e65 | Ruby | Leandro01832/ruby | /12_07_2019aula16/Abstrata.rb | UTF-8 | 223 | 2.671875 | 3 | [] | no_license | class Abstrata
def initialize
raise "classe não pode ser instanciada, somente herdada, classe abstrata"
end
def teste1
raise "não implementada"
end
def teste2
"este é um teste 2"
end
end | true |
71a15a68bc156336dde700eedc2b0ac01e7f98d2 | Ruby | anandu/Test | /t3_check.rb | UTF-8 | 366 | 2.703125 | 3 | [] | no_license | #!/usr/bin/ruby -w
unless ARGV.length == 2
puts "Usage: ./check.rb value2reach startinputl"
exit
end
count = ARGV[0].to_i
count1 = ARGV[1].to_i
t = 0
#puts count
#puts count1
while count != count1
t = t + 1
count = count + t
puts count
if count != count1
t += 1
count -= t
puts count
end
en... | true |
757d5136a331873cbffba1d6d740b1fd52e6a22b | Ruby | maritimememory/kwk-l1-ruby-2-meal-choice-lab-kwk-students-l1-stl-061818 | /meal_choice.rb | UTF-8 | 654 | 4.34375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Here's an example of a 'snacks' method that returns the meal choice passed in to it and defaults to "cheetos" if nothing is passed in.
def snacks(food="Cheetos")
"Any time, is the right time for #{food}!"
end
# Define breakfast, lunch and dinner methods that return the meal choice passed into them. If nothing is p... | true |
f8cccdf6f9dff766d288fdbbfb5620ac0e9e3ca8 | Ruby | akchalasani1/myruby | /examples/RubyMonk/sum_of_cubes.rb | UTF-8 | 170 | 3.8125 | 4 | [] | no_license | # Returns the sum of cubes for a given Range a through b.
def sum_of_cubes(a, b)
(a..b).inject(0) { |sum, x| sum += (x*x*x) }
end
test = sum_of_cubes(3, 5)
puts test
| true |
4fbb852663eb999a4497b6137f6429456dcf45ca | Ruby | Kennethjk3/2.3-Minitest_ATM | /minitest.rb | UTF-8 | 1,147 | 2.578125 | 3 | [] | no_license | require 'minitest/autorun'
require '.'
require './User.rb'
class TestAtm < MiniTest::Unit::TestCase
def setup
@user= User.new
@atm= ATM.new
end
def self.input
gets.chomp
end
def test_auth
assert_equal true, @user.authenticate('Ken', 4567)
end
def test_not_auth
assert_equal true, @u... | true |
92b0151595b161a9405f3de1209709f6891dbee2 | Ruby | Bishoy-Samwel/Telegram-Bot | /lib/bot_logic.rb | UTF-8 | 1,553 | 2.609375 | 3 | [
"MIT"
] | permissive | require_relative './app_config'
require_relative './reply'
require 'telegram/bot'
reply = Reply.new
# rubocop: disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength
define_method :respond do |message, id, first_name = ''|
unless message.nil?
if message['start'] || message['Hi']... | true |
bf78f2d213e8e40e32adaaedb7cedbc91ad75b9f | Ruby | kevino2/Bear-River-Fish | /pet_shop_start_point/customer.rb | UTF-8 | 510 | 3.75 | 4 | [] | no_license | class Customer
attr_accessor :name, :cash
def initialize (name, cash)
@name = name
@cash = cash
@pets = []
end
# can use .size or .length
def pet_count
return @pets.count
end
def add_pet(new_pet)
return @pets.push(new_pet)
end
def get_total_of_pets()
total = 0
for pet in @pets
tot... | true |
57dc41249f734492cc8567166563d0fe6bcb16ca | Ruby | t5krishn/ruby-2-player-game | /helpers.rb | UTF-8 | 306 | 3.5 | 4 | [] | no_license |
def getQnA()
operations = ['plus', 'subtract']
num1 = rand(10) + 1
num2 = rand(10) + 1
op = rand(2)
ans = 0
if (op == 0)
ans = num1 + num2
else
ans = num1 - num2
end
question = {q: "#{num1} #{operations[op]} #{num2}", a: ans}
return question
end
| true |
3aee0b26b0f5d48931222c3dcfa0bab1b0784617 | Ruby | chalt0319/looping-loop-v-000 | /looping.rb | UTF-8 | 61 | 2.6875 | 3 | [] | no_license | def looping
loop do
puts "Wingardium Leviosa"
end
end
looping
| true |
18000a69efd5a7dcd13a07c69e5211d7691d69f9 | Ruby | kmic1986/Ruby-Foundations-More-Topics | /Challenges/04 Advanced 1/simple_cipher.rb | UTF-8 | 950 | 3.609375 | 4 | [] | no_license | # 97 - 122
class Cipher
attr_reader :key
def initialize(k=make_key)
@key = k
raise ArgumentError if k == ''
k.chars.each do |e|
if e.ord < 97 || e.ord > 122
raise ArgumentError
end
end
end
def encode(string)
result = ''
string.chars.each_with_index do |c, i|
... | true |
06a7243f543ec1d7bdb26afe07c1fc97c558cf1c | Ruby | acannie/progate | /ruby/ruby_study_1/page18/index.rb | UTF-8 | 282 | 3.375 | 3 | [
"MIT"
] | permissive | number = 48
# 条件分岐を作成してください
if number % 3 == 0 && number % 5 == 0
puts "15の倍数です"
elsif number % 5 == 0
puts "5の倍数です"
elsif number % 3 == 0
puts "3の倍数です"
else
puts "3の倍数でも5の倍数でもありません"
end
| true |
02a5ff9f01aae689ec950bd540eb32b12d4e4646 | Ruby | lexus2727/ruby-intro-to-arrays-lab-online-web-prework | /lib/intro_to_arrays.rb | UTF-8 | 1,508 | 4.21875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # instantiate_new_array
def instantiate_new_array
ary = Array.new # => []
end
# indexing to access specific array elements
def array_with_two_elements
ary = Array.new
Array.new(2)
end
# retrieving the first element from the Array
def first_element(array)
taylor_swift = ["Welcome to New York", "Blank Space"... | true |
fe439c9b0957768643e59a695fdec028af81f70f | Ruby | jflohre/goals | /app/models/quote.rb | UTF-8 | 490 | 2.578125 | 3 | [] | no_license | # == Schema Information
#
# Table name: quotes
#
# id :integer not null, primary key
# description :string(255)
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Quote < ActiveRecord::Base
attr_accessible :description, :name
... | true |
f85759101097734efe8a59fab84ce10407d2a3fa | Ruby | guymorita/ruby_practice | /fizzbuzz.rb | UTF-8 | 2,499 | 4.21875 | 4 | [] | no_license | def reverse_each_word(sentence)
words = sentence.split(' ')
y = []
words.each { |x|
y << x.reverse
}
y.join(" ")
end
def square(number)
number*number
end
def cube(number)
square(number)*number
end
#print out all # between 1-100, if mult 3 fizz, if mult 5 buzz, if mult 10 fizzbuzz
def fizzbuzz
y = (1..100... | true |
4d1380d2e48307e3f12b23df461338fe4aca4d57 | Ruby | Chris-Manna/Cool-Code | /RocksPapersScissors.rb | UTF-8 | 220 | 3.0625 | 3 | [] | no_license | class Display
ARR = [:ROCKS, :PAPERS, :SCISSORS]
def initialize(first_entry,sec_entry = rand(2).round)
@entry = entry.upcase.to_sym
@sec_entry = sec_entry
end
def display_winner
end
def entry
end
end
| true |
e15c7bc85b16e943c39a06d6f2911ed001367bd1 | Ruby | zsy056/solutions | /leetcode/240-search-a-2d-matrix-ii.rb | UTF-8 | 319 | 3.375 | 3 | [] | no_license | # @param {Integer[][]} matrix
# @param {Integer} target
# @return {Boolean}
def search_matrix(matrix, target)
i = 0
j = matrix[0].size - 1
while i < matrix.size and j >= 0
if matrix[i][j] == target
return true
elsif matrix[i][j] < target
i += 1
else
j -= 1
end
end
false
end
| true |
225baed57aea3dcf7976b50d996c908e316e3129 | Ruby | murex/murex-coding-dojo | /Beirut/2015/2015-11-25-PowerDigitSum/power_digit_sum.rb | UTF-8 | 175 | 3.296875 | 3 | [
"MIT"
] | permissive | class PowerDigitSum
def compute(power)
sum=0
to_power = (2**power).to_s
digits = to_power.split("").each do |i|
sum = sum+ i.to_i
end
sum
end
end | true |
b2df4954a52c593adc38f18d559b5ec25d4b34fb | Ruby | thomasfrl/thp_jeudi | /exo_09.rb | UTF-8 | 211 | 3.46875 | 3 | [] | no_license |
puts "Bonjour, c'est quoi ton prénom ?"
print "> "
user_name = gets.chomp
puts "Et c'est quoi ton nom de famille ?"
print "> "
user_familyName = gets.chomp
puts "Bonjour, #{user_name} #{user_familyName} !"
| true |
b19809a0f25269f22175eb958fb5759aff785924 | Ruby | Renestl/AAO | /1 Intro/11_hashes/hashes2.rb | UTF-8 | 686 | 4.21875 | 4 | [] | no_license | # Hash Methods
# .length
# .has_key?(k)
# .has_value?(v)
# .keys
# .values
dog = {
"name" => "Fido",
"color" => "black",
"age" => 3,
"isHungry" => true,
"enemies" => ["squirrel"]
}
# puts dog
# puts dog.length
# dog["name"] = "Spot"
# puts dog
# !!Add to array after the fact
# dog["location"] = "MO"
# puts dog... | true |
203448feaa0daa6f6998f581b5e01b7736d4167f | Ruby | eldemonstro/AdventOfCode2019 | /day2/part_2.rb | UTF-8 | 721 | 3.390625 | 3 | [] | no_license | # frozen_string_literal: true
text = File.open(__dir__ + '/input.txt').read
input_frozen = text.chomp.split(',').map(&:to_i).freeze
nouns = (0..99)
verbs = (0..99)
stop = false
nouns.each do |noun|
verbs.each do |verb|
input = input_frozen.dup
input[1] = noun
input[2] = verb
input.each_slice(4) ... | true |
318506528a72687c8977394b019e44daed45336e | Ruby | davidbalbert/ruby_games | /001/original_spec/example_entry.rb | UTF-8 | 389 | 2.859375 | 3 | [] | no_license | class IntegerArray
def self.intersection( array_1, array_2 )
array_1 & array_2
end
end
class StateNameMixer
def self.mix_it_up( string_set )
[ [ 'foo', 'fee' ], [ 'fee', 'foo' ] ]
end
end
class CoinChanger
def self.change_me( dollar_string )
{ :pennies => 567 }
end
end
class RomanNu... | true |
77a1dfd9d1130fa20cbb91bc5d8a0f52e53856e9 | Ruby | DevWarr/rails-mini-course-sprint1-mod1-student--starter | /language_screening.rb | UTF-8 | 204 | 3.078125 | 3 | [] | no_license | def language_screening(people, language)
return people.select do |person|
lang_arr = person[:languages].select { |lang| lang.downcase == language.downcase}
!lang_arr.empty?
end
end | true |
898a434c1ea67061b07050abd0d16261c6a660c4 | Ruby | debjohnson33/ruby-music-library-cli-v-000 | /lib/music_importer.rb | UTF-8 | 281 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path
def initialize(path)
@path = path
end
def files
@files ||= Dir.glob("#{path}/*.mp3").collect{ |file| file.gsub("#{path}/", "")}.sort
end
def import
files.each do |file_name|
Song.new_from_filename(file_name)
end
end
end | true |
48fd218992e017ed9c20a206ca702e0f0823e1ed | Ruby | driv3r/strainer | /lib/strainer/cli.rb | UTF-8 | 1,571 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require 'optparse'
module Strainer
class CLI
def self.run(*args)
parse_options(*args)
if @cookbooks.empty?
puts Color.red { 'ERROR: You did not specify any cookbooks!' }
else
@sandbox = Strainer::Sandbox.new(@cookbooks, @options)
@runner = Strainer::Runner.new(@sandbox,... | true |
c882b6f407b602844122d0f2e59dd59483a09f8c | Ruby | forgedvision/gmat-cards | /lib/tools/terms/google-terms.rb | UTF-8 | 1,453 | 3.265625 | 3 | [] | no_license | # Turn a list of terms into a seeds.rb file for populating the DB
# Steps
# 1. read the tab separated list file into an array. Terms are \n separated.
# 2. randomize array.
# 3. assign groups - 10 groups.
# 4. start writing each element of the array into a seeds.rb file. Probably going to be pretty large.
## Card.de... | true |
ba3e9804ee9b46d0beffbee5325fe5ef44a5f559 | Ruby | merlos/gtfs-api | /lib/gtfs_api/io/models/concerns/gtfsable.rb | UTF-8 | 13,121 | 2.734375 | 3 | [
"MIT"
] | permissive | # The MIT License (MIT)
#
# Copyright (c) 2016 Juan M. Merlos, panatrans.org
#
# 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
# t... | true |
c96abfd1f9b5c7aad593d2bba863be3a2609deef | Ruby | yorktronic/ruby | /prep-work-master/test-first-ruby-master/lib/11_dictionary.rb | UTF-8 | 605 | 3.53125 | 4 | [] | no_license | class Dictionary
def initialize(entries = {})
@ents = entries
end
def entries
@ents
end
def add(ent)
@ents[ent.keys[0]] = ent[ent.keys[0]] if ent.is_a?(Hash)
@ents[ent] = nil if ent.is_a?(String)
end
def keywords
@ents.keys.sort
end
def include?(word)
@ents.has_key?(word)
end
def find(word)
... | true |
38f7f3c8055caa54cd386e3858b33a854bc0d8d5 | Ruby | latentflip/ice_cube | /lib/ice_cube/time_util.rb | UTF-8 | 1,359 | 3.125 | 3 | [
"MIT"
] | permissive | module TimeUtil
LeapYearMonthDays = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
CommonYearMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
# this method exists because ActiveSupport will serialize
# TimeWithZone's in collections in UTC time instead of
# their local time. if +time+ is a T... | true |
1195480b0be3e625ed06ca0520fa9eafd7a60985 | Ruby | truonghuyen2110/iTMS-Tester-Advance-Automation | /btvn_day2/tc7.rb | UTF-8 | 1,439 | 2.59375 | 3 | [] | no_license | require'selenium-webdriver'
#1. Launch browser of your choice say., Firefox, chrome etc.
driver = Selenium::WebDriver.for:chrome
#2. Open this URL - https://itmscoaching.herokuapp.com/form
driver.get'https://itmscoaching.herokuapp.com/form'
#3. Maximize or set size of browser window.
driver.manage.window.maximize
puts ... | true |
ad44c4611a1a60229dcbd9ba1d1a9b342e585cb9 | Ruby | jlusenhop-mchs/medibot-essette | /auth_number_match/update_amisys_auth_number.rb | UTF-8 | 1,041 | 2.609375 | 3 | [] | no_license | require 'spreadsheet'
amisys_results_spreadsheet = ARGV[0]
new_feature_file = File.open("#{amisys_results_spreadsheet}.feature","w")
line_count = 0
old_feature_file = File.open("update_amisys_auth_number_template.feature", "r") do |f|
f.each_line do |line|
line_count += 1
case line_count
when 9
li... | true |
9e71cdfaf28d0ffa58fad0a065bf51f71c75e35d | Ruby | Lindseyls/betsy | /app/models/order.rb | UTF-8 | 1,017 | 2.546875 | 3 | [] | no_license | class Order < ApplicationRecord
STATUS = %w(pending paid complete cancelled)
has_many :order_items, dependent: :destroy
with_options if: :checking_out? do |order|
order.validates :status, presence: true, inclusion: { in: STATUS }
order.validates :email, presence: true
order.validates :mail_adr, presence: tru... | true |
66a1ef517974bffeeb310b11193ca898a67cc8ab | Ruby | ClementPain/Jour-7---Ruby-exercices | /exo_09.rb | UTF-8 | 183 | 3.265625 | 3 | [] | no_license | puts "Quel est ton prénom ?"
print "> "
user_firstname=gets.chomp
puts "Quel est ton nom ?"
print "> "
user_lastname=gets.chomp
puts "Bonjour, #{user_firstname} #{user_lastname} !" | true |
892222bc38c2c166c66f8affe76d68a9c16aedb7 | Ruby | sgonyea/riak-pbclient | /lib/riakpb/content.rb | UTF-8 | 10,014 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | require 'riakpb'
require 'set'
module Riakpb
# Parent class of all object types supported by ripple. {Riakpb::RObject} represents
# the data and metadata stored in a bucket/key pair in the Riakpb database.
class Content
include Util::Translation
include Util::MessageCode
# @return [Key] the key in w... | true |
da4184cb85f65a56839c6cb353a34673375b5ea2 | Ruby | zackfern/adventofcode-2020 | /day4/part_2.rb | UTF-8 | 2,238 | 3.65625 | 4 | [] | no_license | #!/usr/bin/env ruby
#
# The problem: You've got a batch list of "passports"
# Scan over the file and see how many of them are valid.
#
# To be valid, a passport needs the following fields:
# - byr
# - iyr
# - eyr
# - hgt
# - hcl
# - ecl
# - pid
# - cid
# The passport must have all fields, but `cid` is o... | true |
18e24d85488f1b022025dec4ed65475e93cbda03 | Ruby | balalnaeem/launch-school-101-lessons | /exercises/easy_4/8.rb | UTF-8 | 1,433 | 4.75 | 5 | [] | no_license | =begin
Write a method that takes a String of digits, and returns the appropriate number as an integer. The String may have a leading + or - sign; if the first character is a +, your method should return a positive number; if it is a -, your method should return a negative number. If no sign is given, you should return... | true |
8572ccb5b36e985df4bdb19113b35c53856e43be | Ruby | jedld/natural_20 | /lib/natural_20/cli/builder/rogue_builder.rb | UTF-8 | 1,932 | 2.515625 | 3 | [
"MIT"
] | permissive | module Natural20::RogueBuilder
def rogue_builder(_build_values)
@class_values ||= {
attributes: [],
saving_throw_proficiencies: %w[dexterity intelligence],
equipped: %w[leather_armor dagger dagger],
inventory: [],
tools: ['thieves_tools'],
expertise: []
}
@class_values... | true |
6c8f3441a11d571e227431ae3b0d1e71fdddf7f8 | Ruby | rtyenriques/oo-banking-onl01-seng-pt-050420 | /lib/bank_account.rb | UTF-8 | 389 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class BankAccount
attr_reader :name
attr_accessor :balance, :status
def initialize(name)
@name = name
@balance = 1000
@status = "open"
end
def deposit(money)
@balance += money
end
def display_balance
"Your balance is $#{@balance}."
end
def valid?
if @status == "open" && @balance > 0
true
else
... | true |
dfd13c4cf24eb54f5714df8c5be80c61a5c13b31 | Ruby | Tasoxanadu/Ruby_test | /furigana_ruby/test0.rb | UTF-8 | 554 | 3.53125 | 4 | [] | no_license | class Communication
def greet
answer = gets.chomp
if answer == "Hello"
puts "「Hello」"
else
puts "「......」"
end
end
end
communication1 = Communication.new
communication1.greet
class Workplacecommunication < Communication
def greeting
puts "ここは私の職場で合っていますか?はい/いいえ?"
answer = gets... | true |
64782e78b0a7dc68b55b99b0431b7a59d5abf75b | Ruby | pradeep-elangovan91/bitmap_editor | /spec/bitmap_editor_spec.rb | UTF-8 | 1,141 | 2.6875 | 3 | [] | no_license | require './lib/bitmap_editor'
describe BitmapEditor do
context "executing the bitmap editor run function" do
bme = BitmapEditor.new
it "should fail when an invalid file is provided" do
expect { bme.run "invalidfile.txt" }.to output("please provide correct file\n").to_stdout
end
it "should conti... | true |
d3fd0518a88425240db3f761f605f6be2ffd6feb | Ruby | scottmacphersonmusic/FizzBuzz | /spec/arbitrary_spec.rb | UTF-8 | 1,046 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
require 'arbitrary'
describe "arb_fizz" do
it "can handle the standard" do
fizz = arb_fizz 15, 3 => "Fizz", 5 => "Buzz"
fizz[15].must_equal "FizzBuzz"
fizz[5].must_equal "Buzz"
fizz[3].must_equal "Fizz"
fizz[8].must_equal "8"
fizz[0].must_equal "0"
end
it "meets cli... | true |
2e8bb5e4435ea2d44776ffac1e0a3f297211ea71 | Ruby | edmundwright/appacademy-prep | /test-first-ruby/lib/08_book_titles.rb | UTF-8 | 513 | 3.515625 | 4 | [] | no_license | class Book
def initialize
@title = nil
end
def titleize(str)
little_words = %w{a an and as at but by en for if in nor of on or per the to
vs over}
transformed_words = str.split(" ").each_with_index.map do |word, index|
if little_words.include?(word) && index!=0
wo... | true |
6c389285bb5978866d7e1a488b2c24d36862ac4b | Ruby | Vertalab/deplobotre | /lib/trello_release_bot/git_logger.rb | UTF-8 | 470 | 2.5625 | 3 | [] | no_license | module TrelloReleaseBot
module GitLogger
EOC = "\n\n|EOC|\n\n".freeze
# @param [String] branch name
# @param [String] git revision rage eg: 'd9c41e946832..cf2707e17ff2dd'
def self.commits(repo_path, revission_rage)
raw_logs = `cd #{repo_path} && git log #{revission_rage} --format="%H %B#{EOC}"`... | true |
3832446e6715064bcdde2dea5e07f381b86b01d2 | Ruby | NateGiesing/sorting_suite | /insertion_sort.rb | UTF-8 | 704 | 3.28125 | 3 | [] | no_license | def insertion_sort(array)
sort = [array[0]]
#require 'pry'; binding.pry
sorted = []
array.delete_at(0)
array.each do |i|
#for i in array
sort_index = 0
while sort_index < sort.length
if i <= sort[sort_index]
sort.insert(sort_index,i)
b... | true |
e92eb9ddbc87d26ce81d5019f1481c7da40be562 | Ruby | Su0414/ruby-objects-has-many-through-lab-v-000 | /lib/doctor.rb | UTF-8 | 413 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Doctor
attr_accessor :name, :appointments
def initialize(name)
@name = name
@appointments = []
end
def add_appointment(appointment_instance)
@appointments << appointment_instance
appointment_instance.doctor = self
end
def appointments
@appointments
end
de... | true |
cbd785db16695272af3f027866e50f247cd7a643 | Ruby | paul-r-ml/funkr | /lib/funkr/types/container.rb | UTF-8 | 504 | 2.96875 | 3 | [] | no_license | require 'funkr/categories'
module Funkr
module Types
class Container
include Funkr::Categories
def initialize(value)
@value = value
end
def unbox; @value; end
def to_s; format("{- %s -}", @value.to_s); end
include Functor
def map(&block)
self.class.... | true |
a2d5313760120cfd443343fccae792f77c3116f8 | Ruby | Gloumix/my_super_test_project | /my_super_test_project/lib/00_hello.rb | UTF-8 | 84 | 2.984375 | 3 | [] | no_license | def hello
return "Hello!"
end
def greet(machin)
return "Hello, #{machin}!"
end
| true |
60980e59e008262dcab09802cda9faf1bdab3b18 | Ruby | kane7890/ruby-music-library-cli-online-web-ft-051319 | /lib/musiclibrarycontroller.rb | UTF-8 | 3,645 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MusicLibraryController
def initialize(path = './db/mp3s')
# binding.pry
music_importer = MusicImporter.new(path)
music_importer.import
end
def call
puts "Welcome to your music library!"
puts "To list all of your songs, enter 'list songs'."
puts ... | true |
b43c09cd7e3b103ab5387451ff1bedaeeb2afa3d | Ruby | lpmiller/looping-break-gets-001-prework-web | /levitation_quiz.rb | UTF-8 | 185 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def levitation_quiz
loop do
puts "What is the spell that enacts levitation?"
answer = gets.chomp
break if answer == "Wingardium Leviosa"
end
puts "You passed the quiz!"
end
| true |
8b64075b256b3ac318dfbc84b1102cd47e1b8e3b | Ruby | maxckelly/codeAcademyBootCamp | /week-01/day-2-GIT-Ruby.rb | UTF-8 | 6,116 | 4.4375 | 4 | [] | no_license | # Git cloning - To clone a repo you must get the repo https//:
# However once you have SSH setup you should always use that.
# git remote -v - This checks if you're connected to the repo
# fetch and pull are the same words
# -- How to setup SSH on your computer --
# Step One: Open a tab for - https://github.com/... | true |
4e76652ea95a02c4ca04c9171a8aa48164c9fb88 | Ruby | DoiTaiki/AtCoder_answers_by_ruby | /ARC_126/a.rb | UTF-8 | 1,880 | 2.9375 | 3 | [] | no_license | number_of_test_case = gets.chomp.to_i
test_cases = []
number_of_test_case.times do
test_cases << gets.chomp.split.map(&:to_i)
end
number_of_sticks = []
i = 0
while i < number_of_test_case
number_of_stick = 0
comparison_with_N3_and_N4_result = test_cases[i][1] <=> test_cases[i][2] * 2
comparison_with_N2_and_N3_... | true |
bf1a1ca639c5a610f9c4fddd228f0fca0273f37c | Ruby | rhannequin/old-space-api | /sinatra/models/Parent.rb | UTF-8 | 825 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | require 'open-uri'
require 'nokogiri'
class Parent
attr_accessor :uri
attr_accessor :config
def initialize(config)
@config = config
end
def load
documents = []
@urls.each do |uri|
file = get_content(uri)
documents << Nokogiri::HTML(file.read.gsub(" ", ' '))
end
document... | true |
62941094ed63af990df52d109e6bfd0e29857847 | Ruby | diego-aslz/report_logic | /spec/app/my_report.rb | UTF-8 | 671 | 2.765625 | 3 | [] | no_license | Record = Struct.new(:id, :name)
FIRST_DECORATOR = ->(value) { value + 3 }
SECOND_DECORATOR = ->(value) { value / 2 }
class MyReport < ReportLogic::Base
session :header do
field 'ID'
field 'Name'
end
collection_session :rows do |record|
value record.id
value record.name
end
def my_own_rows
... | true |
ca01e5b66128a74d45d580f2d676603e5b69b609 | Ruby | waco/geocoder_ruby | /geocoder.rb | UTF-8 | 1,928 | 3.234375 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'net/http'
require 'cgi'
require 'json'
require 'ostruct'
class Geocoder
BASE_URL = "http://maps.google.com/maps/api/geocode/json"
# Google Geocoder APIへのリクエスト結果をパースして受け取る
# jsonのみでxmlは対応していません
#
# - parameters: Geocoder APIで利用できるパラメータをハッシュで指定します
# 詳しくは次を参照 htt... | true |
104829aa2a167cf8cfe8e10035ef457e4db6d3b0 | Ruby | benjaminsunderland/TicTacToe | /lib/board.rb | UTF-8 | 1,208 | 3.734375 | 4 | [] | no_license | class Board
attr_accessor :grid, :turn
WINNING_COMBINATIONS = [[0, 1, 2], [3, 4, 5],
[0, 3, 6], [6, 7, 8],
[1, 4, 7], [2, 5, 8],
[0, 4, 8], [2, 4, 6]].freeze
def initialize
@grid = Array.new(3) { Array.new(3) { nil } }
@turn... | true |
9250ac966a5bd2e5fc8ee6baff2310fc4a85db71 | Ruby | andrewsapa/intro-ruby-book | /flow_control/exercise2.rb | UTF-8 | 479 | 4.625 | 5 | [] | no_license | # 2. Write a method that takes a string as argument. The method should return
# a new, all-caps version of the string, only if the string is longer than 10
# characters. Example: change "hello world" to "HELLO WORLD".
# (Hint: Ruby's String class has a few methods that would be helpful.
# Check the Ruby Docs!)
def... | true |
dd759a8ae7ea7bb2fc9a44778edad033d83b174b | Ruby | shawn42/chessbox | /src/behaviors/hoverable.rb | UTF-8 | 742 | 2.96875 | 3 | [] | no_license | require 'behavior'
#
# Hoverable adds callbacks for when the mouse is hovering over an actor.
# Will call actor.mouse_(enter|exit)(x,y) by default,
# but can be told what methods to call
# has_behavior :hoverable
# or
# has_behavior :hoverable => {:enter => :my_hover_method, :exit => :my_exit_method}
#
class Hoverab... | true |
1181618d877dbc1fb16a0d3e1068f78099f88fd3 | Ruby | mdeskin/project-euler-power-digit-sum-e-000 | /lib/project_euler_power_digit_sum.rb | UTF-8 | 215 | 3.390625 | 3 | [] | no_license | def power_digit_sum(x,n)
count = 0
sum = 0
product = x ** n
product_str = product.to_s
until product_str.slice(count).nil?
sum = sum + product_str.slice(count).to_i
count += 1
end
sum
end | true |
1f57aa0ab664b300339e484135b84035ddb76249 | Ruby | alf-tool/alf-core | /spec/unit/alf-types/ordering/test_reverse.rb | UTF-8 | 902 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Alf
describe Ordering, "reverse" do
subject{
ordering.reverse
}
context 'on an empty ordering' do
let(:ordering){ Ordering.new([]) }
it{ should eq(ordering) }
end
context 'on a singleton asc ordering' do
let(:ordering){ Ordering.new([[... | true |
2e02fd2eb93e42461570a8b53ac0e0047cb57440 | Ruby | alikewmk/emoji_ranking | /scripts/plot.rb | UTF-8 | 622 | 2.640625 | 3 | [] | no_license | require 'nyaplot'
x = []; y = []; theta = 0.6; a=1
File.open('2000_svm_result.txt').each_line do |line|
item = line.split(" ")
y << item[1].to_f/item[2].to_f
theta += 0.1
end
# word_count/1000 in data base
x = [16.593, 8.016, 5.863, 4.959, 4.315, 3.477, 2.958, 2.86, 2.727, 2.344]
plot = Nyaplot::Plot.new... | true |
da7d55acdd9b77e2fe58f0a8ad158336ac940903 | Ruby | Leadformance/tm4b | /spec/broadcast_spec.rb | UTF-8 | 3,376 | 2.78125 | 3 | [] | no_license | #coding : utf-8
require 'spec_helper'
describe TM4B::Broadcast do
before do
@broadcast = TM4B::Broadcast.new
@broadcast.recipients = "+1 213 555-0100"
@broadcast.originator = "tm4btest"
@broadcast.message = "hello world"
end
it "should return an encoded string if 'plain' encoding if s... | true |
7d8e90078dcaadcd58c4ee92a9bc64162969822b | Ruby | sergio-bobillier/bdd-rails-workout | /spec/features/friendships_spec.rb | UTF-8 | 3,055 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.shared_context 'A pair of users exist and one of them is logged-in' do
before do
@john = User.create!(first_name: 'John', last_name: 'Doe', email: 'john.doe@example.com', password: 'password')
@sarah = User.create!(first_name: 'Sarah', last_name: 'Joseph', email: 'sarah.joseph@ex... | true |
ad9e7545e095a66a5df0da6e985cf42ecb26a89e | Ruby | atri-konami/kyo-pro | /atcoder/abc/060/a.rb | UTF-8 | 113 | 3.359375 | 3 | [] | no_license | a,b,c = gets.chomp.split
if a[a.length-1] == b[0] && b[b.length-1] == c[0]
puts 'YES'
else
puts 'NO'
end
| true |
da638d115bdc5fe4165c239597a0c523a67e0212 | Ruby | DavidSerfaty/exos-mario | /exo_16.rb | UTF-8 | 149 | 3.546875 | 4 | [] | no_license |
puts "Quel age as-tu ?"
birth = gets.chomp.to_i
x = birth
y = 0
while y < birth
puts "Il y a #{x} ans, tu avais #{y} ans"
y += 1
x -= 1
end
| true |
a86248b3ef6dbdda6f519c70ed58456a31987a96 | Ruby | BryantWyatt/learning_the_well_grounded_rubyist | /ch10/get_matches_with_find.rb | UTF-8 | 1,008 | 3.921875 | 4 | [] | no_license | numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
puts(numbers.find{|n| n > 5})
numbers_with_nill = [1, 2, 3, nil, 4, 5, 6]
puts(numbers_with_nill.find{|n| n.nil?}) # Will always find nil regards if it succeeds or fails.
puts()
puts('Find all values in the number array greater than 5')
puts(numbers.find_all{|n| n > 5})
puts... | true |
e5e2c456102b9b686464d65b6c19c6e65c5bac17 | Ruby | kemper/queuez | /lib/queuez/initializer.rb | UTF-8 | 1,114 | 2.515625 | 3 | [
"MIT"
] | permissive | module Queuez
class Initializer
attr_reader :servers
def initialize
@servers = []
end
#TODO: doesn't make sense for client middleware to be at this level
def initialize!(config_hash)
config_hash[:queues].each do |queue_config|
@servers << build_server(queue_config)
end
... | true |
83cfa2b2073d970c5d0f0a6ed511a688cd8f9c49 | Ruby | Williamug/getting-started-with-ruby | /price.rb | UTF-8 | 603 | 4.125 | 4 | [] | no_license | def total(prices)
amount = 0
# process eacb price
prices.each do |price|
# add the current price to the total
amount += price
end
amount # return the final total
end
def refund(prices)
amount = 0
prices.each do |price|
amount -= price # refund the current price
end
amount
end
def show_discounts(pric... | true |
4b9ab9d13471ce0fff28a749f4354bac3f5406fe | Ruby | idynkydnk/connect_four | /spec/board_spec.rb | UTF-8 | 10,409 | 3.59375 | 4 | [] | no_license | require "board"
describe Board do
context "sets a 7x6 grid" do
it "sets 7 rows" do
board = Board.new
expect(board.grid.length).to be(7)
end
it "sets 6 columns inside each row" do
board = Board.new
board.grid.each do |row|
expect(row.length).to be(6)
end
end
en... | true |
23b0bdfecebb7217f00b6ea492b6e4e4bff2c969 | Ruby | purvakaranjawala/doctor_app | /config/prefix_tree.rb | UTF-8 | 618 | 3.59375 | 4 | [] | no_license | class Node
attr_reader :value, :next
attr_accessor :word
def initialize(value)
@value = value
@word = false
@next = []
end
end
class Tree
def initialize
@root = Node.new("*")
end
def add_word(word)
letters = word.chars
base = @root
letters.each { |letter| base = add_char... | true |
88062d652a422766f6b315a4e7f426cdfe1c2cc3 | Ruby | marcdif/ISE337 | /ruby/hw2/submission/treasure-hunt.rb | UTF-8 | 6,809 | 3.625 | 4 | [] | no_license | # Marc DiFilippo - 111420881
# ISE 337 HW2 Part 3
class Console
def initialize(player, narrator)
@player = player
@narrator = narrator
end
def show_room_description
@narrator.say "-----------------------------------------"
@narrator.say "You are in room #{@player.room.number}."
@player.ex... | true |
6ec3a9a18223681b62bf3379defb0ee63ba05e70 | Ruby | champagnepappi/ruby | /HeadFirstRuby/chapter7/hashtst.rb | UTF-8 | 228 | 3.328125 | 3 | [] | no_license | elements = {"O" => "Oxygen", "Na" => "Sodium"}
puts elements["O"]
puts elements["Na"]
#add value to an existing hash
elements["Ne"] = "Neon"
puts elements["Ne"]
elements.each do |element,count|
puts "#{element}:#{count}"
end
| true |
05f7048855154ea3e41572f449661727a7c89830 | Ruby | transcriptic/ups-shipping | /lib/ups_shipping/address.rb | UTF-8 | 772 | 2.625 | 3 | [] | no_license | require "nokogiri"
module Shipping
class Address
ADDRESS_TYPES = %w{residential commercial po_box}
attr_accessor :address_lines, :city, :state, :zip, :country, :type
def initialize(options={})
@address_lines = options[:address_lines]
@city = options[:city]
@state = options[:state]
... | true |
4a6248a632ab67415b00f6917b7b82bb85ed6afc | Ruby | huyettcp/project_2_crossword | /spec/models/word_spec.rb | UTF-8 | 577 | 2.59375 | 3 | [] | no_license | # require 'spec_helper'
# describe Word do
# before :each do
# @word = Word.new(name: "Beer")
# @photo = Photo.new(url: "google")
# @word.photos << @photo
# end
# describe "#name" do
# it "should return the correct word" do
# @word.name.should eq("Beer")
# end
# it "should reutu... | true |
b2651962003bebfdf8ebc2063915b4c3d92f2048 | Ruby | Infogroep/imp | /util/playlist/vlcinterface.rb | UTF-8 | 2,334 | 3.1875 | 3 | [
"MIT"
] | permissive | ##
# An implementation of the IMediaPlayer interface.
# This class launches the VideoLAN VLC Media Player as a subprocess
# in remote mode and communicates with it to play media.
class VLCInterface
##
# Spawns a VLC process and initializes the connection
def initialize(on_media_end)
@vlc = IO.popen("vlc --fullscr... | true |
c980c14646b167420462e1b1e6cb1c543f36928b | Ruby | profan/advent-of-code-2015 | /8-2.rb | UTF-8 | 431 | 3.0625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "matrix"
results = File.open("8.input", 'r').reduce(Vector[0, 0]) do |acc, line|
chomped = line.chomp.dump
escaped = chomped.scan(/\\((?:[xX][0-9a-fA-F]{2})|(?:\\|"))/).reduce(0) do |sum, m|
str = m.first
sum + str.size
end
acc + Vector[chomped.length, (chomped.length-2) - escaped]... | true |
4d81768b87d1c5f6b613d6ba6b2bcb4893fb77f0 | Ruby | piyushkp/ShippingInfo | /lib/ups/UpsInfo.rb | UTF-8 | 11,951 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'date'
require 'time'
require 'rexml/document'
require 'net/http'
require 'net/https'
require 'rubygems'
require 'active_support'
module Fedex
# Provides a simple api to to ups's time in transit service.
class UpsInfo
TEST_URL = "https://wwwcie.ups.com/ups.app/xml"
# UPS Production URL
PR... | true |
5f2e0b74f988858e5bb131769933d63c1a098a24 | Ruby | poise/poise-spec | /lib/poise_spec/patcher.rb | UTF-8 | 10,058 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | #
# Copyright 2015-2016, Noah Kantrowitz
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | true |
cd79b9c474585142d497432116e4ce84657ff7c0 | Ruby | Tkam13/atcoder-problems | /abc159/e.rb | UTF-8 | 237 | 2.734375 | 3 | [] | no_license | h,w,k = gets.chomp.split.map(&:to_i)
chos = h.times.map{gets.chomp.split.map(&:to_i)}
(2 ** (h-1)).times do |n|
sum = 0
idx = Array.new(h, 0)
(h-1).times do |j|
sum += n[j]
idx[j+1] = idx[j] + n[j]
end
p sum
p idx
end | true |
b7648a90c9d414a92e7a8c950125c79b0be2ee5c | Ruby | judo2000/RB101_Programming_Foundations | /lesson_4/double_odd_numbers.rb | UTF-8 | 1,001 | 4.28125 | 4 | [] | no_license | def double_odd_numbers(numbers)
doubled_numbers = []
counter = 0
loop do
break if counter == numbers.size
current_number = numbers[counter]
current_number *= 2 if current_number.odd?
doubled_numbers << current_number
counter += 1
end
doubled_numbers
end
# Note that we are working wit... | true |
abc7a3ba19da55a0bb196414991127d4e67c731b | Ruby | uemurm/ruby | /POH_lite/lite.rb | UTF-8 | 811 | 3.4375 | 3 | [] | no_license | class Combinations < Array
def initialize(n)
for i in 0...2**n
@comb = []
for j in 0...n
@comb[j] = ( (i % 2**(j+1) ) >= 2**j ) ? true : false
end
self.push(@comb)
end
end
end
Company = Struct.new(:nEngineers, :fee)
companies = []
nEngineersRequired = gets.to_i
nCompanies =... | true |
6c77618450607263672b03565230e96dc440a9c4 | Ruby | dshankland/codeclan_w3_cinema | /console.rb | UTF-8 | 1,879 | 2.65625 | 3 | [] | no_license | require('pry-byebug')
require_relative('models/customer')
require_relative('models/film')
require_relative('models/ticket')
require_relative('models/screening')
Ticket.delete_all()
Screening.delete_all()
Customer.delete_all()
Film.delete_all()
customer1 = Customer.new({'name' => 'Ann Campbell', 'funds' => 50})
custom... | true |
2b91c74b03af2d4cfd59eeef82c2af758c5d2461 | Ruby | sherrynganguyen/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 3,072 | 2.625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
subject { described_class.new(
:firstname => "Pikachu",
:lastname => "Pokemon",
:email => "TEST@TEST.com",
:password => "1234567",
:password_confirmation => "1234567"
)
}
describe 'Validations' do
it "should have same pass... | true |
768f1d48b923d4a7a071aee1cef96ce0ee9882f7 | Ruby | holywyvern/carbuncle | /gems/carbuncle-doc-ext/mrblib/hash.rb | UTF-8 | 160 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | # A hash represents a dictionary of key, value pairs.
# Each key can only have one value, but each value can be set to as many keys as you like.
class Hash
end
| true |
294c40556dfdb7d4f1b90c98dfa7f6a365b90509 | Ruby | nejcik/AkademiaRebased | /task_1_TICTACTOE/board.rb | UTF-8 | 2,641 | 3.5625 | 4 | [] | no_license | require_relative 'point'
class Board
attr_accessor :points_weights, :game_board, :max_size
def initialize(size = 3)
@points_weights = Array.new(size){ Array.new(size, 0) }
create_game_board
@max_size = size
end
def create_game_board(size=3)
size = 2 * size + 1
game_board_init = Array.new(size){ Arr... | true |
29ec60815e0d78a939ca6de0ca123b4e8111fbea | Ruby | michael-danello/RB101 | /easy9/double_double.rb | UTF-8 | 469 | 3.3125 | 3 | [] | no_license | def twice(num)
num_string = num.to_s
num_size = num_string.size
if num_size.even? && num_string[0..num_size/2-1] == num_string[num_size/2..-1]
num
else
num * 2
end
end
puts twice(37) == 74
puts twice(44) == 44
puts twice(334433) == 668866
puts twice(444) == 888
puts twice(107) == 214
puts twice(10... | true |
d9f1a7015541412d523787ac47580bf50126566f | Ruby | NomadicNibbler/foodtruck_be | /spec/services/food_truck_service_spec.rb | UTF-8 | 3,238 | 2.65625 | 3 | [] | no_license | require "rails_helper"
RSpec.describe "Food_truck_service_api" do
describe "class methods" do
it "returns all the possible regions", :vcr do
data = FoodTruckService.get_regions
expect(data.status).to eq(200)
regions = parse(data)
expect(regions).to be_an(Array)
expect(regions.count... | true |
0e9e58e8644af1adad879d5d7da8ce25d942b424 | Ruby | tafujino/vcreport | /lib/vcreport/report/c3js.rb | UTF-8 | 2,716 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'json'
module VCReport
module Report
module C3js
class Column
# @return [Symbol]
attr_reader :id
# @return [String]
attr_reader :label
# @return [Boolean]
attr_reader :is_categorical
# @param id [S... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.