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
2e7b6c7e15d0be6ea578b50d807841e794e8cd04
Ruby
vdk88/seek
/lib/seek/bio_schema/csv_reader.rb
UTF-8
726
2.75
3
[ "BSD-3-Clause", "JSON" ]
permissive
module Seek module BioSchema # Reads the CSV mapping file, that contains details about the propery and method # to be invoked for a given resource type # a wildcard (*) for the type means if applies to any resource type that is supported class CSVReader include Singleton MAPPINGS_FILE = F...
true
a3e9f81db26442c3ca386ce0688bfd215e886bec
Ruby
bmael/Raspbuddies
/ForRasp/broadcast/HashModule.rb
UTF-8
661
3
3
[]
no_license
require 'digest/md5' module HashFunctions @@a1 = [18, 39, 3, 37, 12, 29, 7, 30, 23, 2, 5, 39, 24, 12, 26, 12, 27, 0, 25, 24, 9, 12, 9, 18, 32, 27, 38, 30, 18, 27, 12, 25] @@a2 = [6, 9, 38, 16, 21, 26, 3, 7, 13, 5, 30, 22, 15, 19, 31, 30, 32, 9, 9, 0, 18, 10, 7, 1, 16, 6, 12, 6, 22, 3, 5, 29] def h1(k) result = ...
true
e783bfe507276084c93bdfb9eb1981dc36eba10b
Ruby
cmupakile/coursework
/w01d03/aiportLab/main.rb
UTF-8
621
2.734375
3
[]
no_license
# require_relative "./airport.rb" response = menu while response != 'E' case response when 'F' flight_info when 'P' passenger_info when 'T' terminal_info end response = menu end def menu puts `clear` puts "*****************************************************" puts "******************...
true
c3416aeb0dadcc686deaa73c06ad45369ebd95c7
Ruby
puppycodes/huboard-on-heroku
/test/lib/classy_assumptions_test.rb
UTF-8
919
2.875
3
[ "MIT" ]
permissive
require 'test_helper' class ClassyAssumptionsTest < ActiveSupport::TestCase class BobBase def self.bob @bob ||= "bob" end def self.set_bob(bob) @bob = bob end def perform payload end end class Frank < BobBase def get_bob_class self.class.bob end end cl...
true
03cc747401140c04fc6115bf9f5b07c69d0b9536
Ruby
Rob-rls/learn_to_program
/ch10-nothing-new/english_number.rb
UTF-8
5,885
3.375
3
[]
no_license
def english_number number =begin if number < 0 return 'Please enter a number that isn\'t negative.' end =end if number == 0 return 'zero' end numString = '' onesPlace = ['one', 'two','three', 'four','five','six','seven','eight','nine'] tensPlace = ['ten','twenty','thirty','forty','fifty','sixty...
true
1433354356edb91efb94f297596539282a764d57
Ruby
bmangelsen/employee-reviews-102016
/department.rb
UTF-8
877
3.453125
3
[]
no_license
require_relative './employee' class Department attr_accessor :department_name attr_reader :department_employees def initialize(department_name) @department_name = department_name @department_employees = [] CSV.open("departments.csv", "a") do |csv| csv << [department_name] end end def...
true
d90d8592e6d668f8f397c2d30be9d81258212182
Ruby
department-of-veterans-affairs/vets-api
/app/models/emis_redis/veteran_status.rb
UTF-8
2,723
2.65625
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
# frozen_string_literal: true require 'emis/veteran_status_service' module EMISRedis # EMIS veteran status service redis cached model. # Much of this class depends on the Title 38 Status codes, which are: # # V1 = Title 38 Veteran # V2 = VA Beneficiary # V3 = Military Person, not Title 38 Veteran, NOT DoD...
true
f99d968d356eb063ea56fbeee94dbc2f2e15acbb
Ruby
Natirx/LV-277.TAQC
/OpenCart tests/Cart(Andrii)/pages/page.rb
UTF-8
721
2.65625
3
[]
no_license
require_relative 'main' class Page < Main ADDTOCART_BUTTON = {css: ".product-layout:first-child button:first-child"} CART_ONE_ITEM = {:css => "#cart-total"} CART_BUTTON = {:xpath =>"//a[@title='Shopping Cart']"} ITEM_FIELD ={:xpath => "//*[@id='content']//a[text()='MacBook']"} SIME = {css: ".product-layout:f...
true
300d3373c0ff9431b92c0b86918733ccdcc6d611
Ruby
nigelr/guesser
/guesser.rb
UTF-8
611
2.734375
3
[]
no_license
require 'sinatra' get '/' do erb :homepage end get '/start' do secret_number = rand(100) redirect "/play/#{secret_number}/Start" end get '/play/:secret_number/:message' do erb :play, locals: { secret_number: params[:secret_number], message: params[:message] } end post '/check/:secret_number' do secret_nu...
true
78c6b7af77423f5af8546e60ee7246aad667e2ce
Ruby
ErickGushiken/si_project
/siproject/app/models/user.rb
UTF-8
3,476
2.765625
3
[]
no_license
class User < ApplicationRecord has_secure_password has_many :produtos HUMANIZED_ATTRIBUTES = { :email => "Email", :password => "senha", :password_confirmation => "Confirmação de senha", :data_nasc => "Data de nascimento", } # Essa função altera o nome do atributo para mostrar as mensagens de...
true
c0f78ad534678f3523afe2f744f0d6f11911e80a
Ruby
demileee/ruby_fundamentals4
/fizzbuzz.rb
UTF-8
270
3.34375
3
[]
no_license
hundred = [] counter = 0 until counter == 100 counter += 1 z = counter hundred << z end hundred.each do |num| if (num % 3) == 0 && (num % 5) == 0 puts "BitMaker" elsif (num % 3) == 0 puts "Bit" elsif (num % 5) == 0 puts "Maker" else end end
true
ae7fffb8f589f4cda155249e9445f0d10b6b3750
Ruby
cul/json_csv
/lib/json_csv/utils.rb
UTF-8
2,197
3.5
4
[]
no_license
module JsonCsv module Utils # Returns true for empty strings, empty arrays, or empty hashes. # Also returns true for strings that only contain whitespace. # Returns false for all other values, including booleans and numbers. def self.removable_value?(value) return true if value.respond_to?(:emp...
true
bb03a7414910af770605c9c962e261eb092cc500
Ruby
josevictorferreira/store_api
/app/models/stock_item.rb
UTF-8
1,200
2.859375
3
[]
no_license
class StockItem < ApplicationRecord belongs_to :product belongs_to :store validates_presence_of :product, :store validates :items, numericality: { greater_than_or_equal_to: 0 } validates :product, uniqueness: { scope: :store } def add_stock_item(number) StockItem.add_items(self.id, number) self.rel...
true
5319c012e414cc045bd74f5f75afc96300a7800e
Ruby
jpserra/shorty
/lib/shorty/config.rb
UTF-8
507
2.71875
3
[]
no_license
module Shorty class Config def initialize(config_file = nil) @config_file = config_file || File.dirname(__FILE__) + '/../../config/shorty_config.rb' end def fetch(key) config.fetch(key) end def [](key) config[key] end private def config return @confi...
true
3980cd30af65870885fc75e7c624a48cb5c6f02b
Ruby
Hibasan/Ruby-01
/janken.rb
UTF-8
4,653
4.40625
4
[]
no_license
# プレイヤー(自分)に「0~2」を入力させるロジックを書きます。 class Player def hand # プレイヤーにじゃんけんの手を選択させる文章を表示させます。 puts "数字を入力してください。" puts "0:グー, 1:チョキ, 2:パー" # 変数「input_hand」にプレイヤーの入力値を代入します。 # ヒント:getsメソッドについて調べてみましょう。 input_hand =gets.to_i # 「input_hand」が「0, 1, 2」のいずれかだと繰り返し処理を終了し、それ以外(アルファベットも含む)だと繰り返し処理を継続します。 while t...
true
3342b9acf7725d1d3a0e7c64864732cc9fa3e0c0
Ruby
MrDevo/SimpleRubyProjects
/Iterators.rb
UTF-8
448
3.75
4
[]
no_license
i = 5 i.times do puts "Countdown #{i}" i-=1 end puts "Blast off!!" puts "\n" #========================================= 5.times do |i| puts "Countdown #{5-i}" end puts "Blast off!!!" puts "\n" #========================================= 5.downto(1) {|i| puts "Countdown #{i}"} puts "Blast off!!!" puts "\n" #==...
true
628b39c3201ffe916ac5b8c8b6c1e08667087e57
Ruby
anthonyneedles/WISE-HEADACHE-JASH
/cosmos/procedures/plot_test.rb
UTF-8
186
2.65625
3
[]
permissive
load 'cosmos/gui/line_graph/line_graph_script.rb' x = [0.0, 1.0, 2.0, 3.0, 4.0] y1 = [10.5, 9.6, 7.7, 6.8, 7.4] y2 = [10.2, 9.1, 7.3, 6.5, 7.8] plot(x, y1) plot(x, y1, 'y1', y2, 'y2')
true
41043bfd27f5225bd689fd7e510213848f4da0d0
Ruby
Linus-Cson-Ferdinand-Bostrom/Uppgifter
/30_concatenate/lib/concatenate.rb
UTF-8
99
3.015625
3
[]
no_license
def concatenate (num1, num2) blah1 = num1.to_s blah2 = num2.to_s return blah1 + blah2 end
true
dd11517abc8d6cd32a34b4d4e923a75789a593f7
Ruby
ltg7vp/Ruby-stuff
/weatherApp.rb
UTF-8
1,901
3.84375
4
[]
no_license
require 'open-uri' require 'json' #Weather API returns Kelvins so we'll have to use these conversion functions later on def KelvinToCelcius(kelvin) return (kelvin - 273.15).round(2) end def KelvinToFahrenheit(kelvin) return (kelvin * 9/5 - 459.67).round(2) end params = Array.new puts "Pass location parameters in...
true
8ca062405d1ae6b7307b88898d86c89fd3c4a93b
Ruby
rodenr/ruby_assignment
/9.rb
UTF-8
602
3.53125
4
[]
no_license
class Numeric @@currencies={'yen'=>0.013, 'euro'=>1.292, 'rupee'=>0.019, 'dollar'=>1} def method_missing(method_id) singular_currency = method_id.to_s.gsub(/s$/,'') if @@currencies.has_key?(singular_currency) self * @@currencies[singular_currency] else super end end def in(currency) # raise 'Pa...
true
6b8b389aa14b399483f3b0198698329f2b4c1661
Ruby
ThiQuynhTramPHAM/Coderubycaesar
/chiffre_de_cesar.rb
UTF-8
454
3.59375
4
[]
no_license
puts "Que voudriez vous coder?" mot = gets.chomp puts "Quel ecart souhaitez vous avoir" facteur = gets.chomp.to_i def cipher(mot, facteur) nouveau_mot = "" mot.each_char do |i| facteur.times do if(i == "z") i = "a" next elsif(i == "Z") i = "A" next ...
true
e5e75c77ee58312b28ee1515a6c670cb09ff42d5
Ruby
siruguri/track_status
/app/services/text_stats/document_universe.rb
UTF-8
434
2.640625
3
[]
no_license
module TextStats class DocumentUniverse def initialize @_counts = {} @_univ_size = 0 end def add(doc_model) @_univ_size += 1 doc_model.terms.each do |k| @_counts[k] ||= 0 @_counts[k] += 1 end self end def universe_count(term) if @_counts...
true
e35155785d95a0965a2282277112f4a0ec133e1a
Ruby
sho12chk/ruby_lesson
/original/sample.rb
UTF-8
2,734
3.515625
4
[]
no_license
################################# ##### 昼ドラ風プログラム ####### ################################# #共通クラス class User attr_accessor :name,:age,:love_word,:hate_word def initialize(name:,age:,love_word:,hate_word:) self.name = name self.age = age self.love_word = love_word self.hate_word = hate_wo...
true
ea8869bcb6069344588aaa07949e91c32788b5ee
Ruby
nounch/bat-game
/entities/npc.rb
UTF-8
896
3.15625
3
[]
no_license
class NPC attr_accessor :x, :y, :is_dead def initialize(**options) @x = options[:x] || 0 @y = options[:y] || 0 @screen = options[:screen] || nil @game = options[:game] || nil @tile = options[:tile] || 'w' @killable = options[:killable] || true @last_tick = 0 @do_tick = true @is_...
true
bc88ca7f2454698194fbd1e9b7b3b62273d208e6
Ruby
jokercsi/RubyPractice
/04.Query Parts and Web Forms/student_data_start.rb
UTF-8
1,079
3.25
3
[]
no_license
# definition of simple Student class Student = Struct.new(:number, :familyname, :givenname, :english, :math, :average) # initialization of array students students = [ Student.new("12345678", "Reigai", "Taro", 80, 62), # 例外   太郎 Student.new("12349875", "Reidai", "Hanako", 76, 65)...
true
e35e6071752a002213a120a1099b164e69da83e9
Ruby
syhsyh9696/blog-notification-ruby
/lib/module.rb
UTF-8
1,363
2.515625
3
[]
no_license
# encoding: utf-8 module Unicorn version = "1.3.5" def get_time(authentication) updatetime = Hash.new File.open("../resources/allblog.ini", "r") do |io| while line = io.gets line.chomp! updatetime[line] = Time.parse(pushed_at(line, authenti...
true
9d606b27a77fbc466f0833df97bfaea12c80780b
Ruby
spaldingVance/RB101
/lesson_3/sum_or_product.rb
UTF-8
631
4.5
4
[]
no_license
puts ">> Please enter an integer greater than zero" top_of_range = gets.chomp.to_i puts ">> Enter s to compute the sum, p to compute the product" loop do choice = gets.chomp.downcase if choice == 's' sum = 0 (1..top_of_range).each {|x| sum += x} puts "The sum of the integers between 1 and #{top_of_rang...
true
42bc11cc757636501161da4b714f6410011b4c20
Ruby
martin-kirilov/ProgrammingTechnology1task
/h16/subarray_count.rb
UTF-8
268
3.53125
4
[]
no_license
class Array def subarray_count subArr arrCount = 0 if subArr.get self.each_index do |x| if self[x] == subArr[0] && self[x+1] == subArr[1] arrCount += 1 end end arrCount end end
true
ee97ca46660f7f838e325cf5087d5722a9ae510f
Ruby
allagitgub/ttt-game-status-online-web-sp-000
/lib/game_status.rb
UTF-8
1,327
3.859375
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Helper Method WIN_COMBINATIONS = [ [0,1,2], [3,4,5], [6,7,8], [0,4,8], [2,4,6], [0,3,6], [1,4,7], [2,5,8] ] def position_taken?(board, index) !(board[index].nil? || board[index] == " ") end def won?(board) WIN_COMBINATIONS.detect do |win_combination| (board[win_combination[0]] == "X" && board...
true
650ea84d53ffccbf58e134f745117454ceb8dd7d
Ruby
harshjainmove/training
/day2/test6.rb
UTF-8
444
3.359375
3
[]
no_license
#!/usr/bin/env ruby # hashes can use any objects as keys class CelestialBody attr_accessor :name, :type end default_body = CelestialBody.new default_body.type = 'planet' bodies = Hash.new(default_body) bodies['Mars'].name = 'Mars' p bodies['Mars'] bodies['Europa'].name = 'Europa' bodies['Europa'].type = 'Moo...
true
825bc87c81ae14d21e86372153dcc96a970f3a66
Ruby
tmurrell2020/cartoon-collections-onl01-seng-pt-090820
/cartoon_collections.rb
UTF-8
450
3.25
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def roll_call_dwarves(dwarves) dwarves.each_with_index do |names, index| puts "#{index+1}, #{names}" end# end def summon_captain_planet(planeteer_calls) planeteer_calls.map do |elements| "#{elements.capitalize}!" end end def long_planeteer_calls(calls) calls.any?{|call| call.length > 4} end def f...
true
5d364b90f812810ddbc57325c194571ae23420cc
Ruby
freerange/goos-ruby
/app/auction_message_translator.rb
UTF-8
1,767
3.015625
3
[]
no_license
require "price_source" class AuctionMessageTranslator class AuctionEvent def initialize @fields = Hash.new end def type return get("Event") end def current_price return get_int("CurrentPrice") end def increment return get_int("Increment") end def get_i...
true
1e3e07c9df56b0f47bf3619a40068fc3e4e1414b
Ruby
mauriciordz/MetodosDestructivos
/MetodosDestructivos.rb
UTF-8
1,767
4.3125
4
[]
no_license
# Ivan y Mauricio # Métodos Destructivos # Martes 7 de Junio 2016 # name = "Fernando" # puts "Valor de name: #{name}" # puts "Llamando al método reverse en name : #{name.reverse}" # puts "Valor de name despues de pasarlo por reverse: #{name}" # puts "Llamando al método reverse! en name : #{name.reverse!}" # puts ...
true
97bebf101ae663ff5f98d67c05ea648c2f01887f
Ruby
eiji03aero/dprb
/lib/dprb/decorator.rb
UTF-8
1,476
3.265625
3
[]
no_license
module DPRB module Decorator # Problem # We need to vary the responsibilities of an object, adding some features. # # Solution # In the Decorator pattern we create an object that wraps the real one, and implements the same interface and forwarding method calls. However, before delegating to the re...
true
16a64dd517cca3013bb593ed6fc5632c038b3caa
Ruby
tianshuai/xiaomajj
/app/models/captcha.rb
UTF-8
593
2.65625
3
[]
no_license
class Captcha < ActiveRecord::Base #常量 KIND = { #邮箱验证 email: 1, #手机验证 phone: 2 } #限制发送短信/email间隔 def is_expire_message? return true if (self.expires_at + 60) < Time.now.to_i return false end #是否过期 def is_expire? if self.kind==1 n = 3600 elsif self.kind==2 n...
true
882c6cbc85cb19d07712969d26ecdbc2d5fab7b6
Ruby
joshisaurabh/learn_ruby
/01_temperature/temperature.rb
UTF-8
90
2.78125
3
[]
no_license
def ftoc(faren) (faren-32.0)*(5.0/9.0) end def ctof(celcius) (celcius*9.0/5.0)+32 end
true
19a971a78f9bea7eb645dc85ce51b9bda7ac5d9a
Ruby
pamnunez/learn_ruby
/03_simon_says/simon_says.rb
UTF-8
521
3.625
4
[]
no_license
def echo(text) text end def shout(text) text.upcase end def repeat(*input) if input[1] == nil input[0] + " " + input[0] else ((input[0]+" ")*(input[1]-1)) + input[0] end end def start_of_word(word, num) word[0, num] end def first_word(text) text[/\w+/] end def titleize(te...
true
a4a8e7b0ebf816d387a9b7a159733374ddeb0a33
Ruby
charliejp0311/programming-univbasics-4-intro-to-hashes-lab-online-web-prework
/intro_to_ruby_hashes_lab.rb
UTF-8
1,182
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def new_hash # return an empty hash new_h = Hash.new end def my_hash # return a valid hash with any key/value pair of your choice person = { :first_name => "Charlie", :last_name => "Pelton", :house_number => 2 , :house_street => "Lee Ct.", :house_city => "DeKalb", :house_zip_code => 601...
true
f33233d23087ce3481793053d7c1ba708121cd83
Ruby
ktakenaka/trial-ruby-zip
/main.rb
UTF-8
1,661
2.59375
3
[]
no_license
require 'bundler' Bundler.require require "tmpdir" require 'securerandom' require "active_support/core_ext" puts "environment variable 'TMPDIR' is #{ENV["TMPDIR"]}" user = "Bamboo" file_id = SecureRandom.hex(10) file_hash = { theme: "home work", section1: { question1: 1, question2: "hoge" }, section2...
true
99f0e2feaf4c2184d9f2edcc5995f84d441e22cc
Ruby
J-Marriott/codewars
/6kyu/multiples_of_3_and_5_final.rb
UTF-8
788
3.765625
4
[]
no_license
=begin If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in. Note: If the number is a multiple of both 3 and 5, only count it once. =end...
true
b5405a94708767ee1df6311025e392e706d547d0
Ruby
shanebarringer/battle_royal
/lib/battle_royal/game.rb
UTF-8
3,156
3.625
4
[ "MIT" ]
permissive
require_relative 'player' require_relative 'roll' require_relative 'weapon_chest' require_relative 'lame_player' require_relative 'advantaged_player' require 'csv' module BattleRoyal class Game attr_accessor :title, :players, :toasty def initialize(title) @title = title @players = [].sort @t...
true
b562f8136eee734be6cdcfb2e182077fcb0dd696
Ruby
tank-bohr/pong
/lib/pong/game.rb
UTF-8
2,829
3.234375
3
[]
no_license
require 'aasm' require 'pong/player' require 'pong/position' require 'pong/ball' module Pong class Game include AASM aasm do state :idle, initial: true state :playing, :won, :loss event :start, before: :bootstrap do transitions from: :idle, to: :playing end event :win...
true
073b23667bee517634b7c7f4a9cfb1aa394b2aac
Ruby
Part1nax777/BlackJack
/player.rb
UTF-8
758
3.546875
4
[]
no_license
require_relative 'validator' require_relative 'hand' require_relative 'bank' class Player include Validate attr_accessor :name, :score, :bank, :hand MSG_INCORRECT_NAME = 'You must input name'.freeze def initialize(name) @name = name @bank = Bank.new @bank.set_start_amount @score = 0 valid...
true
f51a335092a82752e1391a7a2f103a56005bbfdb
Ruby
jeffmbellucci/Assessments
/assessment02-retake/lib/board.rb
UTF-8
1,286
3.40625
3
[]
no_license
require_relative 'card' require_relative 'foundation' require_relative 'move_error' require_relative 'pile' class Board attr_reader :foundations, :piles def self.deal(deck) foundations = {} Card.suits.each { |suit| foundations[suit] = Foundation.new(suit) } piles = Array.new(7) { |i| Pile.deal(i, dec...
true
cd36136ff434dc768ac2d9f2f23a266660385764
Ruby
framgia1023/rails-elearning-okudo-wataru
/app/models/word.rb
UTF-8
588
2.71875
3
[]
no_license
class Word < ApplicationRecord belongs_to :category has_many :choices validates :content, presence: true validate :check_choice has_many :lessons, through: :answers has_many :answers accepts_nested_attributes_for :choices private def check_choice correct = choices.collect{ |item| item.correct || nil}.comp...
true
dd6aac6fa7253b84a024d947af3b066c4d4aeb2f
Ruby
nekonabesan/Fundamental-Programming
/lec008/fp08_03.rb
UTF-8
2,677
3.296875
3
[]
no_license
require 'benchmark' require 'bigdecimal' require 'bigdecimal/util' require '../modules/fp_module.rb' #/===============================================================/ # 演習 3 モンテカルロ法で数値積分を行うときの、 # 精度 (有効桁数) と試行の数との関係について考察せよ。 # 円周率の例題を活用してもよいが、 # できれば別の関数を積分するプログラムを作って検討することが望ましい。 #/===================================...
true
85b82a504af17b5f4685f0e06e28be6793c376e8
Ruby
vngrv/ruby-game-of-life
/lib/game.rb
UTF-8
323
3.125
3
[]
no_license
require_relative 'cell' require_relative 'board' class Game def call(width, height, cell, cells = [], fps = 0.1) system('clear') board = Board.new(width, height, cell, cells) puts board until board.lifeness? board.evolve sleep fps system('clear') puts board end end end...
true
09013a4fb36c3989f837139c5be2de76b4dae10c
Ruby
spatchcock/quantify
/spec/quantify/quantity_spec.rb
UTF-8
29,049
3.1875
3
[ "MIT" ]
permissive
# encoding: UTF-8 require 'spec_helper' describe Quantity do describe "#initialize" do specify { Quantity.new(1).should eq(Quantity.new(1,'unity')) } specify { Quantity.new(nil,nil).should eq(Quantity.new(nil,'unity')) } specify { Quantity.new(nil,nil).should eq(Quantity.new(nil,'unity')) } specify ...
true
686d927afbd08ffa41863df3d3ac932293965e24
Ruby
rkstarnerd/tealeaf_intro_precourse_work
/flow_control_ex5.rb
UTF-8
414
4.5
4
[]
no_license
puts "Enter a number between 0 and 100." number = gets.chomp.to_i def compare(number) answer = case when number > 0 && number <= 50 "#{number} is between 0 and 50." when number > 50 && number <= 100 "#{number} is between 50 and 100." when number > 100 "Doh! #{number} is greater than 100. Try again!" e...
true
fbf36b8ff5ec4f7ac4b4fbe0894ec5c80d90452b
Ruby
jamestunnell/music-instruments
/lib/music-instruments/instrument_key.rb
UTF-8
4,858
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Music module Instruments # The fundamental unit for performing notes. class InstrumentKey include Hashmake::HashMakeable # defines how hashed args should be formed for initialization ARG_SPECS = { :sample_rate => arg_spec(:reqd => true, :type => Fixnum), :inactivity_threshold => arg_spec(:reqd =>...
true
3d5eb8d1d8c1b652c8d2f6d82d7b9f2bd84efa16
Ruby
mihir787/enigma
/test/encryptor_test.rb
UTF-8
1,662
2.859375
3
[]
no_license
require_relative 'test_helper' require_relative '../lib/encryptor' class EncryptorTest < Minitest::Test def setup @test_file = File.new("test_file.txt", "w+") @test_file.write("ruby is awesome") @test_file.close @test_file2 = File.new("test_file2.txt", "w+") @test_file2.write("ruby is awesome 2"...
true
7e4cd772bdfcc50bfc6774c0a8305210193b62ca
Ruby
viveksraghuwanshi/test
/unless.rb
UTF-8
79
2.765625
3
[]
no_license
#!/usr/bin/ruby -w a=200 unless a > 100 print "#{a}"; else print "100"; end
true
a62359c741e4a1f3352c80fa90cca16b079e4e27
Ruby
drayas/PDHex
/app/models/game.rb
UTF-8
1,186
2.75
3
[]
no_license
class Game < ActiveRecord::Base has_many :game_users has_many :users, :through => :game_users # Players is an array of hashes with user_ids and deck_ids #[ # {:user => u, :deck => d}, # {:user => u2, :deck => d1} #] def self.test Game.start!([{:user => User.first, :deck => Deck.last}, {:user => U...
true
cc25e544dbd93c4930770312bde195f6b799746f
Ruby
hyphenized/c2-module2
/week-2/day-1/howmuch.rb
UTF-8
1,258
3.40625
3
[]
no_license
$input = <<doc Category, (Symbol) Price, Stock, Amount, Name Sporting Goods, USD 49.99, true, 10, Football Sporting Goods, PEN 9.99, true, 3, Baseball Sporting Goods, ARS 29.99, false, 0, Basketball Electronics, PEN 99.99, true, 5, iPod Touch Electronics, USD 399.99, false, 0, iPhone 5 Electronics, PEN 199.99, true, 2,...
true
339c1ba0c60606a179ae8f05784833404253b73f
Ruby
haletothewood/GildedRubyRose
/spec/item_spec.rb
UTF-8
604
3.203125
3
[ "MIT" ]
permissive
require 'item' describe Item do name = 'Foo' sell_in = 20 quality = 10 let(:item) { Item.new(name, sell_in, quality) } describe '#new' do it 'is created with a name' do expect(item.name).to eq 'Foo' end it 'is created with a value for the number of days to sell within' do expect(ite...
true
156b6f6abf53d5f56077b1f7ad2b25ad1abb2409
Ruby
istateside/minesweeper
/minesweeper.rb
UTF-8
5,115
3.53125
4
[]
no_license
require 'yaml' class Tile NEIGHBOR_POS = [ [-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1] ] attr_accessor :is_bomb, :neighbors, :revealed, :is_flagged, :neighbor_bomb_count attr_reader :board, :pos def initialize(board, x, y) @is_bomb = false @n...
true
84bcb21882116a245dbc8fb5a5db4e2f274d6ac0
Ruby
HakubJozak/pcdir-duben-2017
/excersises/pi.rb
UTF-8
238
3.65625
4
[]
no_license
require 'bigdecimal' # Tayloruv rozvoj PI. # # Pi/4 = 1 - 1/3 + 1/5 - 1/7 + ... # def sum(n) s = BigDecimal.new("1") sig = 1 1.upto(n) do |i| sig *= -1 s += (1.0 / (2*i + 1)) * sig end 4 * s end puts sum(30000000)
true
67379fc6df9105f460adb36fec88ba64b9a356ed
Ruby
armendarabyan/wordscollector
/app/filterwords.rb
UTF-8
592
2.828125
3
[]
no_license
require './activerecord/words' class FilterWords def filter(words) a = [] words.each do |word| if not exist?(word) a.push(word.downcase) end end return a end def exist?(word) Words.exists?(name: word.downcase) end def exist_in_unknown?(word) Words.exists?(name: ...
true
c0d421d987ba5b3b2dcc316e44fd5175db6742d7
Ruby
HariShankarS/exercism
/ruby/anagram/anagram.rb
UTF-8
337
3.09375
3
[]
no_license
class Anagram def initialize(word) @word = word end def match(array) output = [] array.each do |a| unless a.downcase == @word.downcase output << a if test(a) == test(@word) end end output end def test(word) word.downcase.chars.sort end end module BookKeeping ...
true
cd6b424e0221ad38a6f5cb6d86e53c634adc80d5
Ruby
portco/connect_four
/spec/lib/connect_four/board_spec.rb
UTF-8
14,449
2.734375
3
[ "MIT" ]
permissive
require 'spec_helper' RSpec.describe ConnectFour::Board do before :each do @obj = ConnectFour::Board.new end context 'vertical_win? checking' do it 'should return false with check vertical win due to minimal input' do @obj.instance_variable_set(:@total_moves, 6) expect(@obj.send(:vertical_w...
true
d855efc9db2cd1b7305c257e5c29d294cf013e4c
Ruby
Terren45/programming-univbasics-4-crud-lab-online-web-prework
/lib/array_crud.rb
UTF-8
890
3.453125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def create_an_empty_array [] end def create_an_array ["cars", "truck", "planes", "trains"] end def add_element_to_end_of_array = ["cars", "truck", "planes", "trains"] add_element_to_end_of_array << "boat" end def add_element_to_start_of_array = ["cars", "truck", "planes", "trains"] add_element_to_start_of_ar...
true
d1cc6388db33273bdc7c87d95bb06445713aa19c
Ruby
QPC-WORLDWIDE/rubinius
/spec/ruby/language/versions/for_1.8.rb
UTF-8
203
2.703125
3
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
describe "The for expression" do it "repeats the loop from the beginning with 'retry'" do j = 0 for i in 1..5 j += i retry if i == 3 && j < 7 end j.should == 21 end end
true
d27c762e07bfbc954f3ac2ad8a8b0449d4043194
Ruby
jwshinx/SubscriptionCircus
/lib/invoice.rb
UTF-8
594
2.625
3
[]
no_license
require 'general_methods' class Invoice include GeneralMethods include GeneralMethods::AddedInstanceMethods attr_reader :customer, :date, :amount_due, :amount_paid def initialize options={} @customer = options[:customer] ? options[:customer] : 'N/A' @date = options[:date] ? options[:date] : 'N/A' @amount_p...
true
d15fc749e4261db2197a0501b44cbf3e4c7cbbff
Ruby
javogel/IH_Coursework
/Week_2/Day_2/OnlineCalculator/lib/Calculator.rb
UTF-8
853
3.640625
4
[]
no_license
class Calculator def initialize end def self.calculate(num1, num2, operation) case operation when "add" self.add(num1, num2) when "subtract" self.subtract(num1, num2) when "multiply" self.multiply(num1, num2) when "divide" self.divide(num1, num2) end end de...
true
263bedc2eb65e6b88d5139df2c3422aec9016b66
Ruby
oliverbebber/key-for-min-value-onl01-seng-pt-081720
/key_for_min.rb
UTF-8
2,046
4.03125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# prereqs: iterators, hashes, conditional logic # Given a hash with numeric values, return the key for the smallest value # def method(hash) # iterate over the hash # returns key with smallest value # if method is called and has an empty hash => nil require 'pry' # return nil - passes, fails returning smallest ha...
true
29cbc369ca6ed3659126d332374a7b34e5d00f25
Ruby
timoh/craftbeer
/app/models/geocoder.rb
UTF-8
3,021
3.0625
3
[]
no_license
class Geocoder require 'rest_client' require 'uri' # requires Rails.application.secrets.googlemaps_token # API docs: https://developers.google.com/maps/documentation/geocoding def Geocoder.get_token access_token = ENV['GOOGLEMAPS_TOKEN'] || Rails.application.secrets.googlemaps_token begin rai...
true
7e5f2d22dda84c98e2f2484ffb2995b83bb8c87a
Ruby
acasasayas/IronHack_exercises
/PreWork/FizzBuzz2.rb
UTF-8
571
3.34375
3
[]
no_license
number = 1 output = "nothing" while number <= 100 if number % 3 == 0 output = "Fizz!" end if number % 5 == 0 output = "Buzz!" end if number % 3 == 0 && number % 5 == 0 output = "Fizz!Buzz!" end if output == "nothing" && number / 10 != 1 output = "#{number}" end if number /10 == 1 && output == "noth...
true
08674b9ccb9a2bfae4a18288ac9e02a50700c919
Ruby
teacplusplus/sait-znakomstv
/config/initializers/lang_correct.rb
UTF-8
2,086
3.359375
3
[]
no_license
#encoding: UTF-8 class LangCorrect REPLACES = { #CASE_UPPER #case_lower "Ё" => '~', "а" => '`', #Ё ё "А" => 'F', "а" => 'f', #А а "Б" => '<', "б" => ',', #Б б "В" => 'D', "в" => 'd', #В в "Г" => 'U', "г" => 'u', #Г г "Д" => 'L', ...
true
b32e675dc3f43b8fd324f8e0b6c2c640d635f872
Ruby
MachineShop-IOT/machineshop_gem
/machineshop/lib/machineshop/api_resource.rb
UTF-8
946
2.625
3
[ "MIT" ]
permissive
module MachineShop class APIResource < MachineShopObject def self.class_name self.name.split('::')[-1] end def self.url() if self == APIResource raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Device, Rule, etc.)') ...
true
313ca1fa57c773bb88bfb672504aa1ff975518e0
Ruby
claritasf/Ruby_Web_Server_and_Browser
/simple_server.rb
UTF-8
1,125
3.03125
3
[]
no_license
require 'socket' require 'json' # Get sockets from stdlib server = TCPServer.open(2000) # Socket to listen on port 2000 puts "Listening on port 2000" loop { # Servers run forever client = server.accept # Wait for a client to connect request = client.gets.split(" ") re...
true
6104b102abaf919be8719e8ed4fdfc53825f17ef
Ruby
salbonico/activerecord-tvshow-v-000
/app/models/show.rb
UTF-8
452
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Show < ActiveRecord::Base def self.highest_rating Show.maximum(:rating) end def self.most_popular_show Show.find_by(rating:Show.highest_rating) end def self.lowest_rating Show.minimum(:rating) end def self.least_popular_show Show.find_by(rating:Show.lowest_rating) end def self.ratings_sum Show.sum(:ratin...
true
f9c3d162b15e8d9938c464ffdd60aab47f707d48
Ruby
mogox/mission-to-mars
/app/rover.rb
UTF-8
966
3.625
4
[]
no_license
class Rover attr_accessor :instructions, :direction, :x, :y def initialize(position, instructions = nil) attributes = position.split @x = attributes[0].to_i @y = attributes[1].to_i @direction = RoverDirection.new attributes[2] self.instructions = instructions end def follow_instructions ...
true
879eae94e5f57ecc9bd0fea00a0af1d03497be6a
Ruby
bvluong/Chess
/inheritance_practice/employee.rb
UTF-8
1,291
3.796875
4
[]
no_license
class Employee attr_accessor :salary def initialize name, title, salary, boss @name = name @title = title @salary = salary @boss = boss @multiplier = 1 end def bonus multiplier @salary * multiplier end end class Manager < Employee attr_accessor :underlings def initialize name...
true
769a7e2b7a242a0ebd26db736cd64fefff30e0b8
Ruby
roosterchicken/beemovie-rb
/lib/beemovie/word.rb
UTF-8
446
2.96875
3
[ "MIT" ]
permissive
module Beemovie class Word def self.multiplySentences(num, array) string = "" globalnum = num while globalnum > 0 if num == 1 string = array.sample else string = string + array.sample + " " ...
true
a3428dd5ecfeed66c514f8e0ec24568d7129e94f
Ruby
thegeekbrandon/rubyScripts
/Ruby-Scripts/input.rb
UTF-8
103
3.59375
4
[]
no_license
puts "Enter your name:" name = gets.chomp greeting = "Hello, #{name}. You are awesome!" puts greeting
true
617f8d686575004938a562e1560eea436591184c
Ruby
luismedinacoca/LearnToCodeWithRuby
/Section14/Lecture174-YieldingWithArguments04.rb
UTF-8
305
3.875
4
[]
no_license
def number_evaluation(num1, num2, num3) puts "Inside the method" yield(num1, num2, num3) #puts "Back inside the method!" end sum = number_evaluation(5, 15, 10){ |num1, num2, num3| num1 + num2 + num3 } product = number_evaluation(5, 15, 10){ |num1, num2, num3| num1 * num2 * num3 } p sum p product
true
1848f33ad368d51c648a2960f574310f99cfcd91
Ruby
umar006/social-media-api
/app/controllers/hashtags_controller.rb
UTF-8
444
2.53125
3
[]
no_license
require './app/models/hashtag' class HashtagsController def create(hashtag) new_hashtag = Hashtag.new(hashtag) new_hashtag.save end def update(hashtag) update_hashtag = Hashtag.new(hashtag) update_hashtag.update end def self.find_by_hashtag(hashtag) Hashtag.find_by_hashtag(hashtag).firs...
true
b79be5877b4a9b3c52b162829784b5f4e2393a31
Ruby
tkgs0109/DIC_scripting_task
/app/models/task.rb
UTF-8
1,416
2.65625
3
[]
no_license
class Task < ApplicationRecord default_scope -> { order("tasks.id") } belongs_to :user has_many :parent_relationals, class_name: 'Relational', foreign_key: :parent_id has_many :children_relationals, class_name: 'Relational', foreign_key: :children_id, dependent: :destroy has_many :parent_task, through: :chi...
true
1a312b9cbc1d3cb2166d672b93e5ac7dde7284e5
Ruby
il-tmfv/sq-test-task
/app/models/transaction.rb
UTF-8
1,929
2.8125
3
[ "MIT" ]
permissive
class Transaction < ActiveRecord::Base validate :seller_and_buyer_exist, :buyer_meets_required_level, :buyer_have_enough_space, :buyer_have_enough_money before_validation :get_info_for_validation after_create :change_data_after_create private def get_info_for_validation @seller = Player.fi...
true
f31741ec5b255ab1195b78fe767224a92318a905
Ruby
muniere/tailor
/bin/tailor
UTF-8
2,442
2.625
3
[]
no_license
#!/usr/bin/env ruby require 'thor' require 'ostruct' require 'colorize' require 'awesome_print' require_relative '../lib/tailor' class CLI < Thor # # start # desc 'start <project>', 'start to tail logs' def start(name='default') # load project = Tailor::Project.load(name).validate # messa...
true
eab51bb8879363ce0d3e1ea152ce18f7577815f4
Ruby
fanjieqi/LeetCodeRuby
/701-800/795. Number of Subarrays with Bounded Maximum.rb
UTF-8
355
3.125
3
[ "MIT" ]
permissive
# @param {Integer[]} a # @param {Integer} l # @param {Integer} r # @return {Integer} def num_subarray_bounded_max(a, l, r) res, dp, prev = 0, 0, -1 a.each_with_index do |num, i| res += dp if num < l && i > 0 if num > r dp = 0 prev = i end if l <= num && num <= r dp = i - prev ...
true
61a4b9de3cd78a9b6bc929828944836972df26f7
Ruby
eeuresti/username_generator
/username.rb
UTF-8
1,419
3.125
3
[]
no_license
# Make sure to run the tests in your /spec folder # Run `rspec /spec/username_spec.rb` to get started. def format_name(first, last) if first == "" || last == "" return nil end new_first = first.gsub(/\W+/,"") new_last = last.gsub(/\W+/,"") username = new_first[0] + new_last username = username.downcase...
true
c7b5c9cabdcdcf0d98ff6e03898233ee96110075
Ruby
ostdotcom/SimpleTokenApi
/lib/global_constant/country_nationality.rb
UTF-8
13,951
2.5625
3
[ "MIT" ]
permissive
# frozen_string_literal: true module GlobalConstant class CountryNationality require 'csv' # GlobalConstant::CountryNationality # Get Aml Country From Ip # # * Author: Tejas # * Date: 01/08/2018 # * Reviewed By: Aman # # @return [Array] # def self.get_aml_country_from_ip...
true
e322b198cad1b5ecd950aeb23be9b227a813dd1a
Ruby
enspirit/wlang
/spec/unit/compiler/test_parser.rb
UTF-8
2,414
2.625
3
[ "MIT" ]
permissive
require 'spec_helper' module WLang describe Parser do def parse(input) WLang::Parser.new.call(input) end let(:expected) { [:template, [:fn, [:strconcat, [:static, "Hello "], [:wlang, "$", [:fn, [:static, "who"]]], ...
true
1f1474bf547530ed540f196515e1cd61d3eab0c6
Ruby
houcheng/JiebaRuby
/lib/segmenter.rb
UTF-8
2,884
3.09375
3
[]
no_license
require 'trie' require 'dag' require 'dag_dfs' require 'date' require 'hmm' require 'sentence_break_iterator' SEARCH_SEGMENT_MODE = 1 INDEX_SEGMENT_MODE = 2 class Segmenter def initialize(args = {}) @segment_mode = args[:segment_mode] || SEARCH_SEGMENT_MODE @enable_hmm = args[:enable_hmm] @trie = load_...
true
e31f87188314f6fec166f407decc1b0dd17557f6
Ruby
olbrich/ruby-units
/lib/ruby_units/definition.rb
UTF-8
2,965
3.328125
3
[ "MIT" ]
permissive
class RubyUnits::Unit < Numeric # Handle the definition of units class Definition # @return [Array] attr_writer :aliases # @return [Symbol] attr_accessor :kind # @return [Numeric] attr_accessor :scalar # @return [Array] attr_accessor :numerator # @return [Array] attr_acce...
true
dd55a5ebb948fc2ea6d046d7fcb09cf03cd61fb2
Ruby
emil/hello_world
/linked_list_test.rb
UTF-8
893
3.203125
3
[]
no_license
require 'minitest/autorun' require_relative 'linked_list' class LinkedListTest < MiniTest::Test def setup end def test_find_nth_to_last ll = LinkedList.new(0) 10.times do |i| ll.add(i+1) end values = ll.return_list value_ints = values.map {|n| n.val} assert_equal 9, ll.nth_to_last(2).val ...
true
2b31b423eb71a2ef36fcb8e7b9d03a1c0614f303
Ruby
thillerson/learn_ruby
/14_fiftynames/test_data.rb
UTF-8
216
2.734375
3
[]
no_license
require 'faker' class TestData def TestData::create_names(fileName, numNames) f = File.open(fileName, 'w') numNames.times { f.puts "name: " + Faker::Name.name } f.close end end
true
ef2eb934faaafb12b1b809b5b7940ec2fb92a73f
Ruby
jgabrielbc1991/Algoritmo-en-ruby---calculo-de-sumatoria-dado-un-resultado
/preguntavs.rb
UTF-8
2,394
4.21875
4
[]
no_license
#!/usr/bin/env ruby puts "Hola, dime la serie de numeros que vamos a comparar. Cuando estes listo escribe 'ya'" array = [] #Declaramos el array vacio lista = gets.chomp #Se captura el primer número array << lista ...
true
45b5daa21071a6190d09a866d45f290226d29783
Ruby
jlgavale/rubyPent
/028_initialize.rb
UTF-8
561
3.640625
4
[]
no_license
=begin tiene la caracteristica que es un metodo que se ejecua cuando creamos un objeto de na clase se utiliza para inicializar valores que el objeto tendra =end class Video attr_accessor :tiempo, :titulo def initialize(titulo) #puts "Gracias por iniciar..." self.titulo = titulo end ...
true
8e73ceb2f4e9585c33a2504e4dafe62f4b59036c
Ruby
torresga/launch-school-code
/prep_work/ruby_basics/user-input/opposites.rb
UTF-8
843
4.15625
4
[]
no_license
def valid_number?(number_string) number_string.to_i.to_s == number_string && number_string.to_i != 0 end number1 = nil number2 = nil loop do loop do puts "Please enter a positive or negative integer:" number1 = gets.chomp break if valid_number?(number1) puts "Invalid input. Only non-zero integers ...
true
453d587a3fd889dddc0fcf807ebf01900ab65500
Ruby
mble/rainfall-problem
/rainfall_spec.rb
UTF-8
591
2.84375
3
[]
no_license
require_relative 'rainfall' require 'rspec' RSpec.describe 'rainfall' do subject { Rainfall.new } it '#calculate works' do expect(subject.calculate([2, 1, 2])).to eq 1 expect(subject.calculate([5, 0, 5])).to eq 5 expect(subject.calculate([1, 5])).to eq 0 expect(subject.calculate([5, 1])).to eq 0 ...
true
e8a909642c27f037d74f644a8d5de968326b737e
Ruby
ivopashov/algorithms-data-structures
/sorting/merge_sort.rb
UTF-8
1,028
4.1875
4
[]
no_license
# central idea is to merge two sorted arrays on every step # as this is O(n) # next central idea is to split the collection is such a way that # you are able to have sorted subarrays. This is done in the recursive step # until we have 1 item collections which are sorted naturally def merge(array_a, array_b) a_index...
true
01a99164081e8445008e57a4e66a8dfb4532e1d8
Ruby
taratatach/netexport-parser
/parse.rb
UTF-8
1,380
2.96875
3
[ "MIT" ]
permissive
require 'json' # Command line helpers require File.join(File.dirname(__FILE__), '.', 'cmdlinetool') # Classes require './models/web_archive' require './models/har' require './models/harp' include Helpers OPTIONS = [ optdef(:verbose, ["-v", "--verbose"], "print generated json", false), optdef(:human, "--human", "...
true
8b52375d202e082bb0141b03c5dd2408ea0d4a5b
Ruby
radu-constantin/small-problems
/easy2/odd_numbers.rb
UTF-8
68
2.78125
3
[]
no_license
odd_numbers = (1..99).to_a.select {|num| num.odd?} puts odd_numbers
true
877fdb0a0d82f9eee81b3a66ae40782b0464badf
Ruby
charlottebrf/ruby-kickstart
/session2/challenge/7_array.rb
UTF-8
1,490
4.0625
4
[ "MIT" ]
permissive
# Given a sentence, return an array containing every other word. # Punctuation is not part of the word unless it is a contraction. # In order to not have to write an actual language parser, there won't be any punctuation too complex. # There will be no "'" that is not part of a contraction. # Assume each of these char...
true
92ea2e013567124da6d7dfa6d8111ba10449b6fd
Ruby
SpiritBreaker226/ruby_fundamentals1
/exercise3.rb
UTF-8
163
3.859375
4
[]
no_license
puts "What is your name?" name = gets.chomp puts "Hi #{name}!" puts "What is your age?" age = gets.chomp puts "#{name} was born in: #{Time.now.year - age.to_i}"
true
705a0171c46f39b92a2bf4a630c2d4e4a581afd0
Ruby
Meloman4eg/kaize_test
/tests/fizzbuzz_test.rb
UTF-8
319
2.734375
3
[]
no_license
require "test_helper" class FizzBuzzTest < Minitest::Test def setup @test = FizzBuzz.new end def test_fizzbuzz assert_equal @test.fizzbuzz(3), "Fizz" assert_equal @test.fizzbuzz(50), "Buzz" assert_equal @test.fizzbuzz(15), "FizzBuzz" assert_equal @test.fizzbuzz(5175), "FizzBuzz" end end
true
485c8c2a6c4fe2337421405b66fa65b2b1f12495
Ruby
deloristhompson/learn-oop
/lib/rectangle.rb
UTF-8
860
3.703125
4
[]
no_license
class Rectangle attr_accessor :length, :width, :area, :x, :y, :diagonal def initialize(length, width, x = nil, y = nil) @length = length @width = width @area = length * width @x = x @y = y @square_root = length * length + width * width @diagonal = Math.sqrt(@square_root) ...
true
b0604400f80fe6f5db9e008d2ab8ad8f370e4206
Ruby
muroj/oo-tic-tac-toe-bootcamp-prep-000
/lib/tic_tac_toe.rb
UTF-8
3,191
4.375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe WIN_COMBINATIONS = [ [0, 1, 2], # Row wins [3, 4, 5], [6, 7, 8], [0, 3, 6], # Column wins [1, 4, 7], [2, 5, 8], [0, 4, 8], # Diagonal wins [2, 4, 6] ] def initialize @board = [" ", " ", " ", " ", " ", " ", " ", " ", " "] end # # Prints the tic...
true