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
f890cb591d7ab346b124105133a9a38a7edb3fc6
Ruby
mylanconnolly/aoc2020
/day6.rb
UTF-8
3,667
3.640625
4
[]
no_license
#!/usr/bin/env ruby # frozen_string_literal: true # --- Day 6: Custom Customs --- # As your flight approaches the regional airport where you'll switch to a much # larger plane, customs declaration forms are distributed to the passengers. # # The form asks a series of 26 yes-or-no questions marked a through z. All you ...
true
1dca788f83658aa607393b21c86ecde26a3de540
Ruby
Juel07/object-oriented-design
/dependency-exercises/car-factory-example/lib/car.rb
UTF-8
282
3.375
3
[]
no_license
# Example of how to use class doubles class CarFactory def initialize(car_class = Car) # you can inject classes themselves @car_class = car_class end def make_a_car car = @car_class.new car.drive_away end end class Car def drive_away "drives" end end
true
59c601bcaf91dc51ffc26556fb2e78b47265b959
Ruby
davygora/Fibonacci
/fibonacci.rb
UTF-8
574
4.875
5
[]
no_license
# Fibonacci F(n) = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34... class Fibonacci attr_reader :first,:second def initialize @first = 1 @second = 1 @next = @first + @second end def fib(n) if n == 1 || n == 0 then puts "F(#{n}) = #{n}" elsif n > 1 || n < 0 print '0 1 1 ' (3..n).each do ...
true
8b3aa200c2950db8217d82fabbb990bd5b0b8cc9
Ruby
SebetheWombat/Ironhack
/week1/day2/blog/app.rb
UTF-8
1,545
2.84375
3
[]
no_license
require_relative("lib/blog.rb") require_relative("lib/post.rb") sec = 60*60*24 blog = Blog.new blog.add_post(Post.new("Rabid Vampire Kittens in Norfolk!", Time.now, "Title says it all really")) blog.add_post(SponseredPost.new("Chicken Crosses Street", Time.now, "It is still uncertain at this time why the chicken crosse...
true
c4ad4c67dc6d6fe535804d87aaefa38220261471
Ruby
nakadakeisuke/furima-32486
/spec/models/item_spec.rb
UTF-8
3,369
2.578125
3
[]
no_license
require 'rails_helper' describe Item do before do @item = FactoryBot.build(:item) end describe '出品機能' do context '出品がうまくいく時' do it "nameとcategory_id、price、description,condition_id,shipping_charges_id,prefecture_id,shipping_daysがあれば登録できる" do expect(@item).to be_valid end end co...
true
61de05eeb1818771e9966dfc3251266cfe5071bb
Ruby
skalum/collections_practice-v-000
/collections_practice.rb
UTF-8
761
3.9375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(array) array.sort {|a, b| a <=> b} end def sort_array_desc(array) array.sort {|a, b| b <=> a} end def sort_array_char_count(array) array.sort {|a, b| a.length <=> b.length} end def swap_elements(array) swap_elements_from_to(array, 1, 2) end def reverse_array(array) array.inject([]) {|me...
true
184243eafb5b376eab20ba2b01db635c33d57bdf
Ruby
asif-kamal/CLI_Data_Gem_project
/lib/new_science/scraper.rb
UTF-8
649
2.53125
3
[ "MIT" ]
permissive
class NewScience::Scraper def self.scrape doc = Nokogiri::HTML(open("https://www.nsf.gov/news/index.jsp?news_type=99&prio_area=0&org=NSF")) whole_page = doc.css(".media.l-media") whole_page.each do |news| date = news.css("span.l-media__date").text.strip name = news.css(".media-heading.l-me...
true
7d676406bf31c50a357494fe118621ba69b19582
Ruby
jusroberts/advent
/2016/12.rb
UTF-8
1,442
3.609375
4
[]
no_license
require "pry-byebug" class String def is_number? true if Float(self) rescue false end end input = "cpy 41 a inc a inc a dec a jnz a 2 dec a" input = "cpy 1 a cpy 1 b cpy 26 d jnz c 2 jnz 1 5 cpy 7 c inc d dec c jnz c -2 cpy a c inc a dec b jnz b -2 cpy c b dec d jnz d -6 cpy 16 c cpy 17 d inc a dec d jnz d -2...
true
63f87ca98e39dbacad8969e3fd5785ac7f549306
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/hamming/3e96b43468fa48d2b0e8ec2d76537cfb.rb
UTF-8
655
3.78125
4
[]
no_license
class Hamming def initialize @i= 0 @distance = 0 end def findSmallerNumber(s1,s2) s1.length > s2.length ? s2.length : s1.length end def hammmingCompare (s1,s2) lengthOfSmallerString = findSmallerNumber(s1,s2) #This was just used to track my code for debug.. puts " Length of smalle...
true
de2f7ea00d3af5538543264ae2b6358dba7401e6
Ruby
TSFoster/hard-timetabling
/mutations.rb
UTF-8
7,364
2.6875
3
[ "MIT" ]
permissive
# Copyright (c) 2011 Florian Pilz # See MIT-LICENSE for license information. class Mutation def to_s self.class.to_s end end class IdentityMutation < Mutation def call(individual) individual.copy end end #################### # Swapping Mutations #################### class DumbSwappingMutation < Muta...
true
9175ec84200a19c75b748243247613aabd700dc7
Ruby
ninjawithkillmoon/griffins
/lib/financial/financial_report.rb
UTF-8
1,977
3.296875
3
[]
no_license
module Financial class FinancialReport @sectionsRevenue = {} @sectionsExpense = {} @sectionsCombined = {} def initialize @sectionsRevenue = {} @sectionsExpense = {} @sectionsCombined = {} end def addTransaction(p_parent, p_category, p_amount) section = sections_by_am...
true
4b20e6401567c5694a5f89effc2ca3fb4f960c81
Ruby
daviddvg7/LPP_P10
/lib/comida/plato.rb
UTF-8
5,564
3.546875
4
[]
no_license
# encoding: utf-8 # Author:: David Valverde # Clase para representar un plato como un conjunto de alimentos y cantidades # Incluye el módulo enumerable class Plato include Comparable #Nombre del plato attr_reader :nombre #Lista de alimentos que componen el plato attr_reader :alimentos #...
true
f475a43383c661ce78198946da403507ee1eb74c
Ruby
bcaytonanderson/coding-challenges
/cats.rb
UTF-8
526
3.171875
3
[]
no_license
module Challenge def self.createcats(number) number.times do |x| x = Cat.new end end class Cat class << self attr_accessor :allcats end attr_accessor :hat def initialize @hat = true (Cat.allcats ||= []) << self end def switch @hat = !@hat end def iterate(times) for i in 1....
true
f1cf3ef254257a377dfa0380e44f8288131d264e
Ruby
ngeballe/ls120-lesson2
/review/1_classes_and_objects/ex4.rb
UTF-8
673
4.34375
4
[]
no_license
# Using the class definition from step #3, let's create a few more people -- that is, Person objects. class Person attr_accessor :first_name, :last_name def initialize(first_or_full) set_name(first_or_full) end def name=(first_or_full) set_name(first_or_full) end def name "#{first_name} #{la...
true
4dba6cc9ee8f53895b1c99a6c194c014bda58c28
Ruby
ebertolazzi/Mruby_customized
/mrbgems/pins-mruby-SymDesc/test/test-Ratio.rb
UTF-8
4,789
3.609375
4
[ "MIT" ]
permissive
require_relative "test.rb", __FILE__ class TestRatio < Test::Unit::TestCase def setup @r = Ratio.new(1,3) end def test_new assert @r.is_a?(Ratio), "Wrong initialization of Ratio" assert_equal @r,1/3.to_r, "Wrong representation of a rational" r = Ratio.new(2.5) as...
true
cd8d988df4e0f06770fee44c9e0ab5005d4d9898
Ruby
njonsson/cape
/lib/cape/core_ext/symbol.rb
UTF-8
609
2.984375
3
[ "MIT" ]
permissive
module Cape module CoreExt # Adds methods missing from Ruby's Symbol core class. module Symbol # Compares the String representation of the Symbol to that of another. # # @param [Symbol] other # # @return [0] the Symbol is equal to _other_ # @return [-1] the Symbol is le...
true
69ba89c6cd5b0b85fa3aabb9db9960d91c59c3a0
Ruby
chuckremes/options_library
/lib/options_library/option_model.rb
UTF-8
2,927
3.171875
3
[]
no_license
# Author Dan Tylenda-Emmons # Since Feb 18, 2011 # Based on Black-Scholes forumla for pricing options module Option class Model # The two known option types, Call and Put KNOWN_OPTION_TYPES = [:call, :put] # A map to define methods to call based on option_type CALC_PRICE_METHODS = { :call=>Calcula...
true
5743b9f1225776f234f01adc26bffcecf3207dcb
Ruby
chadellison/chess_mail
/app/models/concerns/ai_logic.rb
UTF-8
1,764
2.546875
3
[]
no_license
module AiLogic extend ActiveSupport::Concern def ai_move winning_game = random_winning_game notation = winning_game.move_signature.split('.')[moves.count] if winning_game.present? next_move = create_move_from_notation(notation, pieces) if notation.present? next_move = create_from_move_rank(position...
true
a5d2c08fefa3a8425b77b352080439b379268860
Ruby
francosta/OO-mini-project-london-web-career-040119
/app/models/Recipe.rb
UTF-8
808
3
3
[]
no_license
class Recipe attr_reader :name @@all = [] def initialize(name) @name = name @@all << self end def self.all @@all end def users RecipeCard.all.map {|rc| if rc.recipe == self then rc.user end}.compact end def no_users users.length end def self.most_popular @@all.max_by...
true
e369ee4a631a4452c3d2d33e50fd2af96be670cf
Ruby
dinhhientran/ruby-exercism
/clock/clock.rb
UTF-8
969
3.671875
4
[]
no_license
=begin Write your code for the 'Clock' exercise in this file. Make the tests in `clock_test.rb` pass. To get started with TDD, see the `README.md` file in your `ruby/clock` directory. =end class Clock def initialize(options = {}) @hour = options.include?(:hour) ? options.fetch(:hour).to_i : 0 @minute = opt...
true
7a88735dc85a43b0855ac073f969e38e1d5dd08f
Ruby
amanda08/hearthstone-ruby
/lib/player.rb
UTF-8
336
3.09375
3
[]
no_license
class Player attr_reader :name, :score def initialize(name) @name = colorize(name) @score = 0 # @hand # @current_card # ability to come later! end def add_score(value) @score += value end def colorize(name) "\e[01;#{rand(30..36)}m" + name + "\e[0m" end # def take_turn (se...
true
6d8d725c2296887bf3d9c22a331ed6fc6a931180
Ruby
RyanScottLewis/mruby-termui
/mrblib/term_ui/has_attributes.rb
UTF-8
490
2.703125
3
[]
no_license
module TermUI # Adds the `update_attributes` method. module HasAttributes # Initialize this object by optionally updating attributes with a Hash. def initialize(attributes={}) update_attributes(attributes) end # Update any attributes on this object. def update_attributes(attri...
true
d517ea19ad81441850d15b34d9393fbcd9fd2283
Ruby
kevinzhuang10/bucketlist-api
/app/services/create_list.rb
UTF-8
291
2.59375
3
[]
no_license
class CreateList def initialize(name:, user_id:) @name = name @user_id = user_id end def call list = List.create(name: name, user: user) Result.new(status: :ok, payload: list) end private attr_reader :name, :user_id def user User.find(user_id) end end
true
a1e597b3caab3d425b322e397c0bbdcd1347cbe4
Ruby
m1kal/exercism_ruby
/simple-cipher/simple_cipher.rb
UTF-8
824
3.4375
3
[ "MIT" ]
permissive
class Cipher ALPHABET_LENGTH = 'z'.ord - 'a'.ord + 1 attr_accessor :key def initialize(key = nil) @key = validate(key) || (('a'..'z').to_a.join * 100).split('').sample(100).join end def validate(key) raise ArgumentError if key =~ /[^a-z]/ || (!key.nil? && key.empty?) key end def...
true
535ae3b492aa3cd22007b334f0659860256ae209
Ruby
DeepakUp9/Ruby_Basic_Code
/Opps/classAndObject.rb
UTF-8
387
3.640625
4
[]
no_license
# class is own custom data type # class is blue print class Book attr_accessor :titile, :author , :pages end # instance of class book1= Book.new() book1.titile="Harry Potter" book1.author ="Jk Rowling" book1.pages =500 puts book1.titile puts book1.author puts book1.pages book2= Book.new(); book2.titile ="L...
true
bab0d76d86c7d4093bce022c1a9bb4eafaf475bd
Ruby
allbecauseyoutoldmeso/gilded_rose
/lib/sell_in_manager.rb
UTF-8
352
2.890625
3
[ "MIT" ]
permissive
require_relative 'item_category_helper' class Sell_In_Manager include Item_Category_Helper attr_reader :items def initialize(items) @items = items end def update_items items.each do |item| reduce_sell_in(item) end end def reduce_sell_in(item) if ! is_sulfuras?(item) item....
true
3c2c1b96f179c2eba52a515ca67d2da101ce2b4d
Ruby
codeloopy/appacademy
/Intro/hashes/unique_elements.rb
UTF-8
618
4.625
5
[]
no_license
# Write a method unique_elements that takes in an array and returns a new array # where all duplicate elements are removed. Solve this using a hash. # Hint: all keys of a hash are automatically unique def unique_elements(arr) hash = Hash.new(0) non_duplicates = [] arr.each { |char| hash[char] += 1 } hash.ea...
true
ca102c375c593dd059cbf4f8eb70c145a9c3c0a8
Ruby
gmega/sparmap-ruby
/examples/fetch_titles.rb
UTF-8
678
2.859375
3
[ "MIT" ]
permissive
require 'open-uri' require 'sparmap' URL_LIST = %w( https://en.wikipedia.org/wiki/WebCrawler https://en.wikipedia.org/wiki/University_of_Washington https://en.wikipedia.org/wiki/Starwave https://en.wikipedia.org/wiki/America_Online https://en.wikipedia.org/wiki/Global_Network_Navigator https://en.wikipedia...
true
cbb8d190ee706d367a10a10c429ac1eb309e12a5
Ruby
RANDRIANTSIVOHO/appointment-scheduler
/app/models/slot.rb
UTF-8
3,061
3.140625
3
[]
no_license
class Slot < ApplicationRecord belongs_to :availability using Refinements DURATION_IN_MINUTES = 30.freeze # Localize a Coaches time slot, via the # Coaches time zone to a Students time # zone. # # Example: # # Coaches time slot and time zone: # "9:30AM Central Time (US & Canada)" # # ...
true
f94a3dcc22ad1ca98dbb0ebb64c12d21c4483cb0
Ruby
ddrakes/ruby-object-attributes-lab-v-000
/lib/dog.rb
UTF-8
237
3.078125
3
[]
no_license
class Dog def initalize(name) @name = name end def name @name end def name=(new_first) @name = new_first end def breed(breed) @breed = breed end def breed @breed end def breed=(breed_name) @breed = breed_name end end
true
901eeff6061d92c167b0cb867d96d3652b1b253a
Ruby
cassianoblonski/render_sync
/lib/render_sync/scope_definition.rb
UTF-8
1,096
2.84375
3
[ "JSON" ]
permissive
module RenderSync class ScopeDefinition attr_accessor :klass, :name, :lambda, :parameters, :args def initialize(klass, name, lambda) self.class.ensure_valid_params!(klass, lambda) @klass = klass @name = name @lambda = lambda @parameters = lambda.parameters.map { |p| p...
true
a292cab588ea56fa86d02cfad148891d41f75a87
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/filtered-submissions/9e263f19cd2c4865bd786c6d930093e9.rb
UTF-8
315
3.0625
3
[]
no_license
def compute(strand_1, strand_2) if strand_1.length < strand_2.length short = strand_1.chars long = strand_2.chars else short = strand_2.chars long = strand_1.chars end count = 0 short.each_with_index do |c,i| count += 1 unless c == long[i] end count
true
605b729452d591be4f03003c1fec1381f723c22b
Ruby
davidpaps/bookmark_manager
/spec/bookmark_spec.rb
UTF-8
1,224
2.765625
3
[]
no_license
require 'bookmark' describe Bookmark do describe '.all' do it "returns all of the bookmarks" do Bookmark.create('Makers', 'http://www.makersacademy.com') expect(Bookmark.all[0].title).to include('Makers') expect(Bookmark.all[0].url).to include('http://www.makersacademy.com') end end ...
true
a9e59e251f12d7bfbf62207b09e2a02c4cef1f05
Ruby
jpedro-50/ESSBetRuby
/models/bookie.rb
UTF-8
306
2.828125
3
[]
no_license
require_relative '../modules/observer' class Bookie attr_accessor :name, :password @name @password include Observer def initialize(name='', password='') super() @name = name @password = password end def notification return "O jogo que estava a seguir terminou" end end
true
e9295d6c2f60dbb130c0422c8581ade49a780bec
Ruby
PreetBhadana/Training
/Ruby/Ruby_Programs_Practice/Program_Practice6.rb
UTF-8
360
3.40625
3
[]
no_license
''' Very Easy 6 You are counting points for a basketball game, given the amount of 3-pointers scored and 2-pointers scored, find the final points for the team and return that value (2 -pointers scored, 3-pointers scored). Examples points(1, 1) ➞ 5 points(7, 5) ➞ 29 points(38, 8) ➞ 100 ''' def points(x, y) return...
true
22440a527fcab4dba525e7b3a15ae4a46184c3d9
Ruby
niv-eventify/eventify-server
/lib/image_merger.rb
UTF-8
715
2.59375
3
[]
no_license
require 'logger' module ImageMerger class << self def merge_two_images(top, bottom_pics, file_name) dst = Tempfile.new([file_name, ".png"]) command = "composite -geometry #{bottom_pics[0][1]} #{bottom_pics[0][0]} #{RAILS_ROOT}/public/images/empty_invitation.png #{dst.path}" Paperclip.run(command...
true
2936db5d4003f2ddb90258c9281b7c78b2ba6fc3
Ruby
nigel-lowry/i_ching
/features/step_definitions/plotting_steps.rb
UTF-8
196
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
When("the score is {string}") do |string| @score = string.to_i end Then /^the monogram should be "([^"]*)"$/ do |monogram| expect(IChing::MonogramPlotter.new(@score).to_s).to eq(monogram) end
true
7d5462af9beb902b6145a3f37c3a48670eabbf39
Ruby
yeti-switch/yeti-web
/app/services/build_record_copy.rb
UTF-8
1,042
2.5625
3
[]
no_license
# frozen_string_literal: true class BuildRecordCopy < ApplicationService parameter :from, required: true # The links assign associations from original record to a copy. # Usage: has_and_belongs_to_many associations. parameter :links, default: [] # The duplicates creates copies of associations from original r...
true
2251e92f78175f0307924c13e2404ee008d84a75
Ruby
learn-co-students/ruby-objects-has-many-through-lab-web-103017
/spec/04_doctor_spec.rb
UTF-8
1,669
3
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "spec_helper" describe "Doctor" do describe "#new" do it "initializes with a name and an empty collection of appointments" do doctor_smith = Doctor.new("John Smith") expect{ Doctor.new("Martha Jones")}.to_not raise_error expect(doctor_smith.instance_variable_get(:@appointments)).to e...
true
f7ce80e178b68c1153056e7b3225bf26094c5f36
Ruby
jesusmaldonado/algorithms
/ch2/ch2Problems.rb
UTF-8
2,740
4.0625
4
[]
no_license
#cormen algorithms book ch. 2 #[5,2,4,6,1,3] def insertion_sort(array) #go through the array array.each_with_index do |el, i| #n steps #the elements starting from [0..i - 1] will always be sorted (initialization loop invariant) # run 1: el: 5, i: 1 j = i - 1 #1 step while j >= 0 && array[j] > el #...
true
55085240edb75afd1a709968c08dbe647d82483f
Ruby
nekonekosurf/experiment_detabase
/2/HTTP_Server.rb
UTF-8
399
2.921875
3
[]
no_license
require 'socket' server = TCPServer.new 2000 loop do client =server.accept headers=[] while header = client.gets if header.chomp.empty? break end headers << header.chomp end p headers client.puts "HTTP/1.0 200 OK " client.puts "Content-Type: text/html" client.puts client.puts "<h1> Hello, Wo...
true
87561a8b44b916a890bc725fc09a390369dc121d
Ruby
mbj/unparser
/lib/unparser/anima/attribute.rb
UTF-8
1,223
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true module Unparser class Anima # An attribute class Attribute include Adamantium, Equalizer.new(:name) # Initialize attribute # # @param [Symbol] name def initialize(name) @name = name @instance_variable_name = :"@#{name}" end ...
true
841773b7072cab61337fc7f9e24547cc4767fe3a
Ruby
seblindberg/ruby-richtext
/test/readme_test.rb
UTF-8
2,064
3.5
4
[ "MIT" ]
permissive
require 'test_helper' describe 'README.md' do it 'gives the correct output' do # Create a new RichText document rt = RichText::Document.new 'hello ' # Or use the more convenient method rt = RichText 'hello ' # Format the text using attributes entry = rt.append('world', bold: true, my_attrib...
true
2d9ce7d8f1bdcdb62b026410fc984948a1fd8b86
Ruby
nmbits/miw
/lib/miw/split_view.rb
UTF-8
4,736
2.65625
3
[ "MIT" ]
permissive
require 'miw' require 'miw/view' require 'miw/layout/box' require 'miw/point' require 'miw/util/axis' module MiW class SplitView < View class Resizer def initialize(split_view, index) @view = split_view @index = index @orientation = @view.orientation @axis = Util::Axis.new ...
true
726706975ca7b2547634f2ae2f443cc8f63f922f
Ruby
AgencyAgency/Planets
/subclassed_planets.rb
UTF-8
2,450
3.25
3
[]
no_license
class Planet def initialize size, orbit, hue, deg_vel, degs, sketch_w, sketch_h @size = size @degs = degs @orbit = orbit @hue = hue @deg_vel = deg_vel # angular velocity in degs @width = sketch_w @height = sketch_h end def move @degs += @deg_vel theta = Math::PI * @degs / 180...
true
6224482a266ebc66456b587e230810a359d803b5
Ruby
shivani329/phase-0-tracks
/ruby/secret_agents.rb
UTF-8
1,210
3.96875
4
[]
no_license
#Encrypt #Take a string input #Parse through string adding 1 to the position value of each point #return new string def encrypt(stringInput) alphabetString = "abcdefghijklmnopqrstuvwxyz" lengthString = stringInput.length returnString = "" for i in 0..lengthString -1 if stringInput[i] == " " returnS...
true
87cd4d703319b832efe2a1c1a455b4a690bf1c21
Ruby
mintmnr/new_random_bot
/lib/services/message_parser.rb
UTF-8
542
2.984375
3
[]
no_license
# frozen_string_literal: true class MessageParser def initialize(message) @message = message end def chat # TODO: change with the & if @message.respond_to?(:chat) @message&.chat else @message&.message&.chat end end def type @message end def method_missing(method_nam...
true
964fb2c660d23dfe2eeddcaddb6465c4f89b042f
Ruby
lewhitley/w2d3
/tdd/spec/towers_spec.rb
UTF-8
1,442
3.546875
4
[]
no_license
require 'rspec' require 'towers' describe TowersOfHanoi do subject(:tower) { TowersOfHanoi.new } describe "#initialize" do it "makes three stacks" do expect(tower.stacks.length).to be(3) end it "fills the first stack" do expect(tower.stacks.first).to eq([3, 2, 1]) end end descri...
true
9a2766e8ac5e524fe1e97c3170801a9d91136d93
Ruby
vecnet/vecnet-dl
/app/models/geoname_hierarchy.rb
UTF-8
1,333
2.78125
3
[ "Apache-2.0" ]
permissive
class GeonameHierarchy < ActiveRecord::Base self.table_name = 'geoname_hierarchy' attr_accessible :geoname_id, :hierarchy_tree, :hierarchy_tree_name belongs_to :geoname , :foreign_key => "geoname_id" def self.find_or_create(geoname_id,tree) hierarchy = GeonameHierarchy.find_by_geoname_id(geoname_id) if...
true
d106cb9a02fef26613d0cd475bc2cf6b50f4d333
Ruby
Hongj2/deli-counter-online-web-prework
/deli_counter.rb
UTF-8
438
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
katz_deli = [] def line (other_deli) other_line.map.with_each_index {|name,index| "The line is currently: #{index+1}. #{name}"} end def take_a_number (katz_deli, "#{name}") katz_deli.map.with_each_index {|name,index| "Welcome #{name}. You are number #{index + 1} in line. " } end def line (katz_deli) katz_del...
true
0e4278c57819b5c7e79292a9edbef5b67341c805
Ruby
func-i/painsquad
/app/services/user_award_service.rb
UTF-8
1,431
2.625
3
[]
no_license
class UserAwardService def self.analyze(object, modals = nil) new(object, modals).process end def initialize(object, modals) @object = object @user = object.user @last_event = @user.activities.last @modals = modals || [] end def process check_submission if @object.is_a?(S...
true
a316189635262a8c937bd1be3566e04f88601563
Ruby
divbeech/ttt-8-turn-nyc-fasttrack-072719
/lib/turn.rb
UTF-8
1,131
3.984375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code your #valid_move? method here def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end def input_to_index(user_input) index = user_input.to_i ...
true
2ec75d919ae43c7d5a145c1e13b7ab817d1f1fd7
Ruby
gnufied/representable
/test/representable_test.rb
UTF-8
1,916
2.609375
3
[ "MIT" ]
permissive
require 'test_helper' class RepresentableTest < MiniTest::Spec class Band include Representable representable_property :name end class PunkBand < Band representable_property :street_cred end describe "#representable_attrs" do it "responds to #representable_attrs" do assert_equa...
true
01911c270574c94b31a15d52dfc20f83f418da4a
Ruby
dwhelan/pad
/lib/pad/delegate_via.rb
UTF-8
1,146
2.515625
3
[ "MIT" ]
permissive
module DelegateVia class << self def included(base) base.extend ClassMethods end end module ClassMethods # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def delegate_via(accessor_name, *method_names, &return_block) options = method_names.last.is_a?(Hash) ? method_names.pop...
true
680d5b6e436e85724d3d9c0ac8231475546cc51c
Ruby
leosiimas-pratice/ruby-pratice
/calculadora.rb
UTF-8
771
4.53125
5
[]
no_license
loop do puts '1 - Soma' puts '2 - Subtrair' puts '3 - Multiplicar' puts '4 - Dividir' puts '0 - Sair' print 'Digite uma opção: ' op = gets.chomp.to_i if op == 0 system "clear" break end print 'Digite um numero: ' numero1 = gets.chomp.to_i print...
true
52940f7ce6b6f8df0f7c7f4e89604927964407ca
Ruby
pdjohnson1984/LaunchSchool-Extra_Problems
/101-109 Small Problems/easy 4/short_long_short.rb
UTF-8
334
3.4375
3
[]
no_license
def short_long_short(word1, word2) concat_word = "" if word1.length > word2.length concat_word << word2 << word1 << word2 else concat_word << word1 << word2 << word1 end end p short_long_short('abc', 'defgh') == "abcdefghabc" p short_long_short('abcde', 'fgh') == "fghabcdefgh" p short_long_short('', 'x...
true
b21046a000afb764031af0d6d0ab2d01a5626c38
Ruby
AbbottMichael/backend_mod_1_prework
/section3/exercises/ex34.rb
UTF-8
2,931
3.765625
4
[]
no_license
animals = ['bear', 'ruby', 'peacock', 'kangaroo', 'whale', 'platypus'] p animals # 1. The animal at 1 is the 2nd animal and is a ruby. The 2nd animal is at 1 and is a ruby. # 2. The third (3rd) animal is at 2 and is a peacock. The animal at 2 is the 3rd animal and is a peacock. # 3. The first (1st) animal is at 0 and i...
true
f345f3c3cae4a1e8d33502fdf289a6d8b2a914fd
Ruby
dili021/Various-Algorithms-From-Various-Places
/happyLadybugs.rb
UTF-8
1,042
4.21875
4
[]
no_license
# Return "yes" or "no" if all letters in a string have more than one occurrence # and they can be rearanged to be next to the same letters. Read full description on [hackerrank](https://hackerrank.com) def happyLadybugs(b) # create a counter variable by reducing the given string into a new hash with each character #...
true
aebeb1643de4ac9512a3d7420234f28bf112b541
Ruby
vgulaev/codenjoy-client-gem
/spec/games/battlecity/board_spec.rb
UTF-8
1,648
2.53125
3
[ "MIT" ]
permissive
RSpec.describe Codenjoy::Client::Games::Battlecity do before(:context) do @formated_data = File.open("spec/games/battlecity/test_board.txt", "r").read @board = Codenjoy::Client::Games::Battlecity::Board.new data = @formated_data.split("\n").join('') @board.process(data) end let(:enemies) do [...
true
b75f492421710ed96c6cc3a4dfae6af0cd0346b5
Ruby
ctorok/ga-test
/main.rb
UTF-8
1,675
3.65625
4
[]
no_license
# Author: Catharina Torok # Date: 09/18/2013 require_relative 'functions' # Use a currency set of pennies, nickels, dimes, quarters # Make change from a given amount of cents and returns a currency set # Make change for quantities up to 100 cents # Make cents from a given amount of currency and returns as a total numb...
true
91c50c4f5da3e5c4285f6a29a1c31143cd961acf
Ruby
viewworld/NewBizzShoppen
/lib/c_week.rb
UTF-8
747
3.109375
3
[]
no_license
class CWeek include Comparable attr :date def initialize(week = nil, year = nil) @date = Date.commercial( year || Date.today.year, week || Date.today.cweek, 1 ) end def self.first(year = nil) CWeek.new(1, year || Date.today.year) end def self.last(year = nil) CWeek.ne...
true
619164ca97e666c6b6efd0a1137bc4972db81797
Ruby
jacqueline-lam/prime-ruby-online-web-pt-090919
/prime.rb
UTF-8
517
4.03125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime?(integer) #return boolean whether interger is prime num #get rid of negatives to 1 return false if integer < 2 #chceck if anything is able to divide it (2...integer).each do |factor| # prime # = nothing divisible by that # # if not prime: if integer % factor == 0 return fals...
true
bfb82aafd2fd86b41221a5605c3307b05af1a0dd
Ruby
Asoyan/RubyJeudi
/exo_03.rb
UTF-8
144
3.453125
3
[]
no_license
bonjour = "Bonjour, monde !" puts(bonjour) #print ("Et avec une voix sexy, ça donne : " +bonjour) # Le "#"" est pour une ligne de commentaire
true
c060b524fafd9c0be612399e1a7d25c5a6b97e84
Ruby
Nztzlie/phase_0_unit_2
/week_5/5_virus_predictor/original_code.rb
UTF-8
2,624
4.15625
4
[]
no_license
# U2.W5: Virus Predictor # I worked on this challenge with Indigo. # EXPLANATION OF require_relative # # The require relative defines a dependency to another file based on a relative filepath, # including it as if it was in tha same scope as thir file which has required it. require_relative 'state_data' class Viru...
true
9a0d99c57be057a633f125d9ed07d2fd33b5ea23
Ruby
fhayes301/Tech_Interview_Prep
/Cracking the Coding Interview/Ch-1: Arrays and Strings/C1.2.rb
UTF-8
293
4
4
[]
no_license
#Given two strings, write a method to decide if one is a permutation of the other. def permuted_string(str1, str2) return true if str1.split('').sort == str2.split('').sort false end p permuted_string("lemon","melon") p permuted_string("egg", "juice") p permuted_string("lemon","lemon")
true
0a0d55c56762cea68e901379f699e50ab22f3d2b
Ruby
rickymclaren/projecteuler
/10.rb
UTF-8
540
3.765625
4
[]
no_license
#! /usr/bin/ruby # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. # The Prime generator in ruby 1.8 is too slow over about 100000 primes # Had to write a Seive of Erasthones to go faster limit=2000000 seive = Array.new(limit+1, true) (2..limit).each do |x| ...
true
c14a61df404bd2a068e16365d9611c8f4ce892bc
Ruby
liggest/rcnb.rb
/lib/rcnb/str.rb
UTF-8
1,710
3.171875
3
[ "MIT" ]
permissive
require File.expand_path("../../rcnb.rb",__FILE__) module RCNB # 字符串增强 # ## Example # ```ruby # require 'rcnb/str' # using RCNB::Str # # 'Who NB?'.rcnb # # => ȐȼŃƅȓčƞÞƦȻƝƃŖć # 'ȐĉņþƦȻƝƃŔć'.rcnb_decode # # => RCNB! # 'ȐĉņþƦȻƝƃŔć'.rcnb? # # => RCNB! # 'not rcnb'.rcnb? # # => nil # ``` #...
true
6b2f2a77ec84f4126c3c9d2149beada77a00288d
Ruby
huned/rupee
/lib/rupee/business_day/modified_following.rb
UTF-8
526
2.953125
3
[ "MIT" ]
permissive
module Rupee class BusinessDay # Modified following business day convention MODIFIED_FOLLOWING = BusinessDay.new "Roll to following business day " + "unless it's in the next month, then use previous business day" do |date, calendar| month = date.month while calendar.day_off?(date) && date.m...
true
f8d136203ae8489e77d5f71a9df6b5715a00488c
Ruby
jiteshrath123/programming
/Graph/graph_dfs/no_of_path_between_two_nodes.rb
UTF-8
869
3.671875
4
[]
no_license
class Graph def initialize(n) @graph = {} @count = 0 @v = n for i in 0..n-1 @graph[i] = [] end end def add_new_edge(x, y) @graph[x] = [] unless @graph.has_key?(x) @graph[x].push(y) end def count_paths(src, des) visited = Array.new(@v, false) path_cou...
true
767f69e0f971ce6b867254ad3c7514367ea8ca49
Ruby
mixeeff/rubylessons
/lesson_8/station_operations.rb
UTF-8
822
3.125
3
[]
no_license
module StationOperations def create_station station_name = ask_user('Enter station name: ').capitalize station = Station.new(station_name) @my_railway.stations << station puts "Station #{station} created" end def show_stations return puts NO_STATIONS_ERROR unless @my_railway.stations? sh...
true
247878f1e82b4b983efdd676dd5c9bb00b007b96
Ruby
Gelani-G/apress-variables
/spec/lib/variables_spec.rb
UTF-8
7,858
2.53125
3
[]
no_license
# coding: utf-8 require 'spec_helper' class TestSource def self.value_as_string(params) "test_source_#{params[:field]}_#{params[:object][:company_id]}" end end describe Apress::Variables::Variable do let(:id) { :id } let(:name) { nil } let(:desc) { nil } let(:type) { nil } let(:default) { nil } le...
true
e396884fcaadcb870bc7caf3219d2b52dd647fcc
Ruby
danielma/rufo
/lib/rufo/doc_builder.rb
UTF-8
3,815
2.90625
3
[ "MIT" ]
permissive
module Rufo class DocBuilder class InvalidDocError < StandardError; end class << self # Combine an array of items into a single string. def concat(parts) assert_docs(parts) { type: :concat, parts: parts, } end # Increase level of indentation. ...
true
f500f569da3baf7b6f77e547f9540a996f8a2c71
Ruby
vidoseaver/headcount
/lib/headcount_analyst.rb
UTF-8
9,803
3
3
[]
no_license
require "pry" require_relative 'magic' require_relative 'result_set' require_relative 'result_entry' class HeadcountAnalyst include Magic def initialize(district_repo = "district_repo") @district_repo = district_repo end def find_district_by_name(name) @district_repo.find_by_name(name) end def ...
true
9788bb80c6e484c09632507f4e7a14b2b5e8a870
Ruby
fishmacs/mycode
/ruby/iter.rb
UTF-8
164
3.625
4
[]
no_license
def sequence(n, m, c) i, s = 0, [] while(i < n) y = m*i + c if block_given? s << (yield y) else s << y end i += 1 end s end
true
df199f7930702adc26bd655c19d6bfeb8bd36ca0
Ruby
lapohl/SoftwareDev_Prep
/GitHub/LaunchSchool/LS_Ruby_Basics.rb
UTF-8
15,261
3.9375
4
[]
no_license
=begin #VARIABLE SCOPE p 'xyz'.upcase() a = %w(a b c d e) a.insert(3, 5, 6, 7) p a s = 'abc def ghi,jkl mno pqr,stu vwx yz' puts s.split.inspect puts s.split(',').inspect puts s.split(',', 2).inspect a = 7 def my_value(b) b += 10 end my_value(a) puts a a = 7 def my_value(a) a += 10 end my_value(a) puts ...
true
438698037ca4085a75933c62d340685ba3b7d850
Ruby
maiyama18/AtCoder
/abc/003/a.rb
UTF-8
38
2.65625
3
[]
no_license
n = gets.to_i puts 10000 * (n + 1) / 2
true
dbea241e1b24431855aa5b0483799f632aae8e27
Ruby
randomutterings/fundage
/app/models/entry.rb
UTF-8
960
3
3
[ "MIT" ]
permissive
# Entries are the records of debits and credits to various wallets # In accountant speak, they're 'entries' in the 'Journal' or 'Ledger' class Entry < ActiveRecord::Base has_many :credits, inverse_of: :entry has_many :debits, inverse_of: :entry validates_presence_of :credits, :debits validates_associated :cred...
true
71b5c565ac22cf89cb1f771ae5dff8587f2d9207
Ruby
kenikall/wccusd
/db/seeds.rb
UTF-8
7,111
2.578125
3
[ "MIT" ]
permissive
require 'csv' # seed pathway # Survey.destroy_all # Provider.destroy_all # Event.destroy_all # ***** Pathway.destroy_all %w(Law Health IT).each do |path| Pathway.create(school: "DeAnza High School", path: path) end %w(IT Media).each do |path| Pathway.create(school: "El Cerrito High School", path: path) end %...
true
4511f58adceb0bbe64985d5771d737f7ac7bb289
Ruby
chetan/rbot
/plugins/old.rb
UTF-8
1,317
2.515625
3
[]
permissive
# old! # by chetan sarva <cs@pixelcop.net> 2008-09-11 # # never forget! don't paste old links, bitch!@ class OldNewsPlugin < Plugin def say_old(m, params) # http://www.pixelcop.org/~chetan/files/jpg/old.jpg # http://is.gd/2vj6 m.reply "nicca that's so old! http://is.gd/2vj6" end def say_sad(m,...
true
ec7bde6b21763248751070946de4189238195a04
Ruby
spookyvert/countdown-to-midnight-prework
/countdown.rb
UTF-8
176
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
#write your code here def countdown number = 10 while number > 0 puts "#{number}" sleep 1 number-- break if number == 0 end puts "HAPPY NEW YEAR!" end
true
eee518683b703b3c31019cfdea61c4b72cf2686a
Ruby
TBioucas/Rubyist
/Part 2 - Chapter 9/9.3/store.rb
UTF-8
113
2.8125
3
[]
no_license
hash = {"a" => 1, "b" => 2, "c" => 3} hash["d"] = 4 hash.store("e",5) puts hash hash.store("e",6) puts hash
true
c6a6ab8fb619cbb3de3b338fa8bd9dce5e9a38ce
Ruby
NicoRodz/LearningRuby
/lenguaje/iterador.rb
UTF-8
323
3.625
4
[]
no_license
(1..10).each do |numero| puts numero end (0..20).step(2).each do |numero| #step para ir de dos en dos puts numero end ('a'..'z').each do |numero| #step para ir de dos en dos puts numero + "," end puts (0..10).min puts (0..10).max puts (0..10).to_a.reverse #convierte el rango a un arreglo puts ('ma'..'md').to...
true
cf5c6b71b3b342ae7b27a1e888f6291a384cbcfe
Ruby
PeterNet1/Ruby-course
/Task1/sample_spec.rb
UTF-8
1,201
2.875
3
[]
no_license
describe '#convert_to_bgn' do it 'converts usd' do expect(convert_to_bgn(1000, :usd)).to eq 1740.8 end it 'converts bgn - test pesho' do expect(convert_to_bgn(1000, :bgn)).to eq 1000 end it 'converts eur - test pesho' do expect(convert_to_bgn(1000, :eur)).to eq 1955.7 end it 'converts gbp -...
true
282594d08a1313c96ab369917b1578a976705ca3
Ruby
rubybfm1017/AAClasswork
/w1-3/w1/w1d3/project2/nauseating.rb
UTF-8
10,119
3.890625
4
[]
no_license
def strange_sums(arr) pairs = 0 arr.each_with_index do |i , idx1| arr.each_with_index do |j , idx2| if i + j == 0 && idx1 < idx2 pairs += 1 end end end end # p strange_sums([2, -3, 3, 4, -2]) # 2 # p strange_sums([42, 3, -1, -42]) # 1 # ...
true
ea11a0518802c8481787d339bd3b6ab88062c2ba
Ruby
latagore/math-game
/math_game.rb
UTF-8
3,442
3.9375
4
[]
no_license
require './game_state' require './player' require './question' module MathGame module GameState def next; end def status; end def done; end end class InitialState include GameState def initialize(game) @game = game end def next @game.state = PlayState.n...
true
0159de8e7eae9d9744bcd1b7c84ed211bcb929aa
Ruby
bennorris/ttt-with-ai-project-v-000
/lib/game.rb
UTF-8
2,162
3.875
4
[]
no_license
require_relative 'players/human.rb' require 'pry' class Game include Players attr_accessor :board, :player_1, :player_2 def initialize(player_1=Players::Human.new("X"),player_2=Players::Human.new("O"), board=Board.new) @player_1 = player_1 @player_2 = player_2 @board = board end WIN_COMBINATIONS = [ [0,1,2...
true
2e3a6fd04f7bd712e6e3d1d2ddd6bf01c3cceb91
Ruby
mitchellcarroll/landlord
/db/seeds.rb
UTF-8
1,194
2.84375
3
[]
no_license
require_relative "connection" require_relative "../models/apartment" require_relative "../models/tenant" Tenant.destroy_all Apartment.destroy_all John = Tenant.create(name:"John Doe", age: 25, gender:"Male", apartment_id: 21) Jane = Tenant.create(name:"Jane Doe", age: 30, gender:"Female", apartment_id: 22) Mary = Ten...
true
b547d713ab5ab65e78aa3160278f8e221a83d3c7
Ruby
Marvalero/LearningRuby
/chapter06-regular_expresion/palindrome.rb
UTF-8
269
3.890625
4
[]
no_license
#!/usr/bin/ruby class Palindromo def initialize(palin) @palin = palin end def is_palindrome? match = /((.*),(.*))/.match(@palin) puts "#{$2}-#{$3}" $2.reverse==$3 end end puts "Es palindromo" if Palindromo.new("Lo que,euq oL").is_palindrome?
true
ba4b49666c4e0b08ff51a8a0c44fd361e2397c03
Ruby
projectkamira/analyze_codes
/lib/analyze_value_sets.rb
UTF-8
2,377
2.84375
3
[ "Apache-2.0" ]
permissive
module AnalyzeValueSets # Analyze value sets for intersection with patient data # @param [HealthDataStandards::SVS::ValueSet[]] value_sets # @param [{}] all_codes_found as map of {codeSetOID => {code => count}} # @param [Measure] all measures # @return [{}] map of {valueSetOID => {:totalCodes => count, :code...
true
b4c86a5aec9473ea29e30ea6a618f280f3ebcd80
Ruby
vishalvijay/reward_system
/lib/tasks/seed_rewards.rake
UTF-8
4,650
2.53125
3
[ "Apache-2.0" ]
permissive
task seed_rewards: :environment do fixed_points = [200, 300, 150, 500, 100, 1000] reward_brands = [ { name: "Flipkart", background_color: "#fdd922", font_color: "#157ed2", description: "Shop the Online Megastore with the free Flipkart Android app. Choose from the massive selection of ori...
true
b2de1ce0805bffaed06d26a0e494f5f590bb83e8
Ruby
caphg/billme
/lib/billme/service_details.rb
UTF-8
247
2.578125
3
[ "MIT" ]
permissive
module Billme class ServiceDetails < ServicesSection attr_reader :data def initialize @data = {} end def method_missing(name, *args, &block) return @data[name] = args[0] unless block_given? raise "Not supported!" end end end
true
48746933a666a675a000fd0498a2ccd632be97c2
Ruby
goldbook/jpshp2db
/tests.rb
UTF-8
2,694
2.875
3
[]
no_license
puts "*** start test.rb ***" require 'sequel' class Result @ok @ng def initialize @ok = 0 @ng = 0 end attr_reader :ok, :ng def check(boolean, explain="") begin if(boolean == true) puts "#{explain}: OK" @ok += 1 return true else puts "#{explai...
true
bb5a39b7c5afa811d221314afb1fceae6d4d367c
Ruby
FreeUKGen/MyopicVicar
/lib/tasks/set_piece_status_for_whole_piece_csvfiles.rake
UTF-8
1,522
2.609375
3
[ "Apache-2.0" ]
permissive
desc "Set Freecen2Piece status and FreecenCSVFile completes_piece." task set_piece_status_for_whole_piece_csvfiles: :environment do puts "Set Piece Status: Started." start_time = Time.now csvfile_whole = 0 csvfile_partial = 0 csvfile_whole_incorporated = 0 csvfile_records_updated = 0 piece_records_upd...
true
a24b561eaf3dde486a4b10254dd81f4c35ee36c7
Ruby
rhys117/LaunchSchoolCurriculum
/Backend/101/exercises/easy1/sum_of_digits.rb
UTF-8
171
3.296875
3
[]
no_license
def sum(num) num.to_s.split('').map(&:to_i).reduce(:+) end #ls num_to_s.chars.map(&:to_i).reduce(:+) puts sum(23) == 5 puts sum(496) == 19 puts sum(123_456_789) == 45
true
43498a3f09a44eda6a5df0e7fb6146a8a270bf3f
Ruby
snorkleboy/leetcode
/ruby/KHAN-TOPOLOGICALSORTlongestpath.rb
UTF-8
3,211
3.796875
4
[]
no_license
#Given an integer matrix, find the length of the longest increasing path. # #From each cell, you can either move to four directions: left, right, up or down. You may NOT #move diagonally or move outside of the boundary (i.e. wrap-around is not allowed). # #Example 1: # #nums = [ # [9,9,4], # [6,6,8], # [2,1,1] #] #R...
true
ced06704abe7a312f72997101887288c907b4192
Ruby
rogsmith/roo
/test/test_helper.rb
UTF-8
1,162
2.5625
3
[ "MIT" ]
permissive
require 'simplecov' # require deps require 'tmpdir' require 'fileutils' require 'minitest/autorun' require 'shoulda' require 'fileutils' require 'timeout' require 'logger' require 'date' require 'webmock/minitest' # require gem files require 'roo' TESTDIR = File.join(File.dirname(__FILE__), 'files') # very simple d...
true
c027e6b7684621ac2a5ad57d77c20c12fa7b5673
Ruby
superspike7/Tic-tac-toe-with-tests
/spec/game_spec.rb
UTF-8
370
2.515625
3
[]
no_license
require '../lib/game.rb' require '../lib/board.rb' require '../lib/player.rb' # trying to figure out how to test this game class and its methods. I don't fucking know what rspec functionalities to use. yet. describe Game do subject(:game) { described_class.new()} context '#play' do it 'starts the game loop'...
true
2ae16be8de538887ce811bf14bac671f2a251f9c
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/acronym/5d1e6f85776a4586b5c056c1baf9dc70.rb
UTF-8
364
3.171875
3
[]
no_license
class Acronym def self.abbreviate(str) @h = "" @ary = Array.new @ary2 = Array.new str.scan(/\w+/).each do |e| @ary << e end @ary.each do |e| @ary2 << e.scan(/(?=([A-Z][a-z])|(^[a-z])|(^[A-Z][^a-z]))/) end @ary2.flatten.each do |e| unless e == nil @h << e[0] ...
true
5aa2073e735e5d600003dd37ff2ece467b66c460
Ruby
alexgont1/Ruby25
/regex-1.rb
UTF-8
185
3.390625
3
[]
no_license
#to try use: rubular.com #Find a word s = 'The cat goes catatonic when you put in in catapult' f = /cat\b/ # \b = Any word boundary puts "String = '#{s}'" puts "Found: #{f.match(s)}"
true
045ebd7b3e4472c2ffb2e8ee0a64eb7a5d982b5f
Ruby
reenz/oystercard
/spec/oystercard_spec.rb
UTF-8
2,254
2.921875
3
[]
no_license
require "oystercard" describe Oystercard do let(:entry_station) {double :station} let(:exit_station) {double :station} let(:journey) {double :journey} subject(:subject) {described_class.new(journey)} it 'sets zero balance on new oystercard' do expect(subject.balance).to eq 0 end describe '#top_up...
true