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
a2b949d0ff6e55379d1865fe1d0babd0e5556bc3
Ruby
jeffpwang/green_grocer-001-prework-web
/grocer.rb
UTF-8
1,225
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def consolidate_cart(cart:[]) new_cart = {} cart.uniq.each do |item| item.each do |name, hash| new_cart[name] = hash new_cart[name][:count] = cart.count(item) end end new_cart end def apply_coupons(cart:{}, coupons:[]) hash_output = {} cart.each do |key, value| coup...
true
f5e3ed4156808f23baed461f1560d713d9a698a7
Ruby
mchaisse/ptp-notifier
/src/filesize.rb
UTF-8
315
2.78125
3
[ "MIT" ]
permissive
# frozen_string_literal: true class Filesize class << self def readable(size) units = %w(B KiB MiB GiB TiB Pib EiB) return '0.0 B' if size == 0 exp = (Math.log(size) / Math.log(1024)).to_i exp = 6 if exp > 6 '%.2f %s' % [size.to_f / 1024 ** exp, units[exp]] end end end
true
636793d81c014fb2fab3982380e7988988667006
Ruby
jennifersmith/wire_tap
/lib/wire_tap/listener.rb
UTF-8
772
2.53125
3
[]
no_license
require 'cgi' require 'wire_tap/request_parser' module WireTap class Listener attr_reader :transactions def initialize app @app = app @transactions = [] end def call(env) response = @app.call(env) @transactions << parse_transaction(env, response) response end def parse_request(request) ...
true
c61cc335eeeaa15e540ef0d0d3b10883fada5b7d
Ruby
eireland/test-experiments
/showcase_all_mining.rb
UTF-8
3,241
2.703125
3
[]
no_license
#This gets a list of all the presentations in the showcase including ids, keywords, grades, state and audience. #Run this prior to running showcase_mining.rb to get all the ids of the presentations require 'rubygems' require 'selenium-webdriver' require 'csv' require 'date' def setup @driver = Selenium::WebDriver....
true
9b5de01c1417f8d62947f1b10ef8930fdb329010
Ruby
xunma/blog
/app/models/post.rb
UTF-8
424
2.65625
3
[]
no_license
class Post < ApplicationRecord validates :title, presence: true, allow_blank: false validates :content, presence: true, allow_blank: false validates :date, presence: true belongs_to :user has_many :marks def read_time word_count = self.content.split.size "#{(word_count / 200.0).ceil} min read" en...
true
ac47948935782b674490a170fdcf8d01a5002023
Ruby
JohnZBurnett/module-one-final-project-guidelines-nyc-web-051418
/app/countdown.rb
UTF-8
885
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain", "MIT" ]
permissive
def static_countdown(launch) l = launch.isostart time = l - Time.now.utc mm, ss = time.divmod(60) hh, mm = mm.divmod(60) dd, hh = hh.divmod(24) ("%d days, %d hours, %d minutes and %d seconds" % [dd, hh, mm, ss]) end require 'io/wait' def char_if_pressed begin system("stty raw -echo") # turn raw in...
true
bf795787b75b14f2be5aab191ae098f39ee4bc9f
Ruby
PhilippePerret/WriterToolbox
/lib/app/console/filmodico/methodes.rb
UTF-8
1,228
2.640625
3
[]
no_license
# encoding: UTF-8 class SiteHtml class Admin class Console # Retourne une liste de Hash de données des films qui # correspondent à la référence +fref+ qui peut être une # portion du titre original/français ou de l'identifiant # type Harvard du film def get_all_films_of_ref fref site.require_objet 'filmod...
true
88f906c4a849c62316768a67056f8e2ceae68153
Ruby
darrinholst/hipchat-emoticons
/app/models/emoticon.rb
UTF-8
749
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Emoticon class << self def fetch_all(auth_token) fetch_all_from('https://api.hipchat.com/v2/emoticon', auth_token) end private def fetch_all_from(url, auth_token, results = []) response = Faraday.get(url, {auth_token: auth_token}) raise response.body unless response.status ==...
true
4fbfdc4fe4060f0b25beb20d58a3f8ff2696fd61
Ruby
inre/event_object
/spec/event_object_spec.rb
UTF-8
2,293
2.984375
3
[ "MIT" ]
permissive
require "spec_helper" describe EventObject do using EventObject class EventEmitter events :success, :error, :data end class ParentObject def ok 'OK' end end it "should create array of events" do events = [] proc = lambda { :result } events.push proc events_with_argume...
true
82875a6319984a738d438dc74c0717abfb9debe9
Ruby
ilovecoding294786/reform
/src/ruby/reform_test.rb
UTF-8
17,231
2.515625
3
[ "MIT" ]
permissive
# # Copyright (c) 2008 Adam Cecchetti # # 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 # to use, copy, modify, merge, pu...
true
60265120d790d701382935c67628d972bd9022e9
Ruby
feigningfigure/WDI_NYC_Apr14_String
/w03/d02/Victor_Rodriguez/Classwork/blog1/models/posts.rb
UTF-8
708
3.234375
3
[]
no_license
class Post def self.connect_to_db @conn = PG.connect ( dbname: 'blog1') end def self.get_all_posts @posts =[] self.connect_to_db.exec("SELECT * FROM posts").each.do |post| posts << post end posts end #A method that creates a new room on the table def self.create(attributes, hash) title = attributes_hash[:titl...
true
056487f46ec2d270b0820c50d5ebaad7adfa035e
Ruby
chrisanthropic/slim-pickins-jekyll-theme
/_plugins/image_optim.rb
UTF-8
1,208
2.640625
3
[ "Unlicense" ]
permissive
require "image_optim" require 'yaml' module Jekyll class ImageOptimGenerator < Generator safe true def generate(site) puts 'Optimizing Images' settings_new = {} settings = {} # Does file exists? if File.file?("images/image_optim_cache.yml") settings = YAML::load_file "images...
true
9673c180f2ccb5331e0fc3bcd4f84fdca2c4d14c
Ruby
brunze/augmented
/test/augmented/arrays/tieable_test.rb
UTF-8
1,713
3.34375
3
[ "MIT" ]
permissive
require 'minitest/autorun' require 'augmented/arrays/tieable' describe Augmented::Arrays::Tieable do using Augmented::Arrays::Tieable describe '#tie' do describe 'when supplied with an object' do it 'returns an array interweaved with the specified object' do object = Object.new weaved ...
true
8a0f504b60ced59ee735720ef0221b2022630f1f
Ruby
renewablefunding/spectifly
/lib/spectifly/support.rb
UTF-8
800
2.65625
3
[ "MIT" ]
permissive
module Spectifly module Support module_function def camelize(string, lower = false) string = if lower string.sub(/^[A-Z\d]*/) { $&.downcase } else string.sub(/^[a-z\d]*/) { $&.capitalize } end string = string.gsub(/(?:_| |(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.g...
true
84301c7de8281cc5c0d76bf108910a22d35a3a71
Ruby
priyapower/viewing_party
/app/poros/movie.rb
UTF-8
313
2.859375
3
[]
no_license
class Movie attr_reader :id, :title, :vote_average, :description def initialize(movie_details) @id = movie_details[:id] @title = movie_details[:title] @vote_average = movie_details[:vote_average] @description = movie_details[:overview] end end
true
a06323741d12942d9d10e36524587aeb686774a4
Ruby
Jay-Dabo/organize2
/spec/models/card_spec.rb
UTF-8
751
2.53125
3
[ "MIT" ]
permissive
require 'rails_helper' describe Card do subject do Card.new(name: 'Card#1') end it { is_expected.to be_valid } it 'should not be valid without name' do subject.name = nil expect(subject).not_to be_valid end it 'returns name as to_s' do expect(subject.to_s).to eq 'Card#1' end contex...
true
b7bccee7edf54ec1de87adb9daf54e147489a0f1
Ruby
hgsgtk/ruby-oop
/chapter6/P144/bicycle_test.rb
UTF-8
531
2.65625
3
[]
no_license
require 'minitest/autorun' require_relative './bicycle' class BicycleTest < Minitest::Unit::TestCase def test_spares bike = Bicycle.new( style: :mountain, size: 'S', front_shock: 'Manitou', rear_shock: 'Fox' ) assert...
true
caee40ab252b554b43e1e8fa647389ef2cb3ec05
Ruby
ryanmcgarvey/Ryan-goes-to-training
/rails2_studio/code/meta/class_eval.rb
UTF-8
200
3.515625
4
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
module Greeter def greet puts "Howdy from #{self.inspect}" end end [String, Array, Hash].each do |klass| klass.class_eval { include Greeter } end "mike".greet [1,2,3].greet {:a => 1}.greet
true
9cd5faa57a5b801392120df3b31f1d21e0a5f70d
Ruby
vibhumahendru/ruby-boating-school-nyc-web-102918
/tools/console.rb
UTF-8
717
2.609375
3
[]
no_license
require_relative '../config/environment.rb' def reload load 'config/environment.rb' end # Insert code here to run before hitting the binding.pry # This is a convenient place to define variables and/or set up new object instances, # so they will be available to test and play around with in your console student1 = S...
true
2716f4b36e51266c507fea55ad059ac6476aa559
Ruby
cryselayala98/Ruby
/Bases/ex25_modulos_uso_self.rb
UTF-8
3,965
4.3125
4
[]
no_license
module Ex25 # Un módulo es un contenedor que agrupa constantes, clases y métodos. def self.break_words(stuff) # métodos self -> funcionalidades pertenecientes a la clase creada. # Esto hace que esos métodos se ejecuten en sí mismos en la clase, como si la propia clase o módulo s...
true
fb02a9163fb92ccc600ded7945c6cf1d627914c7
Ruby
lucasdonuts/connect_four
/lib/board.rb
UTF-8
1,894
3.640625
4
[]
no_license
class Board attr_accessor :board def initialize @board = Array.new(7) { Array.new(6) } end def display_board 0.upto(5) do |i| print "|" 0.upto(6) do |n| print @board[n][i].nil? ? " |" : " #{@board[n][i]} |" end puts end end def valid_move?(column) (1..7).i...
true
2e4e2a7b840dfa4e4f8f707dfca83b856a838c00
Ruby
abouhid/open-flights
/app/models/airline.rb
UTF-8
518
2.8125
3
[]
no_license
# frozen_string_literal: true class Airline < ApplicationRecord has_many :reviews validates :name, presence: true, length: { maximum: 255 } # Slugify airline name into a url safe param before create # Ex: 'United Airlines'.parameterize => 'united-airlines' before_create :slugify def slugify self.slu...
true
4c6e26472a24151359ca45e3acd5be3f4f2f63b7
Ruby
rhyswat/hap
/lib/hap.rb
UTF-8
1,306
3.234375
3
[]
no_license
require 'getoptlong' require_relative 'hap/driver' module Hap def self.usage(script_name) puts "Usage: #{script_name} [-h] [-o OUTPUT] PIECE" puts "" puts "Generate a MIDI file from a piece description." puts "" puts "Arguments:" puts " PIECE\ta piece description file." puts "" put...
true
9ff0ca1b25637664ebb26e1ef8ef481d3c60ddd8
Ruby
nunsez/ruby-rush
/rubytut/lesson10/viselitsa_methods.rb
UTF-8
2,231
3.46875
3
[ "Apache-2.0" ]
permissive
# rubocop:disable Naming/AccessorMethodName def get_letters word = ARGV[0] if word.nil? || (word == '') abort 'Для игры введите загаданное слово в качестве аргумента при запуске программы' end word.encode('utf-8').chars end def get_user_input letter = '' letter = $stdin.gets.encode(...
true
08b78e435d125bffa32980085b32c5ccd1b2c621
Ruby
angry-boss/rake
/vendor/bundle/ruby/2.6.0/gems/tins-1.25.0/lib/tins/bijection.rb
UTF-8
995
3.125
3
[ "MIT" ]
permissive
module Tins class Bijection < Hash def self.[](*pairs) pairs.size % 2 == 0 or raise ArgumentError, "odd number of arguments for #{self}" new.fill do |obj| (pairs.size / 2).times do |i| j = 2 * i key = pairs[j] value = pairs[j + 1] obj.key?(key) a...
true
33bdb4fdbd4e41ac55c160e28a0cf9c732ddf591
Ruby
jichen3000/colin-ruby
/metaprogramming_in_ruby/rails/alias_method_chain.rb
UTF-8
1,141
3.078125
3
[]
no_license
module Greetings def greet "hello" end end class MyClassSimple include Greetings end class MyClassAlias include Greetings def greet_with_enthusiasm "Hey, #{greet_without_enthusiasm}!" end alias_method :greet_without_enthusiasm, :greet alias_method :greet, :greet_with...
true
3950d5372472a8ce943a03dee33eee3edb9a42ad
Ruby
DT021/x-stocks
/app/models/x_stocks/stock/ar_finders.rb
UTF-8
1,191
2.71875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module XStocks class Stock # Stock AR Finders Business Model module ARFinders def find_all_random stocks_in_random_order.map { |ar_stock| XStocks::Stock.new(ar_stock) } end def find_all(*args) XStocks::AR::Stock.where(*args).all.map { |ar_stock...
true
bc27fb28cd0124c5bcd9d29f8602d8a7eeb5efe6
Ruby
DavidMejia025/99BottlesOfBeer
/shameless_green_refactor_six_pack/solution_6.rb
UTF-8
4,099
3.6875
4
[]
no_license
%Q( Code is ok to be done in a procedural way when it is not affected by changes, but when they occur the cost of a change can increase considerable so its better to think twice when deciding to make the first implementation. S O L I D principels: S ingle Responsability O pen Close principle, states that code m...
true
fa0c748ad5f3e63686b29b28d02adb8c5314e0b9
Ruby
analogeryuta/Sandbags
/Ruby/json.rb
UTF-8
262
3.40625
3
[]
no_license
#!/usr/bin/ruby require 'json' # array to string arr = {"name" => "bourn, jason", "age" => 35} p arr.to_json # string to json str = '{"name":"hoge","age":32}' json = JSON.parse(str) # iterate from json objects json.each do |key,val| puts "#{key}: #{val}\n" end
true
3d08f7bfbeccf067750f447c0d711e60ec18b241
Ruby
nonusae/hello_gold_test
/app/models/balance.rb
UTF-8
201
2.78125
3
[]
no_license
class Balance < ApplicationRecord def add(amount) self.update_attribute(:amount, self.amount+amount) end def deduct(amount) self.update_attribute(:amount, self.amount-amount) end end
true
460187ee02cfc1c50d57565817aea2a5ae30465e
Ruby
koss-lebedev/wordnik-ruby
/lib/wordnik/resource.rb
UTF-8
4,058
2.71875
3
[]
no_license
# To jog the memory: Resource > Endpoint > Operation > OperationParameter module Wordnik class Resource require 'active_model' include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :name, :raw_data, :endpoints, :models validates_p...
true
82b251e01c3506bedd9fd95464477e004eae5719
Ruby
rjschnellbacher/httply
/hello.cgi
UTF-8
434
2.953125
3
[]
no_license
#!/usr/bin/env ruby require 'cgi' cgi = CGI.new puts cgi.header page = 'home' page = cgi['page'] unless cgi['page'].empty? def render(page_name, &content) title = {'about' => 'About Us','home' => 'Welcome'} puts "<!doctype html><html><head><title>#{title[page_name]}</title></head> <body>#{yield}</body></html>" e...
true
1dd39f876805e78732d9a71797e061ddd4d861d2
Ruby
pentesttools/Spotlight
/objects.rb
UTF-8
12,433
2.515625
3
[]
no_license
module LDAPData #This method is designed to take an BER object and convert it to something normal def self.breakout(object) if object.is_a? Array if object.size == 1 if object[0].is_a? String if object[0] =~ /^-?[0-9]{0,20}$/ #If the value is an integer return object[0].to_i else ret...
true
cfaf7032ccf8ab4e9f68d1c4662b27cb4747ea0b
Ruby
jhuang429/ruby-oo-object-relationships-kickstarter-lab-nyc-clarke-web-010620
/lib/project.rb
UTF-8
417
2.96875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Project def initialize(title) @title = title end attr_accessor :title def add_backer(backer) ProjectBacker.new(self, backer) end def projectbackers ProjectBacker.all.select do |projback| projback.project == self end end def backers ...
true
7176e33211aa4762b62ddb448da2b2195be60bb2
Ruby
mustmodify/simple-desk
/app/models/assignment.rb
UTF-8
1,038
2.8125
3
[]
no_license
class Assignment < ActiveRecord::Base def self.reset Assignment.all.each{|assignment| assignment.update_attribute(:hours_worked, 0)} end def self.total_for( provider ) out = 0 l=Assignment.find(:all, :conditions => "provider_odesk_id = '#{provider}'") l.each do |assignment| out += assignme...
true
63db736bc898b591f79d9d3ffba14d8f3a235367
Ruby
larrytheliquid/rubinius
/lib/1.8.7/dir.rb
UTF-8
305
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
class Dir def self.foreach(path) return to_enum :foreach, path unless block_given? self.open(path) do |dir| while s = dir.read yield s end end nil end def each return to_enum unless block_given? while s = read yield s end self end end
true
e77c27ba3b33c0e4915e3d89e247e4472b600dcd
Ruby
kyrylo/system_browser_server
/lib/system_browser/gem2markdown.rb
UTF-8
2,086
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "Zlib" ]
permissive
module SystemBrowser class Gem2Markdown def self.convert(gem) self.new(gem).convert end def initialize(gem) @gem = gem end def convert description = '' [header, summary, homepage, license, author, email, newline, descripti...
true
ca8bf33b3a5e3023fee4285ab9d3d1164e3ef7f8
Ruby
knaidu/coding_katas
/arrays/increment_bigInteger.rb
UTF-8
329
3.421875
3
[]
no_license
def increment(arr) return nil if arr.nil? i = arr.size - 1 arr[i] += 1 while i > 0 && arr[i] == 10 arr[i] = 0 i -= 1 arr[i] += 1 end if arr[0] == 10 arr[0] = 0 arr = [1].concat(arr) end arr end puts increment([9,9]).inspect puts increment([9,9,9]).inspect puts increment([1,2,3]...
true
e16ea5cd81ebc10437b727afcf01171a880419e7
Ruby
GunioRobot/extreme-solitaire
/lib/turn/waste_to_tableau_turn.rb
UTF-8
535
3.28125
3
[ "MIT" ]
permissive
require 'turn/turn' # Represents a turn moving the top waste card to a tableau class WasteToTableauTurn < Turn attr_reader :to_tableau_index # Initializes the turn. This takes the board to act on and the index of the # tableau to act on. def initialize(board, to_tableau_index) super(board) @to_tablea...
true
42526d3587f04107da7dbd6ac84cf3aa79178820
Ruby
toshi1973814/depot
/spec/lint/rubocop_spec.rb
UTF-8
664
2.53125
3
[]
no_license
# https://gist.github.com/djburdick/5104d15f612c15dde65f require 'spec_helper' RSpec.describe 'Check that the files we have changed have correct syntax' do before do current_sha = 'origin/master..HEAD' @files = `git diff-tree --no-commit-id --name-only -r #{current_sha} | grep .rb` @files.tr!("\n", ' ') ...
true
041926c14b27253675d701f154a9f02c6a51542b
Ruby
sparksmb/euler-project-ruby
/lib/math/fibonacci.rb
UTF-8
337
3.078125
3
[]
no_license
require './lib/math/sequence.rb' class Fibonacci def self.sequence @config ||= Config.new(1,2) end class Config < SequenceConfig def list seq = [1,2] term = 3 while term < @last_term_less_than seq << term term = seq.last(2).sum end return Sequence.new(seq) ...
true
aa9fee57cc745cbddaf6370abd9b77c17b842ab0
Ruby
andrewhr/wasabi
/lib/wasabi/schema_collection.rb
UTF-8
939
2.8125
3
[ "MIT" ]
permissive
class Wasabi class SchemaCollection include Enumerable def initialize @schemas = [] end def <<(schema) @schemas << schema end def push(schemas) @schemas += schemas end def each(&block) @schemas.each(&block) end def element(name) find_type { |s...
true
2fb8757172a8d0d872a1e75a945efe7531c6f89c
Ruby
glamrock/hypnoscholar
/lib/gtranslate.rb
UTF-8
1,039
2.90625
3
[]
no_license
require 'cgi' require 'open-uri' require 'json' API_KEY = "AIzaSyAt-DzStk_hdwPSpjTKLo_x86Zor-GPNSs" def escape(v) if v == false; '0' elsif v == true; '1' else CGI::escape(v.to_s) end end def parametrize(params) paramstrs = [] params.each { |k,v| paramstrs << "#{k}=#{escape(v)}" unless v.nil? } return "?" + pa...
true
d36afe674f00461f7f8fd4a5ca9bfa45cd112eed
Ruby
dev-named-jordan/black_thursday
/test/sales_analyst_test.rb
UTF-8
8,088
2.84375
3
[]
no_license
require_relative './test_helper' require './lib/sales_analyst' require './lib/standard_deviation' require 'bigdecimal/util' require 'time' require 'mocha/minitest' class SalesAnalystTest < Minitest::Test include StandardDeviation def setup @se = SalesEngine.from_csv({ :items => "./fixture_data/items...
true
de7ca46f9bf4619798c8b3a17483a3089e1868de
Ruby
Ramaze/ramaze
/lib/ramaze/bin/runner.rb
UTF-8
3,128
3
3
[ "MIT" ]
permissive
require 'optparse' require 'pathname' require __DIR__('create') module Ramaze #:nodoc: module Bin ## # Module used for running a particular command based on the specified # command line arguments. # # Usage: # # ramaze --help # Shows a help message # ramaze -h # Shows a h...
true
fa0194ef5d25bd52123d1d633f3a357cf71f094f
Ruby
renuo/lean-elevators
/spec/lib/populator_spec.rb
UTF-8
1,575
2.59375
3
[ "MIT" ]
permissive
module LeanElevators RSpec.describe Populator do let(:origin_floor) { instance_double(Floor, people: [], panel: Panel.new) } let(:target_floor) { instance_double(Floor, people: [], panel: Panel.new) } let(:other_floor) { instance_double(Floor, people: [], panel: Panel.new) } let(:floors) { [origin_flo...
true
01901a4c30b04aed79f6a9fb81e7e3a40a60f6f2
Ruby
nowakoff/phase-0
/week-6/validate-credit-card/my_solution.rb
UTF-8
2,226
3.90625
4
[ "MIT" ]
permissive
# Class Warfare, Validate a Credit Card Number # I worked on this challenge [by myself, with: ]. # I spent [#] hours on this challenge. # Pseudocode # Input: integer # Output: true/false # Steps: # Initial Solution # Don't forget to check on initialization for a card length # of exactly 16 digits # class Credit...
true
d9de19a2212f9c902d68c07d1afd428cd78d39d0
Ruby
tylrd/farkle
/lib/farkle/die.rb
UTF-8
724
3.546875
4
[ "MIT" ]
permissive
module Farkle class Die attr_reader :upface, :sides # Initializes a new instance of <code>Farkle::Die</code object # # @param [Integer] the number of sides for the die object. Defaults to 6. # @example # Farkle::Die.new(15) # # # default constructor returns 6 # Farkle::Die....
true
c52a259006927cf138124b26bb292ba3d91f288b
Ruby
huffman442/Waterfalls
/waterfalls_data.rb
UTF-8
654
3.15625
3
[]
no_license
require "./waterfalls_tiles.rb" class Board def initialize gridSize = 100 @grid = Array.new(gridSize){ Array.new(gridSize){ Water.new } } end def create_level_one island = Island.new # Place 3 'u-shaped' islands onto the grid @grid = island.u_shape @grid, r...
true
859af869eabf8412db9ea7408df77bc30cc9e8dd
Ruby
compciv/2016.compciv.org
/lib/custom_helpers/date_helpers.rb
UTF-8
975
3.0625
3
[]
no_license
require 'chronic' module CustomHelpers module DateHelpers def date_slug(val) _to_date(val).strftime '%Y-%m-%d' end def machine_date(val) _to_date(val).strftime '%Y-%m-%dT%l:%M:%S%z' end def day_of_week(val) if (v = _to_date(val)) v....
true
d9eda7243119144e625bbdcb1b3585dba550bf8a
Ruby
joeroot/parts
/lib/parts/tester.rb
UTF-8
3,030
3.484375
3
[ "MIT" ]
permissive
class Parts::Tester attr_accessor :sentences def initialize path="#{File.dirname(__FILE__)}/treebank3.2.txt" # Sentences are stored as array's of word-tag pairs, where each sentence # will be [{:word => w1, :tag => t1},...,{:word => wn, :tag => tn}]. @sentences = [] self.load path end def loa...
true
aad4fdb5751b02b472e061347fb84ea3addc2a38
Ruby
brymck/death_and
/lib/death_and/state.rb
UTF-8
865
3.265625
3
[ "MIT" ]
permissive
require 'death_and/bracket' module DeathAnd class State def initialize(params = {}) @name = params['name'] @abbreviation = params['abbreviation'] build_brackets params['brackets'] end attr_reader :name, :abbreviation def [](index) @brackets[index] end def []=(index,...
true
0ce6c3e1cf0dfcf6115418917dd5da901edc6b98
Ruby
var114/bj
/lib/bj.rb
UTF-8
2,474
3.625
4
[]
no_license
require 'rspec' class Card attr_reader :suit, :value def initialize(suit, value) @suit = suit @value = value end def value return 10 if ["J", "Q", "K"].include?(@value) return 11 if @value == "A" return @value end def to_s "#{@value}-#{suit}" end end class Deck attr_...
true
d21eb3ff1a8988d62205ed32927e7aee1373b17b
Ruby
ashamani9/Ruby
/31-08-2016/Function1.rb
UTF-8
313
3.828125
4
[]
no_license
#Write a function to calculate area and perimeter of a rectangle. def func() print "Enter the length:" l = gets.chomp.to_f print "Enter the width" w = gets.chomp.to_f area = l * w puts "Area of rectangle:#{area}" perimeter = 2 * (l + w) puts "Perimeter of rectangle:#{perimeter}" end func()
true
bb644bc71f1e830fa3a267634f57a60c44895151
Ruby
Troy8878/RougeBot
/Roguelike/Assets/Scripts/Support/Items/Armor.rb
UTF-8
1,128
3.375
3
[]
no_license
####################### # Armor.rb # Claire Robsahm # Created 2014/09/11 # Copyright © 2015 DigiPen Institute of Technology, All Rights Reserved ####################### #########################Class Details########################## # Armor is the base class for all armor in the game. # It inherits all properties fro...
true
a502dd02e427ee3b96895c74ae80a18c3042dc08
Ruby
bobbyvidal/module-one-final-project-guidelines-houston-web-career-021819
/lib/models/customer.rb
UTF-8
925
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# require_relative '../config/environment' # require_relative '../CLI_Methods.rb' class Customer < ActiveRecord::Base has_many :reviews has_many :restaurants, through: :reviews #@cli = Highline.new # def write_review(current_restaurant, array_of_stuf) # i_customer_id = self.id # ...
true
adf704429b0627825aff5a56bdb0d75f2debe5b6
Ruby
Nisticism/reverse-each-word-online-web-ft-100719
/reverse_each_word.rb
UTF-8
225
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(word) word_array = word.split(" ") new_word = "" new_word_array = [] word_array.collect do |each_word| new_word_array.push(each_word.reverse) end new_word = new_word_array.join(" ") end
true
0729a5753e495230dd302852110881c67c67fe0f
Ruby
arlechann/atcoder
/AtCoder/ABC128/B.rb
UTF-8
226
3.078125
3
[ "CC0-1.0" ]
permissive
n = gets.to_i sp = Array.new n.times do |i| sp.push(gets.chomp.split.push(i)) end sp.sort! do |sp1, sp2| sp2[1].to_i <=> sp1[1].to_i end sp.sort! do |sp1, sp2| sp1[0] <=> sp2[0] end n.times do |i| puts sp[i][2] + 1 end
true
927f60f7fd56ab8fb992811f3d5298961ad9cbc2
Ruby
olci34/MoDay
/lib/genre.rb
UTF-8
369
3.46875
3
[ "MIT" ]
permissive
class Genre attr_accessor :name @@all = [] def initialize(name) self.name = name self.class.all << self end def self.all @@all end def movies Movie.all.select {|movie| movie.genre_array.include?(self)} end def self.find_by_name(name) self....
true
cae4e016efa80c83a14099c4c081457b54e8e3cd
Ruby
LeniaMarga/diagrams
/specs/test_wand.rb
UTF-8
353
2.5625
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../wand.rb') class TestWand < Minitest::Test def setup @wand_wood = Wand.new("holly", "phoenix feather") end def test_wand_got_wood assert_equal("holly", @wand_wood.wood) end def test_wand_got_core assert_equal("phoenix feath...
true
d26c188b93f13b357133d0fe2c59abb7e0ceb30c
Ruby
quiin/Werewolves-and-wanderers
/helpers/section.rb
UTF-8
355
2.71875
3
[]
no_license
=begin Samantha Ponce A01370967 Carlos Reyna A01165824 Diego Monroy A01165792 Edgar López A01372098 =end class Section attr_reader :id, :description, :transitions def initialize(description = "Starting room", id = 7, transitions = []) @description = description @id = id @transitions = transitions end...
true
1b66fb20959c85ed60e351a84368854da83ab87f
Ruby
VenkiPhy6/Ruby-basics
/12_dicts.rb
UTF-8
562
3.890625
4
[]
no_license
#Also called associative arrays test_grades = { "Andy" => "B+", :Stanley => "C", #Interesting notation "Ryan" => "A", 3 => 95.2 } puts test_grades test_grades["Andy"] = "B-" puts test_grades["Andy"] test_grades["Kavanaugh"] = "C-" puts test_grades puts test_grades[3] #Methods print test_grades.keys; puts print t...
true
eef68d35b9a70cec0e378db7bc859a7a03a8c5b2
Ruby
Fish-bowl/scraping-fun
/imreallytryingtolearnnokogiri.rb
UTF-8
1,109
3.03125
3
[]
no_license
require 'rubygems' require 'mechanize' require 'HTTParty' require 'colorize' require 'pry' # def main # puts "Welcome to the scraper".colorize(:red) # puts "enter the url you would like to scrape".colorize(:red) # input = $stdin.gets.strip # @og_url = "https://www." + input # puts @og_url # end # class ...
true
8fe12549c263b160e317a2f23e87e1b7f08cb2ca
Ruby
DanielCoffey1/Updated-Practice
/Week01 Advanced OOP/cohort-stats-boston-22/lib/system_check.rb
UTF-8
224
2.828125
3
[]
no_license
class SystemCheck attr_reader :submissions def initialize(name, due_date) @name = name @due_date = due_date @submissions = [] end def add_submission(submission) @submissions << submission end end
true
e71acbcaaecb4a3475414486ef7c0f1d8fc1fecf
Ruby
syhsyh9696/Ruby
/Leetcode/fizz_buzz.rb
UTF-8
411
3.65625
4
[]
no_license
# encoding:utf-8 # @param {Integer} n # @return {String[]} def fizz_buzz(n) result = Array.new 1.upto(n).each do |i| if i % 5 == 0 && i % 3 == 0 result.push "FizzBuzz" elsif i % 3 == 0 result.push << "Fizz" elsif i % 5 == 0 result.push "Bu...
true
39bcaa32c6fed175d6eab2661f22b8824e3f27f0
Ruby
bohdan0/Chess
/board.rb
UTF-8
3,025
3.71875
4
[]
no_license
require_relative 'pieces/piece' require_relative 'pieces/null' require_relative 'pieces/king' require_relative 'pieces/knight' require_relative 'pieces/queen' require_relative 'pieces/bishop' require_relative 'pieces/rook' require_relative 'pieces/pawn' class Board attr_accessor :grid def initialize(set_up = true...
true
bbf4ff5b877376975b2051a3ecedc38bb67e6352
Ruby
wooisland/LRHW
/ex38.rb
UTF-8
590
3.421875
3
[]
no_license
ten_things = "Apple Oragnes Crows Telephone Light Sugar" puts "Wait there's not 10 things in that list, let's fix that." staff = ten_things.split(' ') more_staff = %w(Day Night Song Frisbee Corn Banana Girl Boy) while staff.length != 10 next_one = more_staff.pop puts "Adding: #{next_one}" staff.push next_one p...
true
17cf29e40a920c8df644ab2c81c09ee52ae8a832
Ruby
dormi/xaviim
/app/views/snippets/ruby_countdown_correct.rb
UTF-8
28
2.609375
3
[]
no_license
hi.downto(lo) { |n| puts n }
true
f77b9388a0cfba66760b35190396ddd950b6a9e6
Ruby
ey6es/snarkypucks
/app/models/player.rb
UTF-8
1,588
2.578125
3
[]
no_license
class Player < ActiveRecord::Base # The minimum name length. MIN_NAME_LENGTH = 2 # The maximum name length. MAX_NAME_LENGTH = 60 # The minimum password length. MIN_PASSWORD_LENGTH = 6 # The email prefix for Facebook accounts. FACEBOOK_PREFIX = "facebook" # Strips and sanitizes a name. def self....
true
6426d558a0aac5b5c7d4e51c68cc9bb3885d16d6
Ruby
markhaskamp/Greed-kata
/spec/Greed_RulesEngine_spec.rb
UTF-8
1,189
2.703125
3
[]
no_license
require 'rspec' require File.dirname(__FILE__) + '/../lib/Greed_RulesEngine.rb' describe Greed_RulesEngine do it "a single 1 is 100" do Greed_RulesEngine.roll([1]).should == 100 end it "triple ones = 1000" do Greed_RulesEngine.roll([1,1,1]).should == 1000 end it "1,1,1,1 = 1100" do Greed_Rule...
true
3c4df6d589d6ee2af428101335a120d964e990ac
Ruby
patdowney/supernet
/lib/supernet.rb
UTF-8
2,686
3.265625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'ext/ipaddress' require 'set' class SuperNet attr_reader :network attr_reader :allocated def initialize(network_string) @network = IPAddress.parse(network_string) @allocated = Set.new end def resolve_network(network) if network.is_a?(String) network = IPAddress.parse(network) ...
true
68892a9991969040a90c7cd1ccd4ebcf3a7ae15e
Ruby
meussram/wav
/lib/waveform.rb
UTF-8
2,129
2.9375
3
[]
no_license
require 'rubygems' require 'chunky_png' require 'yaml' require 'json' require './lib/wavfile_processor.rb' class Waveform include WavfileProcessor attr_accessor(:number_of_points, :file, :file_name) def initialize(density, wav_file_name) @number_of_points = density @file = File.open(wav_file_name, 'rb...
true
0d995e3dcaf27f6cc428eb2bd20cce54060fac0e
Ruby
gglin/project-euler
/ruby_all/420.rb
UTF-8
636
3.4375
3
[]
no_license
# Problem 420: 2x2 positive integer matrix # http://projecteuler.net/problem=420 # A positive integer matrix is a matrix whose elements are all positive integers. # Some positive integer matrices can be expressed as a square of a positive integer matrix in two different ways. Here is an example: # # # http://projec...
true
43795f145b5c863f3b34112b7ba9c9d8428c8ccf
Ruby
SwanstromLab/tools
/label_g2p_score.rb
UTF-8
2,224
3.015625
3
[]
no_license
#label sequence name with g2p scores #count lineages above 1% abundance def fasta_to_hash(infile) f=File.open(infile,"r") return_hash = {} name = "" while line = f.gets do if line =~ /^\>/ name = line.chomp return_hash[name] = "" else return_hash[name] += line.chomp end end f...
true
de0b0ae4ccae41758426d48ec5be0c3da8cfad4b
Ruby
TheRoyalTnetennba/coding_challenges
/hacker_rank/cracking_the_codeing_interview/bubble_sort.rb
UTF-8
484
3.8125
4
[]
no_license
#!/bin/ruby def bubble_sort(a) $total_swaps += $swaps $swaps = 0 (1...a.size).each do |i| if a[i - 1] > a[i] $swaps += 1 temp = a[i - 1] a[i - 1] = a[i] a[i] = temp end end $swaps.zero? ? a : bubble_sort(a) end n = gets.strip.to_i a = gets.strip a = a.split(' ').map(&:to_i) $...
true
267172eeb58a2bbca772d4aa821c91f1d5e2ba33
Ruby
realtomaszkula/chess_ruby
/lib/pieces.rb
UTF-8
6,407
3.40625
3
[]
no_license
class Piece attr_reader :color, :figure, :unicode attr_accessor :position, :possible_moves def initialize(color, position) @color = color @position = position @possible_moves = [] end def receive_environment(active_player, opposing_player) @active_player = active_player @opposing_player...
true
44aaed50901d20d268ce484e2cb0c99864dd297b
Ruby
leftees/swearjar
/lib/swearjar/tester.rb
UTF-8
529
2.90625
3
[]
no_license
require 'yaml' require 'fuzzy_hash' require 'bloomfilter' class Swearjar class Tester def initialize(config_file) data = YAML.load_file @tester = FuzzyHash.new data['regex'].each do |pattern, type| @tester[Regexp.new(pattern)] = type end data['simple'].each do |test, typ...
true
af9c01ac993a585b5545b5bac096958cd7eee3dd
Ruby
BarretteBanner/badges-and-schedules-houston-web-080519
/conference_badges.rb
UTF-8
630
3.9375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def batch_badge_creator(array) new_array = [] array.each do |item| new_array << "Hello, my name is #{item}." end return new_array end def badge_maker(name) "Hello, my name is #{name}." end def assign_rooms(array) new_array = [] room_number = 1 array.eac...
true
498e0179a36e8d306d37324cb23126ae665c17da
Ruby
JoshuaTatterton/BattleshipsWeb
/lib/game/play.rb
UTF-8
2,161
3.4375
3
[]
no_license
require_relative "board" class Play attr_reader :player1_board, :player2_board def initialize @player1_board = Board.new @player2_board = Board.new end def player1_place(ship,coord,direction) player1_board.place_ship(ship,coord,direction) end def player2_place(ship,coord,direction) play...
true
ff8190b8795376c5b7b16b2dfc475e24e46cc414
Ruby
jmay/masticate
/lib/masticate/include.rb
UTF-8
1,048
2.75
3
[ "MIT" ]
permissive
# exclude rows based on field = value class Masticate::Include < Masticate::Base def configure(opts) standard_options(opts) @field = opts[:field] or raise "missing field to include" @value = opts[:value] or raise "missing value to include" # row-loading automatically strips leading & trailing white...
true
268a2e08abdfa5a7920ee6d30dd3757ffeb04abb
Ruby
PeterCamilleri/fOOrth
/lib/fOOrth/monkey_patch/numeric.rb
UTF-8
754
3.4375
3
[ "MIT" ]
permissive
# coding: utf-8 #Extensions to the \Numeric class required by the fOOrth language system. class Numeric #Convert this number to a form suitable for embedding in a source string. #<br>Returns #* An embeddable form of this number as a string. def foorth_embed self.to_s end #Convert this numbe...
true
3cd08517816a730e8f44a738a05ce8fed509998c
Ruby
anisssoudki/array-CRUD-lab-onl01-seng-pt-021020
/lib/array_crud.rb
UTF-8
1,160
4.3125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def create_an_empty_array [] end def create_an_array ["a", "b", "c", "d"] end def add_element_to_end_of_array(array, element) create_an_array.push(element) end def add_element_to_start_of_array(array, element) create_an_array.unshift(element) end def remove_element_from_end_of_array(array) ...
true
6fa9558f2c72ac3d74df1f602e9dc11d3a0095c3
Ruby
Tubbz-alt/pdex-formulary-client
/app/controllers/formularies_controller.rb
UTF-8
3,296
2.53125
3
[ "Apache-2.0" ]
permissive
################################################################################ # # Formularies Controller # # Copyright (c) 2019 The MITRE Corporation. All rights reserved. # ################################################################################ require 'json' class FormulariesController < ApplicationCo...
true
ab0b005197f968fc68719a0408f3038b1faa2733
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/allergies/f58d418ce7c44a12b9bf0e033f521592.rb
UTF-8
549
3.53125
4
[]
no_license
class Allergies CODES_TO_NAMES = { 1 => "eggs", 2 => "peanuts", 4 => "shellfish", 8 => "strawberries", 16 => "tomatoes", 32 => "chocolate", 64 => "pollen", 128 => "cats" } NAMES_TO_CODES = CODES_TO_NAMES.invert def initialize(score) @score = score end def li...
true
e0a80ff9e70ff5312315392c878ead2bd08538db
Ruby
jhar3ll/ruby-music-library-cli-online-web-pt-081219
/lib/music_importer.rb
UTF-8
269
2.890625
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 {|n| n.gsub("#{path}/", "")} end def import files.map {|n| Song.create_from_filename(n)} end end
true
620ce509215a62f696b72530f3af13d54325a31e
Ruby
naechrist/my-each-onl01-seng-ft-052620
/my_each.rb
UTF-8
117
3.296875
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def my_each(array) counter = 0 while counter < array.length yield array[counter] counter += 1 end array end
true
20aceb6de21bee951f12eabb795a2e0a156c7c33
Ruby
Akrabut/App-Academy
/Beginner Ruby/Array Methods and Enumerables/Is Valid Email.rb
UTF-8
1,266
4.21875
4
[]
no_license
#Write a method is_valid_email that takes in a string and returns a boolean indicating whether or not it is a valid email address. # For simplicity, we'll consider an email valid when it satisfies all of the following: # - contains exactly one @ symbol # - contains only lowercase alphabetic letters before the @ #...
true
68b88fd4b7d968b1891037445155c3e2f7951316
Ruby
nesaro/snippets
/nn/discriminador.rb
UTF-8
1,024
3.296875
3
[]
no_license
#!/usr/bin/ruby class Selector def initialize(umbral,*pesos) @umbral=umbral @pesos=pesos @entradas=@pesos.length end def usar(*entradas) suma=0 i=0 entradas.each{ |x| suma += x*@pesos[i] i += 1 } if suma > @umbral return 1 else return 0 end end def pesos @p...
true
37c7e5ccbe41710b58708418214088928193a46b
Ruby
gjanee/advent-of-code-2020
/22.rb
UTF-8
14,162
4.3125
4
[]
no_license
# --- Day 22: Crab Combat --- # # It only takes a few hours of sailing the ocean on a raft for boredom # to sink in. Fortunately, you brought a small deck of space cards! # You'd like to play a game of Combat, and there's even an opponent # available: a small crab that climbed aboard your raft before you # left. # # F...
true
5f35fbc33eb6ae8c71a19d420d4d71bfe8ad9039
Ruby
vidyasagarpogiri/voting-1
/app/models/election.rb
UTF-8
2,444
2.53125
3
[]
no_license
require 'date' class Election < ApplicationRecord has_many :positions, dependent: :destroy has_many :ballots, dependent: :destroy def self.currently_open self.select do |election| election.is_open? end end def self.currently_open_to(user) return self.all if user && user.is_admin? # TODO use AR sel...
true
148bb0d15a0cf12095b0ceaa5913f83d2d183375
Ruby
ferret000/ExE_Sutdy
/5th/vehicle/vehicle.rb
UTF-8
330
2.96875
3
[]
no_license
require_relative './tire' class Vehicle def initialize # タイヤを初期化 @tire = Tire.new end # 前進! def move_forward puts "前進する" return @tire.spin end end class Car < Vehicle def initialize @tire = CarTire.new end end class Truck < Vehicle def initialize @tire = TruckTire.new end end
true
9f0a15db325fc482e749d6fafb9e97c3ebc649af
Ruby
holmes/nflsquares
/app/models/game.rb
UTF-8
447
2.828125
3
[]
no_license
class Game < ActiveRecord::Base has_many :squares attr_reader :home_picks attr_reader :away_picks def add_squares for home in (0..9) for away in (0..9) self.squares.create(home_index: home, away_index: away) end end end def generate_headers @home_picks = Array.new @home_picks.pu...
true
c8daeb16903a706a23da31113f74d68c930f7c1e
Ruby
chriseichler/hw
/Moviez/moviez.rb
UTF-8
2,243
3.140625
3
[]
no_license
#a program to read and/or change entries in SQL database require 'pry' require 'pg' require 'json' require 'httparty' conn = PG.connect(:dbname => 'moviez', :host => 'localhost') print "What movie do you want to know all about? " title= gets.chomp.gsub(" ", "+") movie= HTTParty.get("http://www.omdbapi.com/?t=#{title...
true
76ca2507a0c7bbdbca22670144a972df77c00e30
Ruby
Eric-Guo/ember-tutorial
/app/models/chapter.rb
UTF-8
1,514
3.28125
3
[]
no_license
class Chapter def self.all [ 'Introduction', 'Hello World', 'The Ember Object', 'Routing in Ember', 'Ember Object Flow', 'Ember Route', 'Ember Controller', 'Ember View', 'Ember Template', 'Our App', 'Creating the Rails API', 'Creating the La...
true
444f347a8869513ccd31fe66547e9eb184473713
Ruby
jaredcwhite/phaedra-fun
/api/the-time.rb
UTF-8
453
2.59375
3
[]
no_license
require "phaedra" class PhaedraFunction < Phaedra::Base before_action :earlier_stuff def get(params) "The Current Time is: #{Time.new} and Search Param is #{params[:search]}." end def post(params) {message: "POST works!", params: params[:arr]} end private def earlier_stuff request.query...
true
e26cace56b34762a9c298185cb35015cda45d0a6
Ruby
pse-group2/medminer
/demo flo/old files/RunRelevance.rb
UTF-8
594
2.53125
3
[]
no_license
require './relevanceFinder.rb' relevanceFinder = RelevanceFinder.new entryDir = Dir.entries("entries") File.open('output.txt', 'w') {} entryDir.each do |entry| string = "entries/" + entry unless entry == "." || entry == ".." output = relevanceFinder.getRelevantWords(document (string)) File.write('output.txt...
true
4757baa852f6893cb968cceb35ad07851b001213
Ruby
anonik9900/rubyinstaller.org-website
/Rakefile
UTF-8
2,532
2.578125
3
[]
no_license
require "open-uri" require "yaml" def read_filerefs YAML.safe_load(File.read("_data/downloads.yaml", encoding: "utf-8")) end def write_filerefs(filerefs) File.write("_data/downloads.yaml", YAML.dump(filerefs)) end def new_github_assets(repo: "oneclick/rubyinstaller2", filerefs: read_filerefs) require "octokit...
true
71d828fd47ede06ff1d9e1987ceb3cb6eb31d2e2
Ruby
carinevunabandi/shekel_tracker
/features/support/pages/view_budget_page.rb
UTF-8
1,050
2.671875
3
[]
no_license
class ViewBudgetPage < SitePrism::Page set_url '/budget{/id}' def has_spending_limit_for?(budget) has_text? budget.spending_limit end def has_time_period_for?(budget) has_text? "#{budget.from_date}" has_text? "#{budget.to_date}" end def has_total_spending_for?(budget) has_text? budget.tot...
true
04bef2d4f8c7cc473146a8d098f4b719e1d80745
Ruby
hiimtaylorjones/Practical-Object-Oriented-Design
/chapter_2/project/clock.rb
UTF-8
1,487
4.21875
4
[]
no_license
# Round 2! # So, we have our Clock class. # Now we're going to try to stuff it with as much functionality as possible. class Clock # We can read / write on these variables attr_accessor :hour, :minute, :second # hour - specified hour # minute - specified minute # second - specified second # i...
true
41a6a5c2edaa008cdcaa7c5b9f807b97d57d0c5f
Ruby
fixxxer1134/prep-work
/coding-test-2/practice-problems/originalLib/02_letter_count.rb
UTF-8
237
3.046875
3
[]
no_license
def letter_count(str) @str = str.delete(" ").split(//) return_hash = {} @str.each do |x| if return_hash.has_key?("#{x}") return_hash["#{x}"] = (return_hash["#{x}"] +1) else return_hash["#{x}"] = 1 end end return_hash end
true