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
f69a3e6888939daffec435d125ee7d9c1c53a709
Ruby
bleavs/ruby-collaborating-objects-lab-web-080717
/lib/song.rb
UTF-8
376
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_accessor :name, :artist def initialize(name) @name = name end def artist_name=(name) @artist = Artist.find_or_create_by_name(name) end def self.new_by_filename(file_name) arr = file_name.split(" - ") new_song = Song.new(arr[1]) new_song.artist_name=(arr[0]) n...
true
5d2d81a9711c686f918563c195909f2d1b19dbba
Ruby
funkorogashi/programming_ideas
/chapter2/04_decode_msg/01.rb
UTF-8
1,140
3.453125
3
[]
no_license
# アルファベットと記号 ALPHABET_L = [*'A'..'Z'] ALPHABET_S = [*'a'..'z'] MARKS = ["!", "?", ",", ".", " ", ";", "\"", "'"] # モード一覧 MODE_ALPHABET_L = "1" MODE_ALPHABET_S = "2" MODE_MARKS = "3" def decode_message(message) message_array = message.split(",") decoded_message = "" mode = MODE_ALPHABET_L numval = 27 message_arr...
true
d05831ece1e10d5636c15b763753cc819321fb86
Ruby
carynkeffer/nom_nom_nom
/lib/pantry.rb
UTF-8
562
3.09375
3
[]
no_license
require './lib/ingredient' class Pantry attr_reader :ingredients def initialize @ingredients = [] end def stock {} end def stock_check(ingredient) if @ingredients.include?(ingredient) @ingredients else 0 end end def restock(ingredient, amount) ingredient = Ingred...
true
115beb89921232540bc2279fe7c152c432a8953b
Ruby
c0nspiracy/advent-of-code-2019
/day_22/part_2.rb
UTF-8
1,088
3.609375
4
[]
no_license
# frozen_string_literal: true # Calculates large integer powers with the Exponentation by squaring method # https://en.wikipedia.org/wiki/Exponentiation_by_squaring def exp_by_squaring(a, b, exponent, deck_size) return [1, 0] if exponent.zero? if exponent.even? exp_by_squaring(a * a % deck_size, (a * b + b) %...
true
3c669140bc6bac2e830ffd0c25dd9aa8cbcac91f
Ruby
dengsauve/College-Work
/2017 Spring/CIS283/jukebox/Jukebox.rb
UTF-8
1,826
3.875
4
[]
no_license
############################################################ # # Name: Dennis Sauve # Date: 04/22/2017 # Assignment: Jukebox # Class: CIS 283 # Description: Jukebox holds the Jukebox class which has # an array of song objects. # [X] Write another class called...
true
fb788c3f04b4dd2691ec9fc2dd5429db94b33c2b
Ruby
thesleevecode621/school-domain-online-web-pt-051319
/lib/school.rb
UTF-8
377
3.4375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class School attr_accessor :name, :roster def initialize(name) @name = name @roster = {} end def add_student(name, grade) roster[grade] = [] unless roster[grade] roster[grade] << name end def grade (i) roster[i] end def sort sorted = {} roster.each do |key, values| ...
true
560e19d527672f4ec05e63ab4ec958d9a1087927
Ruby
mt3/vnews
/lib/vnews/opml.rb
UTF-8
1,360
2.625
3
[ "MIT" ]
permissive
require 'nokogiri' require 'vnews/feed' require 'vnews/constants' class Vnews class Opml CONCURRENCY = 18 def self.import(opml) sqlclient = Vnews.sql_client doc = Nokogiri::XML.parse(opml) feeds = [] doc.xpath('/opml/body/outline').each_slice(CONCURRENCY) do |xs| xs.each do...
true
b1d73c85ce0105e212b8bc7018d96ad756322ad1
Ruby
IrinaSTA/oystercard_day3
/lib/oystercard.rb
UTF-8
995
3.390625
3
[]
no_license
require 'pry' require 'journey' class Oystercard attr_reader :balance, :start_station, :trips MINIMUM_BALANCE = 1 MAXIMUM_BALANCE = 90 MINIMUM_FARE = 1 def initialize @balance = 0 @trips = [] end def topup(amount) raise "Cannot topup £#{amount}: maximum balance of £#{MAXIMUM_BALANCE}" if ...
true
24d3a60d97d1f0d6eaa7eca37bd51b4750892ddc
Ruby
wayne5540/trikeapps
/app/big_five_results_text_serializer.rb
UTF-8
1,559
3.15625
3
[ "MIT" ]
permissive
class BigFiveResultsTextSerializer SCORE_KEYS = ['EXTRAVERSION', 'AGREEABLENESS', 'CONSCIENTIOUSNESS', 'NEUROTICISM', 'OPENNESS TO EXPERIENCE'].freeze def initialize(text) @text = text end def hash basic_info.merge score_info end private def basic_info { 'NAME' => my_name, 'EMA...
true
ac985881a4497d40ed9ba89e2dec38b351e1d9ef
Ruby
drunkwater/leetcode
/medium/ruby/c0223_442_find-all-duplicates-in-an-array/00_leetcode_0223.rb
UTF-8
589
3.3125
3
[]
no_license
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #442. Find All Duplicates in an Array #Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. #F...
true
8a1fe5ba0c7b1b8ba876d5f5424d53c5ca7b1d70
Ruby
ryoqun/wavefile
/lib/wavefile/buffer.rb
UTF-8
4,919
3.359375
3
[ "MIT" ]
permissive
module WaveFile # Error that is raised when an attempt is made to perform an unsupported or undefined # conversion between two sample data formats. class BufferConversionError < StandardError; end # Represents a collection of samples in a certain format (e.g. 16-bit mono). # Reader returns sample data conta...
true
8aabb1750efd3a6bec07b484b6c872fe82090af7
Ruby
jjshanks/adventofcode-legacy
/2015/day14/part2.rb
UTF-8
3,524
3.59375
4
[]
no_license
=begin --- Day 14: Reindeer Olympics --- This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally to recover their energy. Santa would like to know which of his reindeer is fastest, and so he has them race. Reindeer can only either be flying (always at their top speed) or restin...
true
08e21451adfb22762c457f2300c3fa2dbd084e7a
Ruby
javsterati/ruby-oo-object-relationships-has-many-through-atlanta-web-111819
/lib/customer.rb
UTF-8
910
3.703125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Customer #has many meals #has many waiters thru said meals attr_accessor :name @@all = [] def initialize(name, age) @name = name @age = age @@all << self end def new_meal(waiter,total, tip=0) Meal.new(waiter, self, total, tip) end def me...
true
82ba88a4ada4ba6eba41c5a89cfd6ca65f1a7b58
Ruby
mgn200/imdb_playfield
/lib/imdb_playfield/netflix_dsl.rb
UTF-8
688
2.765625
3
[]
no_license
module ImdbPlayfield # DSL for easier use of filters. # @example # Filters movie collection stored in Netflix with DSL # Netflix.by_country.usa => Array of movies created in USA # @see Netflix#initilize # @see NetflixReference module NetflixDSL # @param keys [Array] keys from {MovieCollection::KEY...
true
902e83c2013a0b359dfe2e56490546d7f821e157
Ruby
7omich/AtCoder
/codeFlyer/B_洋菓子店.rb
UTF-8
265
3.546875
4
[]
no_license
# AC a, b, n = gets.chomp.split(' ').map(&:to_i) x = gets.chomp x.each_char do |c| if c == 'S' a -= 1 if a > 0 elsif c == 'C' b -= 1 if b > 0 elsif c == 'E' if a >= b && a > 0 a -= 1 elsif b > 0 b -= 1 end end end p a p b
true
07c035198d4ec58b24a37d4f77d076f988785096
Ruby
ukutaht/farkle
/lib/farkle/die.rb
UTF-8
446
3.25
3
[]
no_license
module Farkle class Die attr_accessor :scored, :value alias_method :scored?, :scored def initialize(opts = {}) @scored = opts.fetch(:scored) { false } @value = opts.fetch(:value) { rand(6) + 1 } end def roll self.value = rand(6) + 1 end def mark_unscored! self....
true
c0c2c859e2ca124bf00b7802765d198523275cdf
Ruby
alansparrow/learningruby
/seekfileexample1.rb
UTF-8
153
2.96875
3
[]
no_license
f = File.new("test1.txt", "r") while a = f.getc puts a.chr f.seek(5, IO::SEEK_CUR) end t = File.mtime("test1.txt") puts t.hour puts t.min puts t.sec
true
42da82525aca3c9eaf676b146050e6a9edb6dc4a
Ruby
cmsrrent/ruby-training
/ex_oop_3.rb
UTF-8
655
4.28125
4
[]
no_license
class Thing # short hand way of getters and setters # also creates class variables of same name attr_reader :description attr_writer :description def initialize( aName, aDescription ) @name = aName @description = aDescription end # long hand way of getters and setters # get accessor def name return @n...
true
8e8878b044f4153a2400ae9ea938b02b559a3a79
Ruby
PlasticLizard/Cubicle
/lib/cubicle/duration.rb
UTF-8
1,962
2.703125
3
[ "MIT" ]
permissive
module Cubicle class Duration < Measure attr_accessor :duration_unit, :begin_milestone, :end_milestone, :timestamp_prefix def initialize(*args) super self.duration_unit = options(:in) || :seconds self.timestamp_prefix = options :timestamp_prefix, :prefix self.expression_type = :javasc...
true
dd6d84dc386902bf077ba73a3b347f1e52908d8c
Ruby
silvanagv/my-select-001-prework-web
/lib/my_select.rb
UTF-8
200
3.375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_select(collection) select_ary = [] x = 0 while x < collection.length if yield collection[x] select_ary << collection[x] end x = x + 1 end return select_ary end
true
fae11cc9b6f10660c0b341d45303608e5b21b80e
Ruby
hhouston/appacademy-prep-master
/w2/w2d4/exercises/lib/board.rb
UTF-8
2,913
4.21875
4
[]
no_license
require 'byebug' class Board attr_accessor :grid, :winner, :marks def self.new_grid Array.new(3) { Array.new(3)} end def initialize(grid = Board.new_grid) @grid = grid @winner = nil @marks = [:X, :O] end def [](pos) row, col = pos grid[row][col] end def []=(pos, value) ro...
true
80b95aad8f40bc5e010ef41e6fa1ad1bbb30a50d
Ruby
marwahaha/rasta
/label.rb
UTF-8
966
2.765625
3
[]
no_license
class Label < String def fetch_as_constant env context = env.lookup("self") case self when /\A::/ self.gsub(/\A::/, '').fetch_as_constant Kernel when /::/ self.split(/::/).inject(context) do |m, e| m.const_get(e) end else context.const_get(self) end end def ...
true
5876d0fefb4a1d400394c544e45a653e6b387ca6
Ruby
marcallan34/learn_ruby
/01_temperature/temperature.rb
UTF-8
168
3.609375
4
[]
no_license
#write your code here def ftoc(fahrenheit) final = (fahrenheit - 32)/1.8 return final.ceil end def ctof(celsius) final = (celsius * 1.8) + 32 return final end
true
2eb3fcac06a6c393f5e12e43ef903df885cdfbf0
Ruby
SHiroaki/Ruby
/prac/control.rb
UTF-8
660
4.125
4
[]
no_license
# coding: utf-8 =begin 真:falseとnil以外すべて 偽:falseとnil 真偽値を返すメソッドの末尾には?をつける =end a = 20 if a >= 10 then print("bigger\n") end #if 条件 then(thenは省略できる) # do #end(忘れがち) #が基本 a = 8 if a > 10 then print "bigger\n" else print "smaller\n" end #繰り返し i = 1 while i <= 10 print i, "\n" i += 1 end # times 繰り返す回数が...
true
47be8c45b2911c76fac1a598f6c563a26640f178
Ruby
psagan/slackbot-rubydoc
/lib/client/websocket_request_data.rb
UTF-8
1,570
3.03125
3
[]
no_license
# This class is responsible for handling websocket request data - which will be # send to websocket module Client class WebsocketRequestData # instance attribute on singleton's class @id = 0 # here we have class method class << self # Public: returns incremented id - to have it # ...
true
e580aa9c216116e566715ac292afb9a1c6a29bdc
Ruby
chelsten/mini-project-2
/mp2.rb
UTF-8
1,500
3.828125
4
[]
no_license
require 'csv' require './crud_function' class Employee def show_menu puts "Welcome to Company Directory Management System: " puts "1 - Add new employee" puts "2 - Read existing employee" puts "3 - Update existing employee" puts "4 - Delete existing employee" input = gets.chomp case inpu...
true
ae28b79f11bf013d73db88f5006c8bee1e144037
Ruby
danielacodes/numerology-app
/spec/people_show_spec.rb
UTF-8
794
2.5625
3
[]
no_license
require 'spec_helper' describe "Our Person Show Route" do include SpecHelper before (:all) do @person = Person.create(first_name: "Miss", last_name: "Piggy", birthday: DateTime.now.utc - 40.years ) @birth_path_num = Person.get_birth_path_number(@person.birthday.strftime("%m%d%Y")) end after (:all) do...
true
2c843598663e012f009b213f4dea744095208cfb
Ruby
mattdillabough/reddish_rails
/app/models/user.rb
UTF-8
1,072
2.515625
3
[]
no_license
class User < ActiveRecord::Base has_many :votes has_many :links, through: :votes has_one :reset_token RE_USERNAME = /\A[A-Za-z0-9_.]+\z/ RE_EMAIL = /\A[A-Za-z0-9_.]+@[A-Za-z0-9_.]+\z/ # This association declaration is the inverse of the "belongs_to" on the link.rb # It indicates that a given object...
true
6dee57af474eae4bd7e4ff73e07ab5f649c6931d
Ruby
brenufernandes/Homework3
/Hw3.rb
UTF-8
2,036
4.59375
5
[]
no_license
=begin Breno Fernandes de Andrade - CS270. Assignment #3 Description: Checkout of books using class concept input: Book's title and name Output: Checkout book's name =end #The class book is used for the constructor to attribute the variable book name and the writer class Book #User the method attr_reader and attr_acess...
true
66e0c1c69d8e80960e121ee6ee67ad473cda2b3d
Ruby
Javier-Machin/music-beast-manager-api
/app/controllers/concerns/response.rb
UTF-8
577
2.609375
3
[]
no_license
module Response def json_response(object, status = :ok, serializer = '') if (serializer == 'index') object[:tracks] = object[:tracks].map do |track| { id: track.id, title: track.title, artist: track.artist, created_by: track.created_by } end ...
true
a398e0159181cbb34055d1f34c0da311c536dab5
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/grade-school/61441e359cc945efb5ee9c79d20a1994.rb
UTF-8
312
3.34375
3
[]
no_license
class School attr_reader :db def initialize @db = Hash.new { Array.new } end def add(name, grade) db[grade] = db[grade] + [name] end def grade(grade) db[grade] end def sort Hash[ db.map { |grade, students| [grade, students.sort] }.sort ] end end
true
2e19646b3ad163a94c81a8c92e4a537a482d51c9
Ruby
kathleen-carroll/flash_cards
/lib/deck.rb
UTF-8
440
3.4375
3
[]
no_license
class Deck attr_reader :deck, :cards def initialize(cards) @cards = cards #@deck = [] end # def add_card(cards) # @deck << cards # end def count @deck.count end def cards_in_category(category) @cards.find_all do |card| #require "pry"; binding.pry category == card.cat...
true
16be7c8ee2e6e41c6ae7b263ca9476bb220568fd
Ruby
halo/LinkLiar
/lib/macs/vendor.rb
UTF-8
2,357
2.59375
3
[ "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
module Macs class Vendor def initialize(name:) @name = name @prefixes = [] end def name return 'Cisco' if @name == 'Cisco Systems' return 'Huawei' if @name == 'Huawei Technologies' return 'Samsung' if @name == 'Samsung Electronics' return 'HP' if @name == 'Hewlett Pack...
true
01418731f7ea96bcbcc8e6b56e9a602e2a30321b
Ruby
DYDamaschke/Launch_School
/exercises_small_problems/Easy_3/arithmetic.rb
UTF-8
301
3.4375
3
[]
no_license
operators = %w(+ - / * % **) puts "=> Please enter the first number: " number1 = gets.chomp.to_f puts "=> Please enter the second number: " number2 = gets.chomp.to_f operators.each do |operator| puts "#{number1} #{operator} #{number2} = " + "#{eval("#{number1}#{operator}#{number2}")}" end
true
7aa4e2de68f0a8f9cf21d14382b6a943330071a3
Ruby
threedaymonk/uk_postcode
/spec/giro_postcode_spec.rb
UTF-8
2,088
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "OGL-UK-3.0" ]
permissive
require "uk_postcode/giro_postcode" describe UKPostcode::GiroPostcode do let(:subject) { described_class.instance } describe ".parse" do it "parses the canonical form" do pc = described_class.parse("GIR 0AA") expect(pc).to be_instance_of(described_class) end it "parses transcribed 0/O and...
true
69d63087e50c062ef132e40b0925d849f54b03ec
Ruby
akoliag/katas
/CODEWARS/Exercise_53_add_words.rb
UTF-8
821
3.96875
4
[]
no_license
# https://www.codewars.com/kata/adding-words-part-i/train/ruby class Arith def initialize(base) @base = base end def add(word) collection = { 1=> "one", 2=> "two", 3=> "three", 4=> "four", 5=> "five", 6=> "six", ...
true
5f3a0ec6ab622a97747a1e1152822c58b3ad0e5e
Ruby
ezy023/easy_challenges
/41.rb
UTF-8
244
3.0625
3
[]
no_license
puts "Enter a sentence to see it pretty" sentence = gets.chomp puts '*' * (sentence.length+4) puts '*' + (' ' * (sentence.length+2)) + '*' puts '* ' + sentence + ' *' puts '*' + (' ' * (sentence.length+2)) + '*' puts '*' * (sentence.length+4)
true
bce5f90e4892cb9b7c65a790a7f286dd5553bcf9
Ruby
mintyfresh/pone-points
/app/forms/create_group_form.rb
UTF-8
937
2.53125
3
[]
no_license
# frozen_string_literal: true class CreateGroupForm < ApplicationForm # @return [Pone] attr_accessor :owner attribute :name, :string attribute :description, :string validates :owner, presence: true validates :name, presence: true, length: { maximum: Group::NAME_MAX_LENGTH } validates :description, leng...
true
264653c10fb5a4470cc4ff4b685cafc97a8c4219
Ruby
sparsons808/W2D5
/todo/item.rb
UTF-8
834
3.140625
3
[]
no_license
class Item attr_accessor :title, :description attr_reader :deadline def self.valid_date?(date_str) month = ('01'..'12').to_a day = ('01'..'31').to_a if month.include?(date_str[5..6]) && day.include?(date_str[-2..-1]) return true else return false ...
true
3bc59a3d633c26274790b5ebfaa2784ba080672a
Ruby
garcia50/idea_box
/spec/features/users/authentication_user_spec.rb
UTF-8
3,150
2.59375
3
[]
no_license
require 'rails_helper' describe "As an unathenticted use" do describe "when I visit the landing page I see a create a new user link" do scenario "when I click on the link I can create an account" do visit root_path click_on 'Create An Account' expect(current_path).to eq(new_user_path) e...
true
b4f801ae5571a02a27689fc3923823243e29b905
Ruby
dallinder/small_problems_ls
/easy_7/3.rb
UTF-8
153
3.40625
3
[]
no_license
def word_cap(string) words = string.split words.map do |word| word.capitalize! end words.join(' ') end puts word_cap('four score and seven')
true
a21ac32d7c186a97bcca3044adade16c345b9cac
Ruby
brunoao86/radar-talentos-wine
/09_iteracoes/1_while.rb
UTF-8
64
3.3125
3
[]
no_license
x = 10 while x > 0 do puts "valor de x: #{ x }" x -= 1 end
true
4ab0e65b8594bd5e7cc4a3e917bc3b6415c3eb22
Ruby
chrisswk/advanced_calculator
/simplifiers/evaluation_simplifier.rb
UTF-8
228
2.765625
3
[ "MIT" ]
permissive
class EvaluationSimplifier def self.run(tree) if tree.operator? && tree.left.numeric? && tree.right.numeric? tree.class.new tree.operator.call(tree.left.value, tree.right.value) else tree end end end
true
77efb98bd3baafdb01138c3108672451e456998d
Ruby
panjiw/Team-Player
/app/controllers/users_controller.rb
UTF-8
7,016
2.515625
3
[]
no_license
# # TeamPlayer -- 2014 # # This file deals with creating a user and signing him in. # It returns a status code indicating success or failure, # as well as a list of reasons for failure if necessary # class UsersController < ApplicationController before_action :signed_in_user, only: [:viewgroup, :view_pending_groups, ...
true
1f202f404d958ac0d1f97cb6319aa44042acde88
Ruby
arjunchib/aoc2020
/day2/part1.rb
UTF-8
399
3.0625
3
[]
no_license
def process(file) lines = File.readlines(file) lines.map {|line| validate(line) ? 1 : 0}.sum end def validate(line) policy,password = line.split(': ') range,term = policy.split(' ') lower,upper = range.split('-').map {|a| a.to_i} count = password.count(term) lower <= count and count <= upper end if __FI...
true
f6532596934455fe89f673f5dba041769fd9e267
Ruby
Brahimndaw/simple-loops-001-prework-web
/simple_looping.rb
UTF-8
848
4.15625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# REMEMBER: print your output to the terminal using 'puts' def loop_iterator(number_of_times) phrase = "Welcome to Flatiron School's Web Development Course!" count = 0 loop do puts phrase count += 1 break if count == 7 end end def times_iterator(number_of_times) 7.times do puts "Welcome to Flatiron...
true
6d0a43bcc93ab95f83492264bf7fe900eb158a0e
Ruby
learn-co-students/atlanta-web-021720
/05-oo-review/tools/console.rb
UTF-8
329
2.6875
3
[]
no_license
require_relative '../config/environment.rb' # Recipes recipe_one = Recipe.new("rice_casserole") recipe_two = Recipe.new("hot_dog") recipe_three = Recipe.new("beans") # Users user_one = User.new("sam", "thomas") # Ingredients beans = Ingredient.new("beans") # Allergies peanut = Allergy.new(user_one, beans) bin...
true
997972565a6b2b615f3dce73cb5c98a7edc7f8fd
Ruby
elinaDangol/jan24
/spec/app/models/book_spec.rb
UTF-8
547
3.125
3
[]
no_license
# Book.length("computer science") # => 16 require 'rails_helper' describe Book do describe '.length' do context 'when user provides book name' do subject(:length) { described_class.length("computer science") } it 'gives length of the book' do expect(length).to eql(16) end end...
true
22842b193d39217bd36e0cf6855c1da287ae14a5
Ruby
mitcha16/SalesEngine
/test/invoice_items_repo_test.rb
UTF-8
5,318
2.59375
3
[]
no_license
require_relative '../test/test_helper' class InvoiceItemsRepoTest < Minitest::Test def setup @file = File.expand_path("../test/fixtures/invoice_items.csv", __dir__) end def test_it_can_hold_a_new_invoice_item data = FileReader.new.read(@file) repo = InvoiceItemsRepository.new(data, "sales_engine") ...
true
34905e4cf83b5c0d0ae923f766c1e0d0e27c76f8
Ruby
LeoBorquez/Stock
/app/models/stock.rb
UTF-8
535
2.578125
3
[]
no_license
class Stock < ApplicationRecord has_many :user_stocks has_many :users, through: :user_stocks def self.find_by_ticker(ticker_symbol) where(ticker: ticker_symbol).first end def self.new_from_lookup(ticker_symbol) begin StockQuote::Stock.new(api_key: ENV["API_KEY"]) lookep_up_stock = Stock...
true
7d3915ca30da136bf10f2ef1acc06e13b3cb37c8
Ruby
amso100/livescript-declarations
/obj.rb
UTF-8
239
2.5625
3
[]
no_license
class Obj < Node def parseNextNode(ast_json) @items = [] ast_json["items"].each { |inner_prop| @items << parseAstFromJsonToNodes(inner_prop) } end def get_vars() @items.each { |item| item.get_vars() } end end
true
c79f42487f8e044310d4ca6690b1e08f9155eb98
Ruby
Hiromi-Kai/TEA_YOURSELF
/tea_yourself.rb
UTF-8
524
3.328125
3
[]
no_license
require 'telegraph' module TEAYOURSELF class << self public def do(text) delete_last_space(delete_space(tuu_to_yourself(tonn_to_tea(Telegraph.text_to_morse(text))))) end private def tonn_to_tea(text) text.gsub('.','TEA ') end def tuu_to_yourself(text) text.gsub('-','YOUR...
true
4eb89463491576611cbdd4827b1bcc58341e32e7
Ruby
yune-kotomi/dokusho-biyori-ishibashi
/bin/bot/operation/comics.rb
UTF-8
551
2.578125
3
[ "MIT" ]
permissive
require 'cgi' # grep -h "<abstract>" jawiki-latest-abstract* |grep '漫画作品'>comic_src.txt open(ARGV[1], 'w') do |f| open(ARGV[0]).read.split("\n"). map{|s| s.gsub(/<.?abstract>/,'') }. map{|s| CGI.unescapeHTML(s) }. map{|s| s.gsub(/[((].+[))]/, '') }. map{|s| s.split(/[』」  ]/).first }. map{|s| s.s...
true
08d6018a83d38b86ea1561823b624e9984a96652
Ruby
rails/sprockets
/lib/sprockets/context.rb
UTF-8
9,078
2.609375
3
[ "MIT" ]
permissive
# frozen_string_literal: true require 'rack/utils' require 'set' require 'sprockets/errors' require 'delegate' module Sprockets # They are typically accessed by ERB templates. You can mix in custom helpers # by injecting them into `Environment#context_class`. Do not mix them into # `Context` directly. # # ...
true
404b4f07b9e8e9417477f76d92e63199b1b11538
Ruby
RReiso/ruby-practice
/concepts/string-regex.rb
UTF-8
2,146
3.515625
4
[]
no_license
# gsub p '1 esmu26 5'.sub(/\d+/) { |num| num.next } #"2 esmu26 5" First occurance p '1 esmu26 5'.gsub(/\d+/) { |num| num.next } #"2 esmu27 6" p '1 esmu26 5'.gsub(/\d+/, &:next) #"2 esmu27 6" # regex p /abcde/.match("hello abcd") # nil p /abc/.match("hello abcd") #<MatchData "abc"> p /abc/.match?("hello abcd") # true p...
true
c76a122748a53680b1488f8ee3e4fedd441a25bb
Ruby
Ezmyrelda/ezmy-tarot
/tarot.rb
UTF-8
1,651
3.6875
4
[]
no_license
#!/usr/bin/ruby print "You would like your fortune? Please tell me your name; or should I read that as well?" name = gets.chomp print "How many cards would you like? " reading = gets.chomp deck = [ 0 => 'zed', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8...
true
3a8f9e0867477d5022eb98600904ad2e11c0c1e3
Ruby
mfham/chartjs_sample
/create_data_for_chartjs.rb
UTF-8
752
2.875
3
[]
no_license
require 'csv' require 'optparse' require 'time' opt = OptionParser.new params = ARGV.getopts("i:") raise StandardError, 'Please specify -i option' if params['i'].nil? h_date = Hash.new {|h, k| h[k] = 0 } h_person = Hash.new {|h, k| h[k] = 0 } CSV.foreach("data/#{params['i']}", :headers => [:page_id, :yyyymmdd, :nam...
true
2d2e2aee3247bd73b8797bc8442b6ee07a7b6c3f
Ruby
andrewpetrenko1/codebreaker_web
/lib/codebreaker_web.rb
UTF-8
3,131
2.578125
3
[]
no_license
module RakeWeb class CodebreakerWeb def self.call(env) new(env).response.finish end @@game = CodebreakerAp::Game.new def initialize(env) @request = Rack::Request.new(env) end def response case @request.path when '/' then Rack::Response.new(render('menu.html.erb')) ...
true
8317fc157865d1cdc77522c032027c9626d4c30e
Ruby
michaelbyrd/opal-rails-example
/app/assets/javascripts/greeter.js.rb
UTF-8
282
2.828125
3
[]
no_license
# app/assets/javascripts/greeter.js.rb class Sample def initialize(num) @num = num end def num @num end end s = Sample.new(4) puts s.num # Dom manipulation require 'opal-jquery' Document.ready? do Element.find('body > header').html = '<h1>Hi there!</h1>' end
true
bd1b9aeb0e7a9ba28e6cd2ed6907670a7f410663
Ruby
spotswoodb/podcast_cli
/lib/podcast/scraper.rb
UTF-8
546
2.734375
3
[ "MIT" ]
permissive
class Scraper def self.get_data html = URI.open("https://toppodcast.com/top-podcasts/") doc = Nokogiri::HTML(html) container = doc.css('div.allTopPodcasts div.podcastRow') container.each do |el| title = el.css('h3').text.strip desc...
true
6aed4331fe71e57238dc61620f5df491e4b8cd0e
Ruby
Shopify/chroma
/lib/chroma/rgb_generator/from_string.rb
UTF-8
3,099
2.640625
3
[ "ISC" ]
permissive
module Chroma module RgbGenerator class FromString < Base # Returns the regex matchers and rgb generation classes for various # string color formats. # # @api private # @return [Hash<Symbol, Hash>] def self.matchers @matchers ||= begin # TinyColor.js matchers ...
true
4cc158f199ee80266bafbad7160269a6effbce74
Ruby
stevenjackson/finances
/features/support/test_database.rb
UTF-8
1,555
2.609375
3
[ "MIT" ]
permissive
require 'fig_newton' require 'sequel' class TestDatabase def initialize @db = Sequel.connect(DB_URI) end def insert_category(category, amount) @db[:categories].insert :name => category, :budget => amount end def debit_category(category, amount, date_applied=Time.now) @db[:debits].insert :catego...
true
5ef5f065488cebed11f0c62ebcd1a3a8e1aff451
Ruby
Anthorage/Necrolis
/world1.rb
UTF-8
2,808
2.59375
3
[]
no_license
require_relative 'world' class World1 < World def update(dt) super(dt) game_logic(dt) @wavesys.update(dt) if @state == 0 || @state == 1 || @state == 8 self.next_text() if @adv_timer.update(dt) elsif @state == 2 if @units.size > 0 ...
true
c5c40528f9a1187d1db6a7c65f1e16e020a5e836
Ruby
kishaningithub/udacity-ruby-nanodegree-projects
/rbnd-udacitask-part1-master/Udacitask/todolist.rb
UTF-8
2,951
3.46875
3
[]
no_license
require 'yaml' class TodoList PERSISTENCE_DIR = "persisted_list" attr_reader :title, :items def initialize(list_title) if persisted? list_title then todo_lst = get_persisted_todo_lst(list_title) @title = todo_lst.title @items = todo_lst.items ...
true
2d4eca67b1f9fede7cd5edabd6ea0126364cbe75
Ruby
zoeabryant/ma-airport
/lib/airport.rb
UTF-8
631
3.34375
3
[]
no_license
require_relative 'weather' class Airport include Weather def planes @planes ||= [] end def allow_landing?(plane) currently_good_weather = is_good_weather? if currently_good_weather puts "Landing successful! What a beautiful clear day!" planes << plane else puts "Landing not permitted, wait unt...
true
20f05f4a33e521bde4ecfd1ea1a3448343a5bb8c
Ruby
sano2019/rails-longest-word-game
/app/controllers/games_controller.rb
UTF-8
1,350
3.15625
3
[]
no_license
class GamesController < ApplicationController def new @letters = Array.new(10) { ('A'..'Z').to_a.sample } end def score @answer = "" if included? check_api if @response["found"] == true @score = @response["length"].to_i @answer = "Congratulations! #{params['word']} is a vali...
true
21f39a88b57c22e9e0eee03012e462e359106d74
Ruby
raphael27atm/find_user_github
/app/models/user.rb
UTF-8
413
2.625
3
[]
no_license
class User include HTTParty base_uri "https://api.github.com" attr_accessor :name def initialize(name) @options = {query: {q: name}} end def search response = self.class.get("/search/users", @options) if response.success? response['items'] else raise response end end ...
true
21e8ac6f78946642de7d12ef9636cc024ecdeb21
Ruby
erikabalbino/codecore_may2018
/week4/Day20_Ruby_OOP/labs/Animals/animal_example.rb
UTF-8
196
3.40625
3
[]
no_license
require "./animal.rb" require "./dog.rb" require "./cat.rb" dog1 = Dog.new("Erika", "Red") cat1 = Cat.new("Juliana", "Black", 2) puts "Dogs:" dog1.eat dog1.walk puts "Cats" cat1.eat cat1.walk
true
61620f5f844cdc250477be15a2d1cfc6f95e9b7b
Ruby
philipd97/ruby_on_rails
/section2/crud.rb
UTF-8
846
2.796875
3
[]
no_license
module Crud require 'bcrypt' puts "Module CRUD activated" # def self.create_hash_digest(password) def create_hash_digest(password = nil) BCrypt::Password.create(respond_to?(:password) ? self.password : password) end # def self.verify_hash_digest(password) def verify_hash_digest BCrypt::Password....
true
343d50a6992b0827a12e1c751a0dce2fc064cbb0
Ruby
TheMartonfi/math_game
/Player.rb
UTF-8
246
3.46875
3
[]
no_license
class Player attr_accessor :name, :current_lives, :total_lives def initialize(n, l) self.name = n self.current_lives = l self.total_lives = self.current_lives end def get_answer print "> " $stdin.gets.chomp end end
true
92285104c4a70cba3c779cb2d3ae3761c574d9a1
Ruby
vidriloco/wikicleta-Left-panel
/app/models/bike_status.rb
UTF-8
1,012
2.625
3
[]
no_license
class BikeStatus < ActiveRecord::Base belongs_to :bike validates_presence_of :bike_id, :concept def self.find_all_for_bike(bike_id) categories = Bike.category_list_for(:statuses).invert find(:all, :conditions => {bike_id: bike_id }).each do |bike_status| categories[Bike.category_symbol_for(:statu...
true
f84703a84619ea1af2d952a50c3eaae000db80e0
Ruby
askay/coding_standards_setup
/prep.rb
UTF-8
1,322
2.515625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby # try to determine the root of the project # if there's .git, then bail if !(Dir.exists? '.git') print "Can't find project root\n" abort end require 'fileutils' print "Installing clang-format\n" system("brew install clang-format") scriptDirectory = File.dirname(__FILE__) binDirectory = File....
true
7cfe63de5b99d256f3ac796bc4a8dcb99c084485
Ruby
qqdipps/LeetCode-DS-Algos-Other
/string/reverse_words_in_a_string_iii_557.rb
UTF-8
1,043
3.90625
4
[]
no_license
# Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. # # Example 1: # Input: "Let's take LeetCode contest" # Output: "s'teL ekat edoCteeL tsetnoc" # Note: In the string, each word is separated by single space and there wil...
true
a2703f850334e75c1b245f3e9005e86336322be6
Ruby
mohammadaliawan/ls-prep
/ruby_basics/debugging/confucius_says.rb
UTF-8
840
4.21875
4
[]
no_license
def get_quote(person) if person == 'Yoda' 'Do. Or do not. There is no try.' elsif person == 'Confucius' 'I hear and I forget. I see and I remember. I do and I understand.' elsif person == 'Einstein' 'Do not worry about your difficulties in Mathematics. I can assure you mine are still greater.' end e...
true
fc8db7257239b4737ec2b8028cabacdd748d66ff
Ruby
LesOsorio/parrot-ruby-online-web-prework
/spec/parrot_spec.rb
UTF-8
629
3.203125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative './spec_helper' require_relative '../parrot.rb' # Code your solution in this file def '#parrot'(default) puts "please let me pass" end it 'should return the default phrase, "Squawk!" when called without any arguments' do phrase = parrot expect(phrase).to eq("Squawk!") end it 'should...
true
3901d955306948bdfc93b3f3019fe071bdd02c0f
Ruby
bih/stripe-ruby
/lib/stripe/reader.rb
UTF-8
760
2.890625
3
[ "MIT" ]
permissive
module Stripe class Reader def self.parse(reader_string, additional_params = {}) parsed = reader_string.to_s.split(/(%B)([0-9]{16})(\^)([a-zA-Z ]*)(\/)([a-zA-Z ]*)(\^)([0-9]{2})([0-9]{2})(.)*?$/) card = Hash.new card[:number] = parsed[2].to_s card[:name] = "#{parsed[6]} #{parsed[4]}"....
true
88b2f34b1942cf3e64c78f187b2de438ca0c9808
Ruby
sagemlee/war_or_peace
/war_or_peace_runner.rb
UTF-8
3,868
3.28125
3
[]
no_license
require './lib/card' require './lib/deck' require './lib/player' require './lib/turn' require './lib/game' require 'pry' # suits = [hearts, spades, diamonds, clubs] # values = ["ace", "2","3","4","5","6","7","8","9","10","jack","queen","king"] # ranks = [2,3,4,5,6,7,8,9,10,11,12,13,14] standard_deck = [] standard_dec...
true
6874f648863470fac22c14b8a9a5bcd08479951e
Ruby
gnmerritt/bitbar-plugins
/Lifestyle/todoNotePlan.15m.rb
UTF-8
6,824
2.53125
3
[]
no_license
#!/usr/bin/env ruby # coding: utf-8 # <bitbar.title>NotePlan Todo in Colour</bitbar.title> # <bitbar.version>v1.0</bitbar.version> # <bitbar.author>Richard Guay</bitbar.author> # <bitbar.author.github>raguay</bitbar.author.github> # <bitbar.desc>A todo list taken from NotePlan and displayed with customizable color-cod...
true
61a0f9755f619af518cb72b4d6e2b8262c84f6cc
Ruby
KravchenkoDS/Thinknetica
/Lesson6/lib/train.rb
UTF-8
2,538
3.296875
3
[]
no_license
require_relative '../lib/instance_counter' require_relative '../lib/manufacturer' class Train include Manufacturer include InstanceCounter attr_reader :type, :speed, :route, :wagons, :number FORMAT_NUMBER = /^[a-zа-я\d]{3}[-]?[a-zа-я\d]{2}$/i FORMAT_NUMBER__ERROR = 'Неверный формат номера' EMPTY_NUMBER_ER...
true
f56084b5678453dc53b86a1e8ae96a4b116327d1
Ruby
carlosmendes/ruby_miscrosoft_sql
/app.rb
UTF-8
938
2.65625
3
[]
no_license
require 'sinatra' require 'tiny_tds' require_relative 'models/player.rb' # connect with Microsoft SQL Server DB = TinyTds::Client.new dataserver: 'DESKTOP-9CE4NKO\SQLEXPRESS', database: 'jm_players' # sinatra defines the available endpoints # localhost:4567/ # home of the app get '/' do erb :home end # localhost:...
true
d23d3bf8fa6b13df6882381cf687dcb2c3be00fb
Ruby
tiffanyhoodprice/Assignments
/11_2_group_names.rb
UTF-8
856
3.765625
4
[]
no_license
puts "Enter all names. Type 'done' when all names entered." pool = [] while true name = gets.chomp if name.downcase == "done" break #same as break if name.downcase == "done" but wouldn't need 'end' end pool << name end pool.shuffle! pool.each_with_index do |person, i| if pool.size.odd? && i == pool....
true
2217402fff28d7a402b1a3fc46d5c3136c616f55
Ruby
byskyline/ruby-exercise
/basic/basic_ex3.rb
UTF-8
209
3.046875
3
[]
no_license
movies = { apple: 1975, bird: 2004, cat: 2013, dog: 2001, evil: 1981 } puts movies[:apple] puts movies[:bird] puts movies[:cat] puts movies[:evil] puts movies[:dog]
true
581cffd34069dec2a287bbb3e827acda95b78934
Ruby
dpep/amenable_rb
/spec/amenable_spec.rb
UTF-8
4,412
2.9375
3
[ "MIT" ]
permissive
describe Amenable do describe '.call' do let(:fn) { proc {|x, y = :y, a:, b: 2| [ [ x, y ], { a: a, b: b } ] } } it 'takes args and kwargs as expected' do expect(fn).to receive(:call).with(:x, :y, a: 1, b: 2) Amenable.call(fn, :x, :y, a: 1, b: 2) end it 'removes excessive parameters' do ...
true
23baeec3c37e51a4f8c318ccb8930c05ecce39ef
Ruby
RubyPearls/recipebox
/app.rb
UTF-8
2,213
2.59375
3
[]
no_license
require("bundler/setup") Bundler.require(:default) Dir[File.dirname(__FILE__) + '/lib/*.rb'].each { |file| require file } get('/') do erb(:index) end get("/recipes") do @recipes = Recipe.all() @categories = Category.all() # # ... VERY general 'pseudo-code' on how to iterate # # ... thru categories and ...
true
95b8ac55ab6e9ac12b8dd602916ddfac2d9e6b24
Ruby
iwasaki-y/ruby-training
/Lesson5/loop2.rb
UTF-8
81
3.53125
4
[]
no_license
i = 0 loop do if i > 5 then break end puts(i) i = i + 1 end
true
8c3f5a8546b806468c5d4bd9ce3a695ddf8e98e1
Ruby
nvalchanov96/english-numbers
/english_numbers_spec.rb
UTF-8
1,745
3.546875
4
[ "MIT" ]
permissive
require_relative "english_numbers" RSpec.describe EnglishNumber do describe "#in_english" do it "translate singles" do expect(EnglishNumber.new(2).in_english).to eq("two") end it "translate negative singles" do expect(EnglishNumber.new(-2).in_english).to eq("minus two") end it "tran...
true
dfffee41e9035686728f9e0a9a720d16a927dbf1
Ruby
Nekototori/toolkit
/facts/ensure_package.rb
UTF-8
790
2.5625
3
[]
no_license
################### # package_version # ################### # # This fact will use the Puppet RAL to query whether a package has been # installed (using the default package provider). If it is, the version string # that Puppet is aware of will be reported. If not, this fact will be absent. # # To specify the name ...
true
b212dd18f47d4940008f8da400137293accff9b8
Ruby
sonchez/course_101
/101_109_small_problems/easy_5/after_midnight_1.rb
UTF-8
489
3.421875
3
[]
no_license
def time_of_day(minutes) hours_in_day = 24 minutes_in_day = 1440 return "00:00" if minutes == 0 base_minutes = minutes%minutes_in_day hours = (base_minutes/60) minutes = base_minutes - (hours*60) "#{format("%002d", hours) }:#{format("%002d", minutes)}" end p time_of_day(0) == "00:00" p time_of_day(-3)...
true
e3afe6f1633482ca19a40720ce53ea280b5ccd1a
Ruby
nfukasawa/lgtm
/lgtm_cli.rb
UTF-8
1,750
2.875
3
[ "MIT" ]
permissive
require 'RMagick' require 'optparse' class LGTMBuilder LGTM_IMAGE_WIDTH = 1_000 def initialize(in_filepath) @sources = Magick::ImageList.new(in_filepath) end def build(out_filepath, options = {}) images = Magick::ImageList.new @sources.each_with_index do |source, index| target = source ...
true
7d13ddeef7bdef1c02f472263a71725ab53b5b5e
Ruby
dgrahn/baregrades
/app/helpers/courses_helper.rb
UTF-8
1,457
2.71875
3
[]
no_license
module CoursesHelper #Create a Temp calendar file and download it def download_course_calendar(course) # create a temporary file named after the course name require 'date' require 'tempfile' file = Tempfile.new(["#{course.name} ", ".ics"]) begin # Write the calendar to the file file.write("BEGIN:VC...
true
7f5b7a954d5c6212e625fbbe1cbb74d9a5a312cd
Ruby
hokkai7go/study_ruby_silver
/array.rb
UTF-8
708
3.296875
3
[]
no_license
String String.superclass String.superclass.superclass Array [1, 5, 9] [1, 5, 9].class ary = [1, 5, 9] ary.all ary.all? ary.all? {|v| v> 0} ary.all? {|v| v > 0} ary.all? {|v| v < 0} bry = [1, nil, 4] bry.all? bry = [1, false, 4] bry.all? ary.map {|n| n**2 / 2} ary.map {|n| n**2 / 2.0} cry = [] cry.cycle cry.cycle() dry....
true
8795c95d57cda0f80bb4cac3b443363b0c5009a6
Ruby
julianGallegos/algorithm_practice
/find_duplicate.rb
UTF-8
252
3.265625
3
[]
no_license
def show_all_duplicates(input_array) @amount_of_times_repeated = Hash.new(0) input_array.each do |num| @amount_of_times_repeated[num] += 1 end return @amount_of_times_repeated end p show_all_duplicates([1,2,3,4,5,6,7,8,8,8,8,9,1,2,3,4,5,6,7])
true
5bb4a0d6208cb8c9d8cdcf0c3a97db1f5ca63c5a
Ruby
a-nickol/bullet_journal
/lib/bullet_journal/calendar/layouts/collector.rb
UTF-8
842
2.734375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module BulletJournal ## # Class which records all methods calls. # class CollectorProxy < BasicObject def initialize(recorder) @recorder = recorder end private # rubocop:disable Style/MethodMissing def method_missing(method, *_args, &block) @recor...
true
c5796396d65faaf272e678cc5983ef8760b79519
Ruby
saulomendonca/live-bolao
/app/models/prediction.rb
UTF-8
842
2.609375
3
[ "Apache-2.0" ]
permissive
# == Schema Information # # Table name: predictions # # id :integer not null, primary key # home_team_goal :integer # away_team_goal :integer # game_id :integer # user_id :integer # created_at :datetime # updated_at :datetime # # Indexes # # index_predictions_on_game_i...
true
6c9c7d873c7afb2248622cc98c1676d2c6126ee8
Ruby
etdev/algorithms
/0_code_wars/credit_card_mask.rb
UTF-8
153
2.734375
3
[ "MIT" ]
permissive
# http://www.codewars.com/kata/5412509bd436bd33920011bc # --- iteration 1 --- def maskify(cc) cc.length > 4 ? cc[-4,4].rjust(cc.length, "#") : cc end
true
3a2495568539c60797cbe177b14998c2a4be92ab
Ruby
khakimov/id_encoder
/lib/id_encoder.rb
UTF-8
3,377
3.34375
3
[ "MIT" ]
permissive
# Short URL Generator # =================== # Ruby implementation for generating Tiny URL- and bit.ly-like URLs. # A bit-shuffling approach is used to avoid generating consecutive, predictable # URLs. However, the algorithm is deterministic and will guarantee that no # collisions will occur. # The URL alphabet is ...
true
0dc70326435e3949cca60c173f8c0cd7c60af0d3
Ruby
youmuyou/huginn_zh
/app/models/agents/commander_agent.rb
UTF-8
1,924
2.640625
3
[ "MIT" ]
permissive
module Agents class CommanderAgent < Agent include AgentControllerConcern cannot_create_events! description <<-MD Commander Agent由时间计划或传入的事件触发,并命令其他代理(“目标”)运行,禁用,配置或启用自身 # 操作类型 将`action`设置为以下某个操作类型: * `run`: 触发此代理时会运行目标代理. * `disable`: 触发此代理时,将禁用目标代理(如果未禁用) * ...
true
747958186d5340088087c2454e89c0df46fed79a
Ruby
nyc-rock-doves-2016/oop_inheritance_module
/super.rb
UTF-8
435
3.796875
4
[]
no_license
class Bicycle attr_reader :seat def initialize(gear) @wheels = 2 @seat = 1 @gear = gear end def to_s "wheels - #{@wheels}, seat - #{@seat}, gear- #{@gear}" end end class Tandem < Bicycle def initialize(gear) super(gear) @seat = self.seat + 2 @color = "white" end def to_...
true
88e0f38b75721eeab090454adb1fe08789a3a8ba
Ruby
0x-CHUN/CSE341
/practice/partC.rb
UTF-8
442
3.421875
3
[]
no_license
class Point attr_accessor :x, :y def initialize(x,y) @x = x @y = y end def distFromOrigin # direct field access Math.sqrt(@x*@x + @y*@y) end def distFromOrigin2 # use getters Math.sqrt(x*x + y*y) end end class ColorPoint < Point attr_accessor :color d...
true
05f90d3bab23b743dad4bf2aff4c486540a11632
Ruby
MonalisaC/hotel
/lib/block.rb
UTF-8
281
2.578125
3
[]
no_license
require 'date' require_relative 'booking' require_relative 'invalid_duration_error' module BookingSystem class Block < Booking attr_reader :rooms, :rate def initialize(input) super(input) @rooms = input[:rooms] @rate = input[:rate] end end end
true