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
a3b09fe814314ada6a00a6e2717fae8ca37673f8
Ruby
chooyan-eng/cardgame
/src/handler/join.rb
UTF-8
1,411
2.71875
3
[]
no_license
require 'etc' require 'model/player' require 'util/data_io' module Handler class Join def initialize(command_args) if !command_args.nil? && command_args.any? then @dryrun = command_args[0] != "y" @status = command_args[0] == "st" else @dryrun = true @status = false ...
true
f0a314032db7918be5f3f45d864bcac32a0e90c9
Ruby
taw/paradox-tools
/lib/multi_range.rb
UTF-8
2,600
3.078125
3
[ "MIT" ]
permissive
class MultiRange def initialize(*args) points = [] args.each do |arg| parse_arg(arg) do |s,e| raise ArgumentError, "MultiRange start #{s} > #{e}" if s and e and s > e next if s == e # Just fast skip, would get filtered later anyway points << [s ? 0 : -1, s, 1] points << ...
true
cc264416f213fa607d2b03e9a3cad26be7c48b68
Ruby
anvil-src/anvil-core
/lib/anvil/task/projects.rb
UTF-8
1,422
2.625
3
[ "MIT" ]
permissive
require 'git' module Anvil class Task module Projects def project_path(project) Anvil::Config.base_projects_path + "/#{project}" end def change_project(project) Dir.chdir(project_path(project)) rescue Errno::ENOENT log_project_does_not_exists project end ...
true
9baa9dfdf23bcaef9ddf9a38f45164f184f924b1
Ruby
lewcastles/RB101
/lesson_6/twenty_one.rb
UTF-8
7,315
3.421875
3
[]
no_license
GAME_VALUE = 21 DEALER_HITS_BELOW = 17 SCORE_TO_WIN_GAME = 3 MOVE_DELAY = 1.2 ROUND_DELAY = 3 CARD_VALUES = %w[2 3 4 5 6 7 8 9 J Q K A] CARD_SUITS = %w[D C H S] def joinor(arr, delim = ',', word = 'or') arr.map.with_index do |element, idx| case idx when 0 then element.to_s when arr.size - 1 then " #{word...
true
ce1671a92ea14e1b4761ccfd68f1edf66ca7342e
Ruby
beathyate/developer-exercise
/ruby/youtube/test.rb
UTF-8
580
2.53125
3
[]
no_license
require 'minitest/autorun' require_relative 'simple_youtube' class SimpleYoutubeTest < MiniTest::Test def setup @query = "google" end def test_returns_three_results_by_default results = SimpleYoutube.search @query assert_equal 3, results.size end def test_can_return_more_results max_result...
true
a2f28abafd02ca3a4f8311b53a9624ac52d81e07
Ruby
rizowski/Ruby-TexasHoldem
/Deck.rb
UTF-8
543
3.375
3
[]
no_license
require_relative 'card' class Deck attr_accessor :deck_cards def initialize @deck_cards = Array.new fill_deck end def fill_deck 13.times do |i| @deck_cards.push(Card.new("S", i)) end 13.times do |i| @deck_cards.push(Card.new("H", i)) end 13.times do |i| @deck_ca...
true
0293ce7501d567971aaa22be559a9e0322219fc0
Ruby
MisterDeejay/space-management-api
/spec/requests/stores_spec.rb
UTF-8
3,940
2.5625
3
[]
no_license
require 'rails_helper' RSpec.describe 'Stores API', type: :request do let!(:stores) { create_list(:store, 10) } let(:store_id) { stores.first.id } describe 'GET /stores' do context 'without query params' do before { get '/stores' } it 'returns stores' do expect(json).not_to be_empty ...
true
9ab31d9ae35cf86002cf8fff043eeb39e83d06fa
Ruby
ray0h/TOP_Ruby_Chess
/lib/pieces/king.rb
UTF-8
3,915
3.046875
3
[]
no_license
require_relative './piece' require './lib/modules/checks' # King piece class class King < Piece include Checks attr_reader :symbol def initialize(color, player_id) super(color, player_id) @symbol = @color == 'white' ? "\u2654" : "\u265A" @history = [] end def possible_moves(board) current_sq...
true
138ccd177d96b443fd1c4757f2348b81c8e9c337
Ruby
stixbunny/desafio-methods-ruby
/1.rb
UTF-8
32
2.84375
3
[]
no_license
def par(x) return x.even? end
true
ebf33181bbd23aca58265268620f8b1d4ff1fe97
Ruby
thomis/db_meta
/spec/db_meta_spec.rb
UTF-8
2,180
2.734375
3
[ "Apache-2.0" ]
permissive
require "spec_helper" meta_args = { username: "a_username", password: "a_password", instance: "an_instance" } class Example < DbMeta::Abstract register_type(:example) end RSpec.describe DbMeta do it "has a version number" do expect(DbMeta::VERSION).not_to be nil end it "validates allowed database ...
true
82f7fdbacb3d7fbd94bc90f2fe8d450936384497
Ruby
sunspot/sunspot
/sunspot_rails/lib/sunspot/rails/adapters.rb
UTF-8
2,525
2.578125
3
[ "MIT" ]
permissive
module Sunspot #:nodoc: module Rails #:nodoc: # # This module provides Sunspot Adapter implementations for ActiveRecord # models. # module Adapters class ActiveRecordInstanceAdapter < Sunspot::Adapters::InstanceAdapter # # Return the primary key for the adapted instance ...
true
2c22a83867b88ec525b594f4b81a8f783706a5ee
Ruby
HungryShark-t/rrr
/AirportSite/lib/flight.rb
UTF-8
773
3.25
3
[]
no_license
# frozen_string_literal: true # Class class Flight attr_reader :number, :where_from, :where_to, :time_from, :time_to, :date_from, :date_to, :type, :cost def initialize(number, where_from, where_to, time_from, time_to, date_from, date_to, type, cost) @number = number @where_from = where_from @where_to =...
true
17ff829f7e36fa40e952ad805488e5939261467d
Ruby
ugodiiorio/experiment
/code/builders/schemas/script/monitor_schema.rb
UTF-8
1,785
2.765625
3
[]
no_license
#!/usr/bin/ruby -w # simple.rb - simple MySQL script using Ruby MySQL module class BuildMonitorSchema def initialize(db_host, db_user, db_pwd, db_default_monitor) @db_host = db_host @db_user = db_user @db_pwd = db_pwd @db_default_monitor = db_default_monitor end def run() puts "\nLa attiv...
true
7b24c5e4b3ef82fe2b597671c1f87196807da1b6
Ruby
njpa/launchschool-rb101
/lesson_3/3_medium_1/question_10.rb
UTF-8
431
4.34375
4
[]
no_license
# Consider these two simple methods: def foo(param = "no") "yes" end def bar(param = "no") param == "no" ? "yes" : "no" end # What would be the return value of the following method invocation? bar(foo) # ANSWER # We'll start by evaluating the `foo` invocation that is sent in as argument. # This invocation eval...
true
67aba38289f9544eb2114c36b4b62e1adb8f0eba
Ruby
Salaizrm/square_array-onl01-seng-pt-052620
/square_array.rb
UTF-8
88
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def square_array(array) squared = [] array.each {|x| squared << x**2} squared end
true
5c8f40dee606dfed671150abfa5e500192a818b6
Ruby
yortz/UNIX-FU
/mini-unicorn.rb
UTF-8
4,255
2.578125
3
[]
no_license
require 'socket' require 'rack' require 'rack/builder' require 'http_tools' class MiniUnicorn NUM_WORKERS = 4 CHILD_PIDS = [] SIGNAL_QUEUE = [] SELF_PIPE_R, SELF_PIPE_W = IO.pipe def initialize(port=8080) if listener_fd = ENV['LISTENER_FD'] @listener = TCPServer.for_fd(listener_fd.to_i) else ...
true
1741e78d5d5f7f5f129eb3af940c2d30d9cc6d7d
Ruby
nealchawn/ruby-lofi
/rlfi/checkbox.rb
UTF-8
1,821
3.015625
3
[ "MIT" ]
permissive
class Checkbox attr_accessor :x, :y, :size, :tag, :phases def initialize x, y, size, checked = false, tag = nil, enabled = true, phases = 1, allow_uncheck = true @x = x @y = y @size = size @checking = false @checked = checked @tag = tag @enabled = enabled @hidden = false @phase...
true
2b5d317a6a362491a555c1a0b46b09f8c5d919b9
Ruby
IsaevPavel/AddressBook
/address_book_ui.rb
UTF-8
2,403
3.296875
3
[]
no_license
require 'active_record' require './lib/address' require './lib/contact' require './lib/email' require './lib/number' database_configuration = YAML::load(File.open('./db/config.yml')) development_configuration = database_configuration["development"] ActiveRecord::Base.establish_connection(development_configuration) de...
true
3032261c7a7429ed1cae040a1890c0a96ab9d9b9
Ruby
tlgakn/codewars
/29_split_springs.rb
UTF-8
1,804
4.59375
5
[]
no_license
=begin Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_'). =end # first time def solution(string) string_arr = string.chars paired_arr = st...
true
067e19346d1069ca611a161c25f176ffbffa5306
Ruby
kevinYCKim33/oo-student-scraper-v-000
/lib/scraper.rb
UTF-8
4,216
3.0625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'open-uri' require 'pry' require 'nokogiri' class Scraper def self.scrape_index_page(index_url) index_page = Nokogiri::HTML(open(index_url)) index_page.css("div.student-card").map do |profile| { :name => profile.css("h4.student-name").text, :location => profile.css("p.student-l...
true
e8c1d46e52b51942d384ac2dda070b931f18c1a5
Ruby
joedean/registration_old
/app/models/course_parser.rb
UTF-8
2,810
3.25
3
[]
no_license
class CourseParser < Parser def parse_model @model = Course.new parse_course line["Class"] parse_age line["Age"] parse_day_and_time line["Day and Time"] parse_studio line["Studio"] end def parse_course(course) @model.name = course.strip @model.category = parse_category @model.name ...
true
df2c3cfe056817d219129f1307be0e5de9863dec
Ruby
feigningfigure/WDI_NYC_Apr14_String
/w01/d02/INSTRUCTORS/drinking_age.rb
UTF-8
200
3.734375
4
[]
no_license
print "What is your age? " user_age = gets.chomp.to_i if user_age > 100 print "Your age is: " print user_age puts "" puts "You are way old!" else puts "Enjoy the rest of your youth!" end
true
23c34a749fed38239b8cb675d93034d431a138aa
Ruby
derwind/machine_learning
/font_analysis/uni2char.rb
UTF-8
157
2.609375
3
[]
no_license
#! /usr/bin/ruby -Ku while line = gets line.chomp! cid, uni = line.split(/\s+/).map { |n| n.to_i } char = [uni].pack("U*") print "#{uni} #{char}\n" end
true
6f9e15ea279e40bcf249c4311905e564a6d41eb0
Ruby
jackrobinrye/greatreads-rails
/db/seeds.rb
UTF-8
3,093
3.09375
3
[]
no_license
#users jack = User.create(name: "Jack", email: "jack@gmail.com", password: "password") sarah = User.create(name: "Sarah", email: "sarah@gmail.com", password: "password") #authors tolkein = Author.create( name: "J R R Tolkein", birthdate: Time.new(1892, 1, 3), bio: "John Ronald Reuel Tolkien was an English...
true
f02bb995389d5a47eb53a184ceefcbb273f1345d
Ruby
Jackmt9/programming-univbasics-nds-green-grocer-nyc-web-030920
/grocer.rb
UTF-8
2,628
3.5
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def find_item_by_name_in_collection(name, collection) # Implement me first! # # Consult README for inputs and outputs collection.each do |hash| if hash[:item] == name return hash end end return nil end def consolidate_cart(cart) # Consult README for inputs and outputs # #...
true
2040558f87a9d2f0cf48512c421a6b7f741e812a
Ruby
rwadstein/eventq
/eventq_aws/lib/eventq_aws/aws_queue_manager.rb
UTF-8
1,843
2.625
3
[ "MIT" ]
permissive
module EventQ module Amazon class QueueManager VISIBILITY_TIMEOUT = 'VisibilityTimeout'.freeze def initialize(options) if options[:client] == nil raise ':client (QueueClient) must be specified.'.freeze end @client = options[:client] end def get_queue(...
true
f72800041477634679025c099450030e1e3cdb06
Ruby
leuchtetgruen/webcam-server
/video.rb
UTF-8
1,544
2.59375
3
[]
no_license
require 'tempfile' SECONDS_PER_SEGMENT = 10 PLAYLIST_LENGTH = 6 KEEP_SEGMENTS = 100 def video_streaming_enabled? @@mode == :video end def video_available? @@segment_ctr > 1 end def keep_segments ret = (@@config['keep_minutes'].to_i * 60) / SECONDS_PER_SEGMENT (ret == 0) ? KEEP_SEGMENTS : ret end def start_vid...
true
cb63472d1258128c7db0d94e93589293b9be183f
Ruby
case-iot/model_evaluation
/spec/spec_helper.rb
UTF-8
1,039
2.546875
3
[]
no_license
require 'case_model' require 'webmock/rspec' RSpec.configure do |config| config.expect_with :rspec do |c| c.syntax = :expect end end class UseCaseLoader def read_def(repo, path) RDF::N3::Reader.open(path) do |reader| reader.each_statement do |statement| # ruby-rdf created very long names f...
true
618092afc5479a0da2288741fd1bb424ccdb136a
Ruby
cinexin/MiniShoppingList
/test/examples/spec/bacon_spec.rb
UTF-8
258
2.625
3
[]
no_license
require_relative 'lib/bacon' describe Bacon do # one specification it "is edible" do expect(Bacon.new.edible?).to be_true end # another specification it "expired!" do bacon = Bacon.new bacon.expired! expect(bacon).to_not be_edible end end
true
b14266c25f0f0d3c384184a77996ad96bee0fffb
Ruby
rshakhb10/alternative-fuel-stations-locator
/lib/data_request.rb
UTF-8
824
3.296875
3
[]
no_license
# Class that wraps up a data request to the API # Currently support JSON format # Requires an API key to access the data # Also includes parameters of request. # e.g., return only fuel stations in a particular state. class DataRequest attr_accessor :url, :api_key, :params, :output_format def initialize url, api_...
true
52ec1c83195a242c7e74ce1a5ea827003511f400
Ruby
Gettekt/APT
/app/models/searchresult.rb
UTF-8
2,075
3.21875
3
[]
no_license
class SearchResult @@results = [] @array = [] attr_reader :name, :price, :rating, :address, :open attr_accessor :num def initialize(place) @num = @@results.length + 1 @name = place["name"] if @name == nil @name = "?" end @price = place["price_level"] if @price == nil @price = "?" end @rati...
true
accbe3270e2fe3101d972d2d192e27a8e80ed6f9
Ruby
dkandalov/katas
/ruby/sort/insertsort/insert_sort_spec.rb
UTF-8
751
3.53125
4
[ "Unlicense" ]
permissive
require "rspec" describe "Insert sort" do it "sorts things" do sorted([]).should == [] sorted([1]).should == [1] [1, 2, 3].permutation.each { |it| sorted(it).should == [1, 2, 3] } [1, 2, 3, 4].permutation.each { |it| sorted(it).should == [1, 2, 3, 4] } end def sorted(list) return list if lis...
true
cbf5b7fc8bb608aa10e803de4103fda037b240b4
Ruby
btiddle/cd-ror-01ruby-01learn
/asgn-01-tryruby-C-misch.rb
UTF-8
3,268
3.53125
4
[]
no_license
# Fiels and direcories # Anything listed after a method is considered an attachment. print Dir.entries "/" puts # => [".", "..", ".DocumentRevisions-V100", ".file", ".fseventsd", ".PKInstallSandboxManager", ".Spotlight-V100", ".Trashes", ".vol", "Applications", "backup", "balsmiq-demo-file.bmml", "bin", "cores", "dev"...
true
50e2d8d3ee80bb2cf24e10eb8e8c1ad5cf2147c9
Ruby
prynt/inscriber
/spec/spec_helpers/test_database.rb
UTF-8
1,854
2.578125
3
[]
no_license
require 'sequel' require 'rspec' require 'spec_helpers/config_helpers' module Inscriber # The TestDatabase is responsible for creating a SQLite database with tables and columns for testing. # It is dumped after every example. To create a database, use the following format: # # Inscriber::TestDatabase.setup do ...
true
92b5d3a55286411120870f1ecf88bc204dfbaee8
Ruby
crapooze/epo
/example/models.rb
UTF-8
662
2.703125
3
[ "MIT" ]
permissive
require 'welo' class Item include Welo::Resource perspective :default, [:name, :price] identify :default, [:uuid] identify :flat_db, [:uuid] attr_reader :name, :price, :uuid def initialize(name, price=0, uuid=nil) @name = name @price = price @uuid = uuid || rand(65535) end end class Person ...
true
b3b0ef5275f3efb0e532107f40d1d7037a7718ce
Ruby
mackied0g/sinatra-basic-routes-lab-dumbo-web-071519
/app.rb
UTF-8
352
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative 'config/environment' class App < Sinatra::Base get "/" do "Hello, World!" end get "/name" do "My name is Mackenzie." end get "/hometown" do "My hometown is Northfield, Minnesota." end get "/favorite-song" do "My favorite song is Butterfly...
true
5c92ec987852655c600b6ef4a40ba992b64c0989
Ruby
DanielMatney/activerecord-validations-lab-online-web-pt-090919
/app/models/post.rb
UTF-8
542
2.53125
3
[]
no_license
class Post < ActiveRecord::Base include ActiveModel::Validations validates :title, presence: true validates :content, length: { minimum: 250 } validates :summary, length: { maximum: 250 } validates :category, inclusion: { in: %w(Fiction Non-Fiction), message: "%{value} must be Fiction or Non-Fiction" } v...
true
84e3ff7fe0e7c2e5172c0cb6321b0ea41ec62bfc
Ruby
stovermc/practice-repo
/cracking_the_coding_interview/rotate_array/lib/rotate_array.rb
UTF-8
876
4.5
4
[]
no_license
# Given an image represented by an NxN matrix, where each pixel in the image is # 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in # place? # [[1, 2, 3], # [4, 5, 6], # [7, 8, 9]] # [[7, 4, 1], # [8, 5, 2], # [9, 6, 3]] # [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # [[7, 4, 1], [8, 5, 2], [9, ...
true
0b546b5f3b2e5edb8255577567cc380491c438f8
Ruby
amohamedali/routes_coverage
/lib/routes_coverage/formatters/full_text.rb
UTF-8
3,342
2.5625
3
[ "MIT" ]
permissive
module RoutesCoverage module Formatters class FullText < SummaryText class RouteFormatter attr_reader :buffer def initialize result=nil, _settings=nil, output_hits=false @buffer = [] @result = result @output_hits = output_hits @output_prefix = false ...
true
cf4df8ab7a802718ce1ff21d7d5824aa45c84b7f
Ruby
cbarcroft/kitchenomicon-rr
/app/helpers/application_helper.rb
UTF-8
917
3.265625
3
[]
no_license
module ApplicationHelper def mixed_number_to_rational(amount) rational_to_return = 0 amount.split(" ").each { |string| if is_rational?(string) # Number? if string.include?("/") # Fraction? rational_to_return += Rational(string) elsif string.to_i == string.to_f # Whole number? ...
true
625ff005d46f223b7b75acb49ea5c7d598268020
Ruby
lemanchester/routes-api
/app/validators/map_route_points_validator.rb
UTF-8
407
2.71875
3
[]
no_license
class MapRoutePointsValidator < Struct.new(:map) def validate!(origin, destination) raise StandardError.new("This map does not contain #{origin} as a route") unless route_points.include?(origin) raise StandardError.new("This map does not contain #{destination} as a route") unless route_points.include?(desti...
true
7876fdc863b4815e2fd794e7e6c8b20914b79f5f
Ruby
Rstinkho/ruby-oop-cards
/test.rb
UTF-8
1,698
4.1875
4
[]
no_license
require 'byebug' # playerOneScore = 0 # playerTwoScore = 0 # put = 1.times.map{ Random.rand(52) } # puts put # if (put[0] >= put[1]) # playerOneScore += 1 # puts "Player One + 1" # elsif (put[0] <= put[1]) # playerTwoScore += 1 # puts "Player Two + 1" # end # puts "SCORE: Player1 = #{playerOneScor...
true
929d1a2998ec07fc1c277699f5fe72c920ca713f
Ruby
sasdevs/ruby-course
/exercises/x.rb
UTF-8
85
2.9375
3
[]
no_license
t = Thread.new do puts "first" sleep 1 puts "second" end puts "outside" t.join
true
683c735835ed34655e3e577486073a529fb18b60
Ruby
edhowland/viper
/lib/runtime/regex_hash.rb
UTF-8
459
3.5
4
[ "MIT" ]
permissive
# regex_hash - class RegexHash - data structor to use regex'es as keys # When stored, the key is a Regexp # and retrieved it is some potetially matching string # rubocop:disable Style/DoubleNegation class RegexHash def initialize @storage = [] end attr_reader :storage def []=(key, value) @storage <<...
true
27ae8dc1782d27a5d5e37beb12a64f47fc4d88ce
Ruby
kaji-hiro/AtCoder_beginner_contest
/ABC182/B-Almost_GCD.rb
UTF-8
249
3.171875
3
[]
no_license
require 'prime' n = gets.to_i k = gets.split.map(&:to_i) ans = 0 max_count = 0 Prime.take(168).each do |p| count = 0 k.each do |k| count += 1 if k % p == 0 end if max_count < count ans = p max_count = count end end puts ans
true
3552f0df05b5192b40fe8461dc450f38fb37b4ab
Ruby
ArturTTN/xrates
/lib/xrates/currency/arithmetic.rb
UTF-8
669
2.953125
3
[ "MIT" ]
permissive
module Xrates class Currency module Arithmetic def -(curr); calculate('-', curr) end def +(curr); calculate('+', curr) end def /(curr); calculate('/', curr) end def *(curr); calculate('*', curr) end def calculate(math_method, currency) raise TypeError, "Should be Xrates...
true
e68c945486e83531ed623cb886ac06843a80d118
Ruby
OpenLinkSoftware/Documentation
/virtdoc2md/virtdoc2md.rb
UTF-8
7,459
3.15625
3
[]
no_license
#!/usr/bin/env ruby require 'fileutils' require 'nokogiri' # # Converts portions of the Virtuoso DocBook documentation to Markdown # using pandoc. # class VirtDocConv attr_accessor :doc attr_reader :output_dir # Root folder for holding the converted book attr_reader :virt_docs_root_dir # Root folder holding th...
true
078fa2a18af20f2ebaa1f3e2f6a2f3f0614b3dce
Ruby
Ksy1993/Ruby
/regexp/metachars.rb
UTF-8
198
2.875
3
[]
no_license
match1 = /Hello\, welcome to our site\./.match('Does Hello, welcome to our site.') puts match1 m2 = /2\*2\+3\-1=\?/.match('Does 2*2+3-1=?') puts m2 m2 = /2*2+3-1=?/.match('Does 2*2+3-1=?') puts m2
true
d5b46f51ed47e6b62daae595a58f2291a307c909
Ruby
Efseykho/6502-emulator
/6502-aslink/tokenizer.rb
UTF-8
3,573
3.71875
4
[]
no_license
#a simple tokenizer interface class Tokenizer attr_accessor :buffer #buffer of tokens attr_accessor :curr_line #current line we're on attr_accessor :temp def initialize( filename ) @buffer = Array.new File.open(filename).each { |line| @buffer.push(line) } #split on white space ...
true
f9bd4f03fd9ef9e689469bbb2ca6110d7508ff4c
Ruby
tigershen23/reed
/app/models/domain/book_factory.rb
UTF-8
252
2.65625
3
[]
no_license
module Domain # Factories instantiate domain objects class BookFactory def create(record) Domain::Book.new(record) end def create_for(record, reader) record.reader = reader Domain::Book.new(record) end end end
true
f13de2169b9e00e6cbfea7175b5115de54016e3f
Ruby
cmaher92/launch_school
/coursework/rb100/small_problems/easy_9/double_double.rb
UTF-8
1,743
4.53125
5
[]
no_license
=begin A double number is a number with an even number of digits whose left-side digits are exactly the same as its right-side digits. For example, 44, 3333, 103103, 7676 are all double numbers. 444, 334433, and 107 are not. Write a method that returns 2 times the number provided as an argument, unless the argument is...
true
6d08bd4364ce86e2338a364b76732d36f8be3b0f
Ruby
lukasgor/back-end-school
/db/seeds.rb
UTF-8
2,058
2.609375
3
[]
no_license
require 'ffaker' # Admin account User.create(first_name: "Adam", last_name: "Nowak", email: "admin@example.com", password: "password", password_confirmation: "password", account_type: "admin") # Teacher account User.create(first_name: "Jan", last_name: "Kowalski", email: "teacher@...
true
fa410aa9e6f4946556ec8bc5f4a489733409ef4f
Ruby
UbuntuEvangelist/therubyracer
/vendor/bundle/ruby/2.5.0/gems/rubytree-1.0.0/examples/example_basic.rb
UTF-8
2,032
3.40625
3
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#!/usr/bin/env ruby # # example_basic.rb:: Basic usage of the tree library. # # Author: Anupam Sengupta # Time-stamp: <2015-12-31 22:17:30 anupam> # Copyright (C) 2013, 2015 Anupam Sengupta <anupamsg@gmail.com> # # The following example implements this tree structure: # # +------------+ # ...
true
bda37a58314daa916850dcfd941047371850e1de
Ruby
christinetran825/ttt-with-ai-project-v-000
/lib/board.rb
UTF-8
1,548
4.3125
4
[]
no_license
require 'pry' class Board attr_accessor :cells #has an attribute to store the cells of the board def initialize reset! end def reset! #can reset the state of the cells in the board, @cells = Array.new(9," ") #sets the cells of the board to a 9 element array of " " end def display #prints the bo...
true
a3c4b166a4c649160028236ecdf872a3f6c81573
Ruby
matthewrpacker/api_curious
/app/models/user_info.rb
UTF-8
430
2.9375
3
[]
no_license
class UserInfo attr_reader :name, :followers, :following, :bio, :member_since, :location def initialize(hash) @name = hash['name'] @followers = hash['followers'] @following = hash['following'] @bio = hash['bio'] @member_since = hash['created_at'] @location = hash['location'] end def me...
true
90a1e6fec1d718d27bdd81d055590e28db4038ca
Ruby
bigfix/erector
/spec/erector/needs_spec.rb
UTF-8
3,516
3.015625
3
[ "MIT" ]
permissive
require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper") describe Erector::Needs do it "doesn't complain if there aren't any needs declared" do class Thing1 < Erector::Widget end Thing1.new end it "allows you to say that you don't want any parameters" do class Thing2 < Erector::Widge...
true
17e7e06cc1cc8e80e4b68e800811a547099e427b
Ruby
towerhe/hightouch
/lib/hightouch/blog.rb
UTF-8
1,433
2.640625
3
[]
no_license
module Hightouch class Blog include Virtus attribute :archive_cache, Hash, default: {} attribute :category_cache, Hash, default: {} attribute :tag_cache, Hash, default: {} attribute :blog_posting_cache, Hash, default: {} attr_reader :app def initialize(app = nil) @app = app en...
true
9140f32cbc1d0a82ee555ed348d5ff6d61ace547
Ruby
ben-harvey/Small-problems-Ruby
/procedural/easy8/2.rb
UTF-8
614
3.53125
4
[]
no_license
# input: four strings representing a noun, verb, adjective and # adverb # output: a new string inserting input strings into a story # rules: input is provided by user # data structures: string # logic: gets.chomp and store in string # string inpterpolation # def madlibs() parts_of_speech = %w(noun verb a...
true
9a3e13a1739a3b9067168f4f5cc79cd346a44cfa
Ruby
lucidenis/redis-copy
/lib/redis-copy/key-emitter.rb
UTF-8
2,936
2.640625
3
[ "MIT" ]
permissive
# encoding: utf-8 module RedisCopy # A Key emitter emits keys. # This is built to be an abstraction on top of # redis.keys('*') (implemented by RedisCopy::KeyEmitter::Default), # but should allow smarter implementations to be built that can handle # billion-key dbs without blocking on IO. module KeyEmitter...
true
01846f8ff139673e7849a49355dec42561b49fd2
Ruby
michalasobczak/q
/01/obsluga.rb
UTF-8
249
3.078125
3
[]
no_license
# 1 # Don't do this begin do_something() rescue Exception => e ... end # 2 begin do_something() rescue => e # This is the same as rescuing StandardError end # 3 begin do_something() rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED => e end
true
0cf0fd1451353862246d19032865dc1173c8d997
Ruby
trbradley/stu-test
/Exercise 2/spec/vehicle_spec.rb
UTF-8
617
2.75
3
[]
no_license
require 'vehicle' describe Vehicle do describe ".move" do let(:driver) { "John Doe" } subject { -> { Vehicle.move(vehicle) } } context "when vehicle is a bicycle" do let(:vehicle) { Bicycle.new(driver) } it { is_expected.to change(vehicle, :distance).by(2) } end context "when vehi...
true
095748ffb340996ab47fc9d0e7d9c9cc8dca7e4f
Ruby
hashmaster3k/backend_module_0_capstone
/day_6/exercises/my_car.rb
UTF-8
943
4
4
[]
no_license
class MyCar attr_accessor :color attr_reader :year def initialize(y, mk, md, c) @year = y @make = mk @model = md @color = c @current_speed = 0 puts "You sit into your #{@color} #{@make} #{@model}.\n\n" end def current_speed puts "Your current speed is #{@current_speed} MPH." e...
true
1a9d150a614953d142bf05334d3cf627efffaa30
Ruby
Feza786/learn-to-program
/ex9.5.rb
UTF-8
1,053
4.125
4
[]
no_license
#improved ask method def ask question puts question answer = gets.chomp.downcase while answer != 'yes' && answer != 'no' puts 'Please answer "yes" or "no".' puts question answer = gets.chomp.downcase end if answer == 'yes' return true else return false end end puts 'Hello, and thank you for ...' puts ask 'Do you...
true
a00e08484305557b0b4077b9008b8134f8263bfd
Ruby
r0tiart/sinatra-mvc-lab-v-000
/models/piglatinizer.rb
UTF-8
938
4
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class PigLatinizer def piglatinize(word) word_array = word.split("") first_letter = word_array[0] second_letter = word_array[1] third_letter = word_array[2] new_word = "" if vowel?(first_letter.downcase) new_word = word + "way" elsif vowel?(second_letter.downcase) && word.size > 1 o...
true
ee2e49ec3fdd6e0ca3d558f2d3a68d537c5cbd62
Ruby
lkfken/npi_registry
/lib/report.rb
UTF-8
1,155
2.71875
3
[]
no_license
class Report attr_reader :logger def initialize(providers:, taxonomy_data:, primary_only: false, logger: Logger.new($stderr)) @providers = providers @taxonomy_data = taxonomy_data @primary_only = primary_only @logger = logger end def rows @providers.inject(Array.new) do |a, provider| ...
true
b4e27c055628b5e2af2957bdb18b3cfc5d928d36
Ruby
IFilonov/Ruby_basics
/10_lesson/train.rb
UTF-8
2,304
3.328125
3
[]
no_license
require_relative 'manufacturer' require_relative 'instance_counter' require_relative 'validation' require_relative 'accessors' class Train include Manufacturer include InstanceCounter include Validation extend Accessors NUMBER_REGEXP = /^[a-zA-Z0-9]{3}-?[a-zA-Z0-9]{2}$/ attr_reader :wagons attr_accesor_...
true
46fe3a6a3df1c7a337539dc9b5a8a31ac7da1ba0
Ruby
willian/validators
/lib/validators/validates_datetime.rb
UTF-8
2,755
2.609375
3
[ "MIT" ]
permissive
module ActiveModel module Validations class DatetimeValidator < EachValidator def date?(value) value.kind_of?(Date) || value.kind_of?(Time) end def validate_each(record, attribute, value) unless date?(value) record.errors.add(attribute, :invalid_date, :mess...
true
d3eb39b61ed7f822a05865c2064575acbf13d62c
Ruby
wegowise/polymorpheus
/lib/polymorpheus/mysql_adapter.rb
UTF-8
6,965
2.625
3
[ "MIT" ]
permissive
module Polymorpheus module ConnectionAdapters module MysqlAdapter INSERT = 'INSERT' UPDATE = 'UPDATE' # See the README for more information about the use of these methods. # # table: a string equal to the name of the db table # # columns: a hash, with keys equal to ...
true
a352e4c491bab34bc21701e2bccec01e9e9b9c9b
Ruby
BFriedland/ruby-web-test-examples
/utils.rb
UTF-8
2,700
3.078125
3
[ "MIT" ]
permissive
require 'inifile' module SeleniumUtilities # Reference for mixins, including reasoning on include vs. extend: # http://stackoverflow.com/a/549273 # Example use: # record_video_toggle = # find_subelements_with_text("tag_name", "label", "Record Video") def find_subelements_with_text(finda...
true
218846dab09d0e32b9a0d09b570d2efba2c81deb
Ruby
shraker13/LS_IntroBook_Ruby
/chptr10Exercises/exercise8.rb
UTF-8
150
2.953125
3
[]
no_license
#Exercise 10.8 measurements = { :weight => '180 pounds', :height => '6 feet'} puts measurements desc = { color: 'red', shape: 'triangle' } puts desc
true
41677e4a88458fd9c2608ecb25014f277ea81515
Ruby
steven989/CRM_commandline
/classnotes/rolodex.rb
UTF-8
493
3.078125
3
[]
no_license
class Rolodex def initialize @contacts = [] end def create_contact(name) contact = Contact.new contact.name = name @contacts << contact end def view_contacts @contacts.each {|contact| puts contact; puts "------------"} end def remove_contact(id) @contacts.delete_if {|con...
true
567d8054caacc75339e2df058c6c4769c67878ac
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/src/3294.rb
UTF-8
165
2.859375
3
[]
no_license
def compute(lhs, rhs) throw ArgumentError.new("Arguments of inequal length.") if lhs.length != rhs.length lhs.length.times.count {|i| lhs[i] != rhs[i]} end
true
8d2e6976fac7ff13c6f30c08cf58f54cffa01de4
Ruby
caridadrivera/sinatra-dynamic-routes-lab-nyc-web-career-031119
/app.rb
UTF-8
594
2.96875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative 'config/environment' class App < Sinatra::Base get '/reversename/:name' do @reversed_name = params[:name].reverse "#{@reversed_name}" end get '/square/:number' do @squared_num = params[:number].to_i * params[:number].to_i "#{@squared_num}" end get '/say/:word1/:word2/:word3/:word4/:word5' ...
true
167554e4450ed844a11342d056550af44517a4ef
Ruby
Sindarus/tsumegomaker
/app/controllers/test_minimax.rb
UTF-8
263
2.671875
3
[]
no_license
load("board.rb") load("minimax.rb") b = Board.new(2,3,[false,false,false,false]) b.load_board("111\n000") m = Minimax.new(b,8) max_score, win_nodes = m.launch_minimax puts "Max score is : #{max_score}" win_nodes.each do |wn| m.show_path_to wn end m.show_tree
true
12d40344d01a6aa4fb8b6060b2752765a7f2820f
Ruby
andrelaszlo/photogun
/lib/email_whitelist.rb
UTF-8
513
2.796875
3
[]
no_license
module EmailWhitelist def self.whitelisted?(email, whitelist: nil) if whitelist.nil? whitelist = Rails.application.secrets.email_whitelist || '' end if whitelist.empty? puts "EMAIL_WHITELIST is empty" return false end patterns = self.parse_whitelist whitelist !!patte...
true
0cc129b361f432d8e75f2bcc00628a8b340206a4
Ruby
jwhitis/AudioFile
/test/test_colorize.rb
UTF-8
269
2.546875
3
[ "MIT" ]
permissive
require "test_helper" include Colorize class ColorizeUnitTest < Test::Unit::TestCase def test_01_colorize_returns_color_coded_text text = "Some green text." expected = "\e[32mSome green text.\e[0m" assert_equal(expected, text.colorize(GREEN)) end end
true
96eaed28cde4c0d3b9c3dd60b89eb43d8a663f31
Ruby
gabdelaun/dotfiles
/car.rb
UTF-8
614
3.578125
4
[]
no_license
class car # attr_reader : color # getters # def color # return @color # end # attr_writer : color #setters # def color=(new_color) # @color = new_color # end attr_accessor: color # = Attr_reader & attr_writer def initialize(color) @engine_started = false @color = color @kms = 0 en...
true
935c93e838700e79ae13939fcde41d366b894dab
Ruby
shirwet/programming-univbasics-4-intro-to-hashes-lab-dc-web-030920
/intro_to_ruby_hashes_lab.rb
UTF-8
1,006
3.609375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def new_hash # return an empty hash new_hash = {} end def my_hash # return a valid hash with any key/value pair of your choice my_hash = { name: "Shirwet", age: 31 } end def pioneer # return a hash with a key of :name and a corresponding value of 'Grace Hopper' hash = { :name => "Grace Hopper" ...
true
7b7efc6dde822808487c8f6ecc8cca6b96b2b778
Ruby
BogdanGermanchuk/rubytut
/lesson7/ex4.rb
UTF-8
1,164
4.125
4
[]
no_license
array = [] index = 1 while index <= 9 do array << index index += 1 end puts 'Исходный массив: ' puts array.to_s puts 'Новый массив, полученный из исходного массива: ' puts "#{array.unshift(9)}\n\n" # encoding: utf-8 # Записываем массив в переменную numbers и выводим его на экран numbers = [1, 2, 3, 4, 5, ...
true
433080b45d5457e03c5d186a95f60b1de05275c4
Ruby
pivotalexperimental/bookmark_fu
/lib/bookmark_fu/configuration.rb
UTF-8
1,016
2.703125
3
[ "MIT" ]
permissive
module BookmarkFu class << self def services Configuration.services end end class Configuration class << self def instance @instance ||= new end attr_writer :instance def all_services @all_services ||= [] end def to_yaml all_services...
true
296ee22cbca5edb790bdcb2609ee48baa518df47
Ruby
viperior/cloud-golem
/start-instance.rb
UTF-8
1,649
2.734375
3
[]
no_license
puts "Cloud Golem EC2 Instance Start Script Started..." require 'aws-sdk-ec2' # v2: require 'aws-sdk' require_relative 'ec2-credentials.rb' client = Aws::EC2::Client.new( access_key_id: cloud_golem_ec2_access_key_id, secret_access_key: cloud_golem_ec2_secret_access_key, region: 'us-east-1' ) ec2 = Aws::EC2::R...
true
621fc9d89b32ed28ab5df40931fd67a88741b495
Ruby
mtcameron5/RB101_Programming_Foundations_Exercises
/medium_2/exercise_1.rb
UTF-8
2,611
3.546875
4
[]
no_license
# Write a program that reads the content of a text file # and then prints the longest sentence in the file based # on number of words. Sentences may end with periods (.), # exclamation points (!), or question marks (?). Any # sequence of characters that are not spaces or # sentence-ending characters should be treated a...
true
50760f07f096ba0d32dea984091ed556add6beb5
Ruby
codeloopy/appacademy
/Soft_eng_foundations/RSPEC/rspec_exercise_1/lib/part_1.rb
UTF-8
391
3.96875
4
[]
no_license
def average(num1, num2) (num1 + num2) / 2.0 end def average_array(arr) arr_sum = arr.inject { |a,n| a + n } arr_sum / (arr.length * 1.0) end def repeat(str, num) str * num end def yell(str) "#{str.upcase}!" end def alternating_case(str) words = str.upcase.split(' ') i = 1 while i < words.length words...
true
5eac4d17b036653096ce57e32a26019f154b25f1
Ruby
mattijsvandruenen/smite_ruby
/lib/smite/full_match.rb
UTF-8
1,001
2.78125
3
[]
no_license
module Smite class FullMatch < Smite::Object attr_accessor :queue, :match def initialize(data) data = { 'competitors' => data.map { |k, v| Smite::Competitor.new(k) } } super @queue = competitors[0].queue @match = competitors[0].match end def teams { team1: team1, team2:...
true
30d53e3711892be14b2a2bb741ff2f731a01af01
Ruby
T-o-s-s-h-y/Learning
/Ruby/exercises/app/mission_c_093.rb
UTF-8
1,008
3.828125
4
[]
no_license
=begin ボブとアリスがテストの点数で勝負をし、どちらが勝ったか、あるいは引き分けたかを求める。 ただし、テストの点数をそのまま比較するのではなく、テストの点数の各桁の数を足した数の一の位で勝負する。 例えば、85点であれば 8 + 5 = 13、13の一の位である3が勝負する際の点となる。 =end class MissionC093 def run # 各人のスコア(ボブの点数 アリスの点数) scores = $stdin.gets.split # それぞれの最終的に使用する点 bob_score = 0 alice_score = 0 # 各桁の数を足す ...
true
0b9eb4b6586b5ff530d3236e05fa675419cebec6
Ruby
EJWebber/yield-and-blocks-london-web-060319
/lib/hello.rb
UTF-8
170
3.328125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def hello_t(array) if block_given? i=0 while i<array.length yield (array[i]) i+=1 end array else puts "Hey! No block was given!" end end # call your method here!
true
2b06e1572ec03e513112282f1e124de622506f11
Ruby
gwhn/clean_cv
/app/controllers/skills_controller.rb
UTF-8
3,961
2.578125
3
[]
no_license
class SkillsController < ApplicationController before_filter :load_person before_filter :load_skill, :only => [:show, :edit, :update, :delete, :destroy, :move_top, :move_up, :move_down, :move_bottom] before_filter :new_skill, :only => [:new, :create, :index] filter_access_...
true
dbf585dd835e828cbc01f47e48ba98b02dfce39c
Ruby
usarekoski/mastermind
/codemaker.rb
UTF-8
1,479
3.25
3
[]
no_license
class AiCodemaker attr_reader :code def initialize @code = (0..5).to_a.shuffle.take(4) end def give_feedback(guess_numbers) col_and_pos = guess_numbers .zip(@code) .map { |x| x[1] == x[0] } guess_left = feedback_help(guess_numbers, col_and_pos) code_left = ...
true
f19ab6b813e7c23479da21f65271c6091f805b8c
Ruby
brabemi/ctu-fit-mi-rub16
/hw2/grid.rb
UTF-8
4,161
3.625
4
[]
no_license
#!/usr/bin/env ruby # Contains sudoku game board class Grid include Enumerable attr_reader :dimension, :block_width # Create Sudoku game grid of given dimension def initialize(dimension) @dimension = dimension @block_width = Math.sqrt(@dimension).to_i @grid = [] @dimension.times do row = ...
true
a651f2c9b4e49650c8219ae6cc65611f05ced7ab
Ruby
hgeorgii/hangman
/lib/hangman_methods.rb
UTF-8
3,185
3.625
4
[]
no_license
module HangmanMethods def select_difficulty puts 'Select difficulty:' puts 'easy ----- 7 guesses' puts 'medium ----- 6 guesses' puts 'hard ----- 5 guesses' input = gets.chomp.downcase message = "You selected #{input}." case input when 'easy' puts message puts 7 ...
true
0058dfeb8da186cefae2b57d096edd740857d964
Ruby
nix12/chess
/spec/board/setup_display_spec.rb
UTF-8
5,548
2.71875
3
[]
no_license
require 'board/setup_display' RSpec.describe SetupDisplay do describe 'setup of display with pieces' do let(:gameboard) { Board.new } let(:setup) { SetupDisplay.new(gameboard) } before { gameboard.build_display } describe '#setup_display' do it "calls gameboard's build_board method" do ...
true
4a28969c8088c0fea048bc0cb832d096601d44af
Ruby
MOSapeizer/SOS-Cache-Server
/lib/tasks/SOS/lib/employees/sos/time.rb
UTF-8
1,056
2.921875
3
[]
no_license
require_relative '../gml/gmlTime.rb' module SOSHelper class SOSTime def initialize(time) @time = checkTimeType time end def timeInstant(time) time.xpath(".//gml:TimeInstant") end def timePeriod(time) time.xpath(".//gml:TimePeriod") end def range(beginTime=beginPosition, endTime=endPosition) ...
true
500a9c7cecf08f2e1aff7e8d46937dc353eee49c
Ruby
Kaiwee/Kwly_Bitly_Clone
/app/models/url.rb
UTF-8
396
2.53125
3
[ "MIT" ]
permissive
class Url < ActiveRecord::Base # This is Sinatra! Remember to create a migration! before_create :shorten, :counter validates :long_url, presence: true, uniqueness: true, format: { with: /https?:\/\/[\S]+/} def shorten range = [*'0'..'9',*'A'..'Z',*'a'..'z'] @short_url = (0...7).map{ range.sample }.join sel...
true
c9bf93da7ca98cacf792a50a3a73bbf82c101bc7
Ruby
ivaverka/Learn-Ruby-the-Hard-Way
/arrays.rb
UTF-8
371
4.15625
4
[]
no_license
#Ex 1 =begin array = [1, 3, 5, 7, 9, 11] number = 3 =end =begin array.each do |x| if x == number puts "#{number} is in the array." end end =end # OR =begin if array.include?(number) puts "#{number} is in the array." end =end # Ex3 arr = [["test", "hello", "world"],["example", "mem"]] =begin arr.flatten word = ...
true
e3382a2e3596d71fcd7870562802a83ab64808d2
Ruby
chrisd1dev/my-first-repository
/TeaLeaf_Exercises/Hashes/hashes_ex7.rb
UTF-8
157
2.671875
3
[]
no_license
#Hashes exercise 7 x = "hi there" my_hash = {x: "some value"} my_hash2 = {x => "some value"} puts x puts my_hash puts my_hash2
true
502e0e40c3b8467bb4d0041b5ee32b7c164d3b65
Ruby
nettan20/qae
/app/models/reports/admin_report_builder.rb
UTF-8
2,735
2.65625
3
[ "MIT" ]
permissive
require "csv" class Reports::AdminReportBuilder MAPPING = [ { label: "URN", method: :urn }, { label: "ApplicantName" }, { label: "RegisteredUserId", method: :user_id }, { label: "RegisteredUserTitle", method: :title }, { label: "Regi...
true
d95bd26db05cf8a3f7b0fa63300518f525b4fcd3
Ruby
eremeyev/thinknetika-course
/ruby_basics/task_3/lib/train.rb
UTF-8
3,116
3.125
3
[]
no_license
require_relative 'base' class Train < Base attr_accessor :speed, :route, :current_station, :wagons, :number, :type attr_writer :current_position validates :number, presence: true, format: /[\w\d]{3}[-|]?[\w]{2}/i, uniqueness: true validates :type, presence: true, inclusion: Types::ALL def initial...
true
ce55c213b7a8915834ac14a56a4859b7e215dae5
Ruby
preetness/phase-0-tracks
/ruby/gps2_2.rb
UTF-8
1,548
4.46875
4
[]
no_license
# Method to create a list # input: string of items separated by spaces (example: "carrots apples cereal pizza") # steps: Take some words, and convert it into a grocery shopping list. # [fill in any steps here] # set default quantity to one # print the list to the console [can you use one of your other methods her...
true
d27f93e35dd947f606568824327660e446d13e0c
Ruby
kirel/armchair
/lib/armchair.rb
UTF-8
2,332
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'rest_client' require 'json' # An Armchair is <em>very</em> a minimal interface to a CouchDB database. It is Enumarable. class Armchair include Enumerable # Pass in the database url and optionally # a <tt>batch_size</tt> which is used when iterating over the armchair in Armchair#each # couch = Armc...
true
02c4150724139a398d986d16239e43b5ce54ce2e
Ruby
firetimli/Viking
/rubybasic/Fibonacci.rb
UTF-8
288
3.59375
4
[]
no_license
def fibonacci range value1 = 2 value2 = 3 sum = 0 while value2 < range value1 = value1 + value2 value2 = value2 + value1 if value1%2 == 0 sum = sum + value1 elsif value2%2 == 0 sum = sum + value2 end end sum+2 end puts"#{fibonacci 4000000}"
true