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
badfa28ec3c66f7a11fa3038bda9f93fa7dcc67e
Ruby
threeifbywhiskey/houston
/rb/39.rb
UTF-8
150
2.921875
3
[]
no_license
def rights p (1..1000).select { |a| (p * p - 2 * p * a) / (2 * p - 2 * a).to_f % 1 == 0 }.size / 2 end p (120..1000).max_by { |n| rights n }
true
c7e3869b568ea20955153617c368132677cf90c5
Ruby
chhavi-khandelwal/basic-ruby-exercises
/interest_difference/lib/interest.rb
UTF-8
406
3.28125
3
[]
no_license
class Interest RATE = 0.1 attr_reader :principal, :time, :block def initialize(principal, time, &block) @principal, @time, @block = principal.to_f, time.to_f, block end def get_simple_interest principal * RATE * time end def get_compound_interest principal * ((1 + RATE) ** time - 1) end ...
true
1250e902bb24a0796c8589134c3fb38aee048971
Ruby
h4hany/leetcode
/solutions/931_minimum_falling_path_sum.rb
UTF-8
1,072
4.1875
4
[]
no_license
# Given a square array of integers A, we want the minimum sum of a falling path through A. # # A falling path starts at any element in the first row, and chooses one element from each row. The next row's choice must be in a column that is different from the previous row's column by at most one. # # # # Example 1: # # ...
true
61a02142c9ac626c9281e4949e2dc213b841342e
Ruby
jennli/codecorejan2016
/ruby_lec_lab/week1/sort.rb
UTF-8
260
2.953125
3
[]
no_license
a = [1,5,23,77,4,6,33,52,3,9] for i in 0...a.size-1 position = i d = i + 1 for m in d...a.size if a[position] > a[m] position = m end end if position != i swap = a[i] a[i] = a[position] a[position] = swap end end p a
true
8c4561c3d87b4c571140807bfc21485b9e880cf9
Ruby
CodingDojoDallas/ruby-oct-2016
/Heffner_Daniel/Ruby Assignments/bank_account_with_test/bankaccount_spec.rb
UTF-8
1,437
3
3
[]
no_license
require_relative "bank_account" RSpec.describe BankAccount do describe 'initialization' do before do @ba = BankAccount.new end it 'has a method for retrieving checking account balance' do expect(@ba.checking).to eq(0) end it 'has a method for retrieving the savings account balance' do expect(@ba.sa...
true
da63c1d812b8409d7b68bffa14be2c2490ea8c45
Ruby
MohammedBm/CodeCoreBootCamp
/Day 04/lab/possible_Permutations.rb
UTF-8
219
3.359375
3
[]
no_license
puts "Enter a number or a letter" input1 = gets.chomp puts "Enter a number or a letter" input2 = gets.chomp puts "Enter a number or a letter" input3 = gets.chomp a = [input1, input2 , input3] print a.permutation.to_a
true
a97f14184b10063794ff4840875a4a8e9483c871
Ruby
Nandiswar/InternetTechSamples
/RubySamples/GivenProductIDListCustomerContactNames.rb
UTF-8
1,884
3.390625
3
[]
no_license
# necessary libraries require "net/http" require "uri" require "json" # print statement asking user to enter product id print "Enter Product ID and I will find Customer's who ordered it " # read the entered value inputId = gets inputId.chomp! # print the entered value puts("Product ID: " + inputId) puts() # uri to fin...
true
3cbe08d8eb7bd30f06b26e3f3e93de0311392887
Ruby
MiguelSavignano/graphql-ruby
/lib/graphql/schema/member/has_fields.rb
UTF-8
1,621
2.578125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module GraphQL class Schema class Member # Shared code for Object and Interface module HasFields # Add a field to this object or interface with the given definition # @see {GraphQL::Schema::Field#initialize} for method signature # @return [void] ...
true
096ae64c46103bf8b1862519c90e32b48c8ce1d3
Ruby
robinheinze/train_system
/spec/arrival_spec.rb
UTF-8
1,046
2.953125
3
[]
no_license
require 'spec_helper' describe Arrival do describe '.initialize' do it 'initializes with arrival values' do test_arrival = Arrival.new(2, '16:45', 1) test_arrival.should be_an_instance_of Arrival end end describe 'save' do it 'saves arrival value to the all array' do test_arrival ...
true
fe47776be4c0d18f64497e1c6eb364b1b73757aa
Ruby
Lerati00/black_jack
/black_jack/player.rb
UTF-8
798
3.34375
3
[]
no_license
class Player attr_reader :name, :hand, :bank STARTING_BANK = 100 def initialize(name) @name = name @bank = STARTING_BANK @hand = Hand.new end def reset_hand @hand = Hand.new end def reset_bank @bank = STARTING_BANK end def give_card(card) hand.take_card(card) end def ...
true
0a799364724c8ac312c45dc60d83d36f3ea91eb2
Ruby
msroot/kuler_shaker
/lib/kuler_shaker/kuler_comment.rb
UTF-8
926
2.53125
3
[ "MIT" ]
permissive
module KulerShaker # holds the data necessary to work with comments as they are provided by the Kuler RSS feed. # See the Adobe API reference for more info (not that there's a whole lot! Grr!) class KulerComment # the comment text - a string with HTML key codes to indicate formatting attr_accessor :c...
true
e677174d5e83bf0ae337d0a24f9dff103e33622d
Ruby
pbrzn/CLI_project
/Development/Flatiron/labs/CLI_project/lib/scraper.rb
UTF-8
1,412
2.84375
3
[]
no_license
require 'nokogiri' require 'open-uri' # require 'pry' class Scraper def self.streamer_scraper(streaming_service) streamer = Nokogiri::HTML(open("http://www.justwatch.com/us/provider/#{streaming_service.downcase.gsub(" ", "-")}/movies")) movies = streamer.css("div.title-list-grid__item") movies.map do |...
true
148af3f53eb2f54bafefa02d3da5f11e782cd549
Ruby
TazzyG/Methods_lesson
/lib/app.rb
UTF-8
5,159
3.375
3
[]
no_license
require 'json' # methods go here # Setup Files def setup_files path = File.join(File.dirname(__FILE__), '../data/products.json') file = File.read(path) $products_hash = JSON.parse(file) $data = $products_hash["items"] $report_file = File.new("report.txt", "w+") end def file_close $report_file.close end def start...
true
6e49cf504790d255b8907bb856fd6499f4fa3a5b
Ruby
odangitsdjang/AA_homeworks
/W4D4/auth_hw/app/models/user.rb
UTF-8
1,372
2.59375
3
[]
no_license
class User < ApplicationRecord attr_reader :password validates :username, :session_token, presence: true, uniqueness:true validates :password_digest, presence: { message: 'Password can\'t be blank' } validates :password, length: { minimum: 8, allow_nil: true } before_validation :ensure_session_token def s...
true
267ee08ed171c30d679bf7805eecc0312df8079d
Ruby
rocky/rb-trepanning
/test/functional/test-step.rb
UTF-8
6,460
2.921875
3
[ "BSD-2-Clause" ]
permissive
#!/usr/bin/env ruby require 'test/unit' require_relative 'fn_helper' class TestStep < Test::Unit::TestCase include FnTestHelper def no_test_step_same_level skip "FIXME" # See that we can step with parameter which is the same as 'step 1' cmds = ['step', 'continue'] d = strarray_setup(cmds) ...
true
e736a616f61b5dd009ce89d62957f43f124afc99
Ruby
matschaffer/friends
/friend.rb
UTF-8
430
2.96875
3
[]
no_license
# # friend.rb # Friends # # Created by Mat Schaffer on 10/31/08. # Copyright (c) 2008 Mat Schaffer. All rights reserved. # class Friend KEYS = [:first_name, :last_name, :phone_number, :email_address] KEYS.each { |k| attr_accessor k } def initialize(*args) args.last.each { |k, v| send("#{k}=", v) } if args.l...
true
8c403ff982babea9e27260c407ee1ede447207e8
Ruby
sumeetkr/katas
/Katas_In_Ruby/Katas/array_problems_solver.rb
UTF-8
5,096
3.796875
4
[]
no_license
class ArrayProblemsSolver def self.two_sum_problem_extended(array, sum_min, sum_max) # The goal of this problem is to implement a variant of the 2-SUM algorithm (covered in the Week 6 # lecture on hash table applications). # The file contains 500,000 positive integers (there might be some repetitions!)....
true
38f4952fcabb169e67cd61f33a5570da38f89f09
Ruby
funwithcthulhu/project-euler
/ruby/061_cyclical_figurate_nums.rb
UTF-8
4,501
3.9375
4
[]
no_license
# Project Euler Problem 61 - Cyclical figurate numbers # Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal # numbers are all figurate (polygonal) numbers and are generated by # the following formulae: # Triangle P3,n=n(n+1)/2 1, 3, 6, 10, 15, ... # Square P4,n=n2 1, 4, 9, 16, 25, ... # Pen...
true
698d96809dc6c28bef6c645db4677a67a607e0cc
Ruby
franklouwers/aoc2020
/10/part2.rb
UTF-8
387
2.78125
3
[]
no_license
ff = File.open("input") #ff = File.open("sample-a") adapters = Array.new([0]) + ff.readlines.map{|l| l.chomp.to_i}.sort count_a = Array.new([1]) adapters.each_with_index do |a, idx| if idx < 4 start = 0 else start = idx - 4 end (start..idx-1).each do |j| if a - adapters[j] < 4 count_a[idx] =...
true
c00cbfcf6d6f997b0900f90c8f6a130aa33a989d
Ruby
cpeterson7/assignments
/Blackjack^.rb
UTF-8
2,120
3.890625
4
[]
no_license
def calculate_total(cards) arr = cards.map{|e| e[1]} total = 0 arr.each do |value| if value == "Ace" total += 11 elsif value.to_i == 0 total += 10 else total += value.to_i end end arr.select{|e| e == "Ace"}.count.times do total -=10 if total > 21 end total end s...
true
00c5a923b5efcad4b1424524972949ef1ec6dcff
Ruby
BetterErrors/better_errors
/lib/better_errors/editor.rb
UTF-8
3,499
2.609375
3
[ "MIT" ]
permissive
require "uri" module BetterErrors class Editor KNOWN_EDITORS = [ { symbols: [:atom], sniff: /atom/i, url: "atom://core/open/file?filename=%{file}&line=%{line}" }, { symbols: [:emacs, :emacsclient], sniff: /emacs/i, url: "emacs://open?url=file://%{file}&line=%{line}" }, { symbols: [:idea], sniff...
true
1275d1be20a28d3cd1bc390cf1c94974792e7739
Ruby
rachidcalazans/chid
/lib/chid/command.rb
UTF-8
3,705
3.484375
3
[]
no_license
module Chid class Command class << self attr_accessor :summary, :description, :arguments COMMANDS = {} def command(cmd) COMMANDS[cmd] = self.to_s end def help if self.description.nil? commands = String.new COMMANDS.keys.each {|k| commands << ...
true
e7df881d6a7fcbc9c129a9f67b32e3c14ea5e950
Ruby
rbhogans/prime-ruby-onl01-seng-pt-032320
/prime.rb
UTF-8
143
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def prime?(integer) if integer<2 return false else (2..(integer-1)).each do |num| return false if integer % num==0 end true end end
true
e05ed0f179f7b6262eaa5e4e1d6aae973338d9b2
Ruby
phss/jeeklabs
/binary_nights/spec/binary_nights/model/pad_spec.rb
UTF-8
1,907
2.875
3
[]
no_license
# # pad_spec.rb # binary_nights # # Created by Paulo Schneider on 2008-03-17. # Copyright 2008 Jeek Labs. All rights reserved. # require File.dirname(__FILE__) + '/../../spec_helper' describe Pad do def create_mock_court upper_sideline = Deflector.new(Orientation::horizontal) upper_sideline.at(0, 0...
true
7dc2776f5e744b145b2b828da9c1f94959a9314c
Ruby
brentbrinkley/tealeaf-quizzes
/tealeaf_quizzes/easy/quiz_1.rb
UTF-8
1,641
3.90625
4
[]
no_license
puts "1) 1 2 2 3 because the uniq method does not mutate the caller" puts "2) Doesn't do anything on it's own but ! is used to indicate that a method is going to alter the caller in some drastic way and ? indicates a method that evaluates to true or false" puts "\t 1. not equal and it's best to use in comparison opera...
true
242511f1a55200b63164f2934cea1abb54c9d60c
Ruby
antran511/testRuby
/march/29.rb
UTF-8
2,569
2.78125
3
[]
no_license
require 'rspec' def url_matcher %r{ \b ( (?: [a-z][\w-]+: (?: /{1,3} | [a-z0-9%] ) | www\d{0,3}[.] | [a-z0-9.\-]+[.][a-z]{2,4}/ ) (?: [^\s()<>]+ | \(([^\s()<>]+|(\([^\s()<>]+\)))*\) )+ (?: \(([^\s()<>]+|(\([^\s()<>]+\)))*\) | [^\s`!(...
true
c5ecc0339be9dfb8594e7fcdbbb98d763cd076d3
Ruby
francirp/ruby-witchhunt
/classes/step/judge_step.rb
UTF-8
515
2.546875
3
[]
no_license
class JudgeStep < Step include ActionableStep def options options = game.surviving_players.map do |player| Option.new(value: player.id, label: player.name) end options end def action player = game.find_player_by_id(parsed_response) player.vote_off! end def ask "Judge, since ...
true
cb7b0123d2071483ae28cc6ceb0e3f412a2af3a4
Ruby
philnash/bitly
/spec/bitly/http/request_spec.rb
UTF-8
3,396
2.734375
3
[ "MIT" ]
permissive
# frozen_string_literal: true RSpec.describe Bitly::HTTP::Request do let(:uri) { URI.parse("http://example.com") } it "is initialized with a URI and the method is GET by default" do request = Bitly::HTTP::Request.new(uri: uri) expect(request.uri).to eq(uri) expect(request.method).to eq("GET") end ...
true
7dfc42566d02037dee906121122b6cb7c9f633aa
Ruby
jakubjanecek/MI-RUB-Project
/test/test_parser.rb
UTF-8
2,510
2.59375
3
[]
no_license
require_relative "../lib/pascalparser/lexer" require_relative "../lib/pascalparser/symbol_table" require_relative "../lib/pascalparser/label_generator" require_relative "../lib/pascalparser/parser" require "test/unit" class TestParser < Test::Unit::TestCase def test_parser1 lexer = PascalParser::Lexer.new("Prog...
true
03b7c2ec6e4056b369fe9138177d473f953a63c9
Ruby
ebertolazzi/pins-mruby-merb
/mrblib/merb.rb
UTF-8
6,008
2.796875
3
[ "MIT" ]
permissive
# = MERB -- Ruby Templating # # Author:: Paolo Bosetti & Enrico Bertolazzi # Copyright (c) 2013 Paolo BOSETTI # # You can redistribute it and/or modify it under the same terms as Ruby. # 000000000000000000 class MERB @@out = '' def self.out; @@out ; end def self.out=(v); @@out = v; end attr_reader :...
true
1f9bfcb2d4368a0d6bd3910d579e7f6c5d396b5c
Ruby
maxnussbaum/contentCop
/lib/contentCop/lyric_methods.rb
UTF-8
661
2.546875
3
[ "MIT" ]
permissive
require "json" require "http" require "uri" require "nokogiri" # require("httplog") # HttpLog.configure do |config| # config.log_connect = true # config.log_request = true # config.log_headers = true # config.log_data = true # config.log_status = true # config.log_response = true # end def get_lyrics(artis...
true
a41175b6c273fbfa9df9054f6ef2b11442eb4a06
Ruby
RSRBX07/exo-johann
/lib/hello.rb
UTF-8
158
3.03125
3
[]
no_license
puts "Hello World !!!!" puts "Quel est votre nom ?" nom = gets.chomp puts "Bonjour #{nom}" puts "Comment vas tu ?" 3.times do puts "Hello #{nom}" end
true
db16b8e4e96cab14d184359801e2de2497d2a1bb
Ruby
fidk/BeginningRubyNotes
/Chapter2.rb
UTF-8
5,129
3.8125
4
[]
no_license
# Practice and notes from Beginning Ruby: From Novice to Professional, Second Edition. Peter Cooper, Apress (2009) # Chapter 2 # The Making of a Man class Person attr_accessor :name, :age, :gender end # class Person # A class is the definition of a single type of object. # Class names always start with a capital l...
true
88f6977b21c271c3b0915cdf9036c5e5a1411ff6
Ruby
evilstreak/pipe-dream-prototype
/lib/grid.rb
UTF-8
3,242
3.3125
3
[]
no_license
require './lib/cell.rb' require './lib/tile/block.rb' class Grid SCROLL_SPEED = 10.0 def initialize(window, top_left, row_count, cell_size) @window = window @row_count = row_count @cell_size = cell_size # Build the first column @cells = [] @cells << build_start_column(top_left) # Add...
true
7d7e70d3f6a8bc08a00efc7b3621da78ab792c9e
Ruby
kirangan/class_kolla
/hari_5/apple.rb
UTF-8
387
3.609375
4
[]
no_license
<<<<<<< HEAD def apple2(n) line = n > 4 ? n : 4 line = n.odd? ? n - 1 : n hasil = '' baris = 2 * line - 1 0.upto(line - 1) do |i| row = ('_' * baris) row[baris / 2 + i] = 'A' row[baris / 2 - i] = 'A' if i == (line / 2) i.upto(line + i - 1) do |x| row[x] = 'A' end end ...
true
0702442eea70809c6d9e2b60c473ea902ddc4e06
Ruby
Jill-Ann/kattis-ruby
/booking.rb
UTF-8
1,134
3.890625
4
[]
no_license
input = STDIN.gets.chomp.split(" ").map(&:to_i) #this saves the number of kittens and beds to variables, then removes them from the array kittens = input[0] beds = input[1] input.delete_at(0) input.delete_at(0) #together these delete the first 2 elements in the array. #this splits the array into 2 arrays: arrival dat...
true
95046332dc86ea75abb88cefa3fff9d415d79a2b
Ruby
Thomas-Muscarello/oo-cash-register-onl01-seng-pt-061520
/lib/cash_register.rb
UTF-8
1,131
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class CashRegister attr_accessor :total, :discount, :price, :items, :transactions def initialize (discount = 0) #discount starts at zero @total = 0 #total starts at zero @discount = discount @items = [] @transactions = transactions # transactions are for the price and quantity end def add_item(item,p...
true
eb0404c84a437280e203bac86d28dee8d0e31371
Ruby
btbuxton/ruby-code-practice-turtle
/test/test_canvas.rb
UTF-8
815
2.796875
3
[]
no_license
require 'test/unit' require_relative '../lib/canvas' module TurtleTracks class TestCanvas < Test::Unit::TestCase def test_simple canvas = Canvas.new(3) assert_equal(". . .\n. . .\n. . .", canvas.to_s) end def test_turn_on_off canvas = Canvas.new(3) canvas.turn_on(0,0) a...
true
c6939aa8fbfe697b6f1fd4ccc64ca4ed192ea13f
Ruby
Jhdezj/Ruby-challenges
/Even-fibonacci.rb
UTF-8
259
3.390625
3
[]
no_license
def even_fibonacci(n, prev_num = 0, next_num = 1, sum = 0) if next_num <= n sum += next_num if next_num.even? prev_num, next_num = next_num, prev_num + next_num even_fibonacci(n, prev_num, next_num, sum) else sum end end
true
58c3b4cd008240e3633c721774d1a5f0851861dc
Ruby
weiofdesign/wei_book_review
/app/models/user.rb
UTF-8
414
2.59375
3
[]
no_license
class User < ActiveRecord::Base attr_accessible :age, :email, :first_name, :last_name def is_teen? (13...19).include?(age) end def has_long_name? (first_name + last_name).size > 10 end def self.all_long_name self.all.select do |user| user.has_long_name? end end def self.all_tee...
true
5c1d0057edc843ee8cadbe21930881421f6beb07
Ruby
joe-gz/scrabbler
/lib/scrabble_word.rb
UTF-8
892
3.609375
4
[]
no_license
require 'pry' class ScrabbleWord def initialize word @word = word # sets hash of score values @letter_value = {a:1,b:3,c:3,d:2,e:1, f:4,g:2,h:4,i:1,j:8, k:5,l:1,m:3,n:1,o:1, p:3,q:10,r:1,s:1,t:1, u:1,v:4,w:4,x:8,y:4, z:10} @matches = [] end #GETTERS def wo...
true
966c72ac3e6c0400956bf9683dad4d77d47d3859
Ruby
JamaSoftware/analyze-ruby
/lib/notion/api.rb
UTF-8
2,059
2.78125
3
[ "MIT" ]
permissive
require "notion/api/version" require 'excon' require 'json' module Notion::API def self.connect(**args) Client.new(**args) end class Client DEFAULT_ROOT = "https://analyze.jamacloud.com".freeze URL_TEMPLATE = "/api/%{version}/%{action}".freeze DEFAULT_VERSION = "v1" def initialize(api_toke...
true
0c6341ac38783f2eb0fbc51c0293ee6dcf874cf8
Ruby
PiotrEjsmont/learn_ruby
/11_dictionary/dictionary.rb
UTF-8
598
3.359375
3
[]
no_license
class Dictionary attr_accessor :d def initialize @d = {} end def entries @d end def add(entry) entry.is_a?(Hash) ? @d.merge!(entry) : @d[entry] = nil end def keywords sorted = d.sort.to_h sorted.keys end def include?(x) if @d.include?(x) true else false end end d...
true
87c0b3a9a800a3d5628bee975e9b5f89d7328e9a
Ruby
AlvaroMaceda/calculadora-judicial
/spec/lib/csv_basic_importer_spec.rb
UTF-8
7,604
2.6875
3
[]
no_license
require 'rails_helper' describe CsvBasicImporter do let(:importer_class) { Class.new do include CsvBasicImporter def expected_headers ['headerA','headerB','headerC'] end def process_row(row) end end } let(...
true
624a89d7d88e5e7aaec9b922e3b0ee9246280bf2
Ruby
preslavmihaylov/adventofcode
/2022/day02/part01/main.rb
UTF-8
1,021
3.8125
4
[ "MIT" ]
permissive
#!/usr/bin/env ruby def parse_play(letter) return :rock if %w[A X].include?(letter) return :paper if %w[B Y].include?(letter) return :scissors if %w[C Z].include?(letter) :unknown end def read_input(_filename = 'input.txt') file = File.open(_filename) plays = [] file.each_line do |line| plays.appe...
true
49e5c50e1d8364aa0f65abeb5b2f786f36f41352
Ruby
ptn/chess_validator
/lib/chess_validator/pieces/knight.rb
UTF-8
287
2.765625
3
[]
no_license
module ChessValidator module Pieces class Knight < Piece private def movement_rule(destination) column_diff, row_diff = diffs(destination) (column_diff == 2 && row_diff == 1) || (column_diff == 1 && row_diff == 2) end end end end
true
bedfe9e09e2860b18a5b5caefc3c66dd41913cb1
Ruby
dizhengcindy/ruby-oo-object-relationships-collaborating-objects-lab-seattle-web-030920
/lib/song.rb
UTF-8
710
3.421875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class Song attr_accessor :name, :artist @@all = [] def initialize(name) @name = name @@all << self end def name=(name) @name = name end def self.all @@all end def self.new_by_filename(file_name) #file_name = 'Michael Jackson - Black or...
true
8623f727709a2b3906082af451bd3a8860671a64
Ruby
lwassink/active-record-light
/lib/03_associatable.rb
UTF-8
2,223
2.671875
3
[]
no_license
require_relative '02_searchable' require 'active_support/inflector' # Phase IIIa class AssocOptions attr_accessor( :foreign_key, :class_name, :primary_key ) def model_class class_name.constantize end def table_name name = class_name.to_s.underscore.pluralize name == "humen" ? "human...
true
fa0a5dc0e5ddb0736573481300c36635e389eafb
Ruby
yvonnebarker/lrthw
/ex34.rb
UTF-8
763
4.90625
5
[]
no_license
#Exercise 34: Accessing Elements of Arrays animals = ["bear", "ruby", "peacock", "kangaroo", "whale", "platypus"] bear = animals[0] ruby = animals[1] peacock = animals[2] kangaroo = animals[3] whale = animals[4] platypus = animals[5] puts "The first (1st) animal is at 0 and is: #{animals[0]}" puts "The second (2nd) ani...
true
9b8d006f101ff26bb5292719d2f8e2e83aaba854
Ruby
yard/viddl-rb
/helper/audio-helper.rb
UTF-8
2,132
2.71875
3
[]
no_license
module ViddlRb # This class is responsible for extracting audio from video files using ffmpeg. class AudioHelper def self.extract(file_name, save_dir) # capture stderr because ffmpeg expects an output param and will error out puts "Gathering information about the downloaded file." ...
true
65be2ec06d031c25e33fbafd75f6a59f3c616cc9
Ruby
meleneth/dotfiles
/wizard/wizard
UTF-8
3,223
3.140625
3
[]
no_license
#!/usr/bin/env ruby # W.I.Z.A.R.D. require 'pathname' $LOAD_PATH << "#{Pathname.new(File.expand_path(__FILE__)).realpath.dirname}" require 'lib/wizard_function' require 'lib/wizard_class' require 'lib/wizard_file' require 'lib/wizard_project' def create_project(project_name) project = WizardProject.new(project_n...
true
824f4822c120a68831746d6853b4d4153ebc6ee1
Ruby
sniquey/WDI6HW
/bigbrother.rb
UTF-8
322
3.421875
3
[]
no_license
puts "Welcome to the Big Brother Database" print "What is your first name? " first = gets.chomp print "What is your surname? " surname = gets puts "Your full name is #{first} #{surname.chomp}" print "What is your address? " address = gets.chomp puts "Your name is #{first} #{surname.chomp} and you live at #{address...
true
5526c75201327c74429eb5268b38fb0228917117
Ruby
minskliliya/ruby-course
/lesson6/train.rb
UTF-8
2,098
3.234375
3
[]
no_license
class Train include CompanyTrain attr_accessor :id_train, :type, :number_carriage, :speed, :route, :current_station TRAIN_TYPE = /^cargo$|^passenger$/i ID_TRAIN = /^((\d|[a-z]){3})-?((\d|[a-z]){2})$/i @@trains_number = {} def initialize(id_train, type) @id_train = id_train @type = type ...
true
0f8b0c50e2933ed1a935989a0cd7ae0fab0d99c4
Ruby
muffinista/random-word
/lib/random_word.rb
UTF-8
3,106
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
require 'set' require 'pathname' require 'json' # Provides random, non-repeating enumerators of a large list of # english words. For example" # # RandomWord.adjs.next #=> "strengthened" # module RandomWord module EachRandomly attr_accessor :random_word_exclude_list attr_accessor :min_length attr_acce...
true
ecf14209401992cdf3956966f81493a454cf269d
Ruby
Dutchmile/triangle-classification-onl01-seng-pt-061520
/lib/triangle.rb
UTF-8
1,060
3.3125
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Triangle attr_accessor :type attr_reader :side1_length, :side2_length, :side3_length def initialize(side1_length,side2_length,side3_length) @side1 = side1_length @side2 = side2_length @side3 = side3_length type = self.kind end class TriangleError < StandardError end def kind ...
true
b319a69fee49a4524e76a771b786530b20f1e383
Ruby
coins5/estructura-datos-algoritmos
/Practica-ruleta/ruleta.rb
UTF-8
3,651
3.453125
3
[]
no_license
# genera la ruleta tal cual la explico el profesor def generarRuletaFija() # Elementos de la ruleta nodoA = [nil, 'A', nil] nodoB = [nil, 'B', nil] nodoR = [nil, 'R', nil] nodoM = [nil, 'M', nil] nodoZ = [nil, 'Z', nil] nodoC = [nil, 'C', nil] # Relacionando los nodos # No se toca l...
true
398e016c724a4f4ba93bb0df4a0f29100543626f
Ruby
bobbyworx/devcms-core
/app/models/response.rb
UTF-8
1,316
2.609375
3
[]
no_license
require 'csv' # This model is used to represent a response from a contact_form # # A +Response+ has many +ResponseField+ objects. # # *Specification* # # Attributes # # * +ip+ - The ip adress of the sender # * +time+ - The time when the response is sent # # Preconditions # # * Requires the presence of +ip+, +time+. # ...
true
79da789325d035cc7f98df2ee846b83d01bdbb9d
Ruby
NatashaHull/EulerSolutions
/Problem2.rb
UTF-8
122
3.578125
4
[]
no_license
sum = 0 x = 1 y = 1 while x < 4000000 new_num = x + y y = x x = new_num sum += x if x % 2 == 0 end puts sum
true
f00c2b67749dc44586d75a9dc2a5ea697f25f4dd
Ruby
AgniMulti/challenge
/lib/desafio/repository.rb
UTF-8
1,726
2.78125
3
[]
no_license
module Desafio class Repository attr_accessor :owner, :name, :id NAME_WITH_OWNER_PATTERN = /\A[\w.-]+\/[\w.-]+\z/i def self.from_url(url) new URI.parse(url).path[1..-1]. gsub(/^repos\//,''). split('/', 3)[0..1]. join('/') end def initialize(repo) case repo ...
true
669cb6f147bfd836df8d44b97ff0cf95202612eb
Ruby
Crysicia/THP_S6
/THP-Ruby-Day00/number_to_string.rb
UTF-8
45
2.9375
3
[]
no_license
def number_to_string(n) return n.to_s end
true
31a94d7062ad956e6e0054f3c809c03e9d921948
Ruby
kiranqureshi1/week1_day4_friends_testing_lab
/friends.rb
UTF-8
1,180
3.25
3
[]
no_license
def get_name(person) return person[:name] end def tv_show(person) return person[:favourites][:tv_show] end def likes_to_eat(person, food) for snack in person[:favourites][:snacks] if snack == food return true end end return false end def add_friend(person, friend) person[:friends] << friend...
true
40df2253b84d91344b43c62605794eb990124d35
Ruby
yvettecook/FAAST
/lib/station.rb
UTF-8
627
3.53125
4
[]
no_license
class Station attr_reader :trains attr_reader :platform def initialize @platform = [] @trains = [] end def add(person) platform << person end def remove(person) platform.delete(person) end def passengers_count @platform.length end def train_count @trains.length end def arrive(train) @t...
true
da7fcbe2ae851c7c4bc302d3f5e3c52902e2f8b7
Ruby
hx/rack-traffic-logger
/lib/rack/traffic_logger/option_interpreter/shorthand.rb
UTF-8
1,800
2.8125
3
[ "MIT" ]
permissive
module Rack class TrafficLogger class OptionInterpreter class Shorthand ABBREVIATONS = { ge: :get, po: :post, pu: :put, pa: :patch, de: :delete, op: :options, he: :head, tr: :trace, h: :heade...
true
9e7f0eccdca4cab870ed2e73b051f9d975bd9263
Ruby
jyates/fineo-deploy-lambda
/lib/deploy/promote.rb
UTF-8
1,071
2.515625
3
[]
no_license
require 'sources' require 'optargs' require 'ostruct' module Promote def parse(args) options = OpenStruct.new OptionParser.new do |opts| opts.banner = "Usage: deploy-lambda.rb [options]" opts.separator "Promote AWS Lambda functions to a given alias" opts.separator " Options:" opts...
true
9797898324a7302ff933585be3491c1125bda290
Ruby
wfischer42/complete_me
/lib/csv_adapter.rb
UTF-8
285
2.84375
3
[]
no_license
require 'csv' class CSVAdapter def initialize(filename, header) @filename = filename @header = header end def array_of_strings strings = [] CSV.foreach(@filename, :headers => true) do |row| strings << row[@header] end return strings end end
true
6e8d9371ac7fa4c2f4368e9dd383909e939307c8
Ruby
oozou/active_form
/lib/active_form/simple_form_helpers.rb
UTF-8
1,205
2.53125
3
[ "MIT" ]
permissive
# frozen_string_literal: true module ActiveForm # This module adds methods available on AR classes used by simple_form to # infer the input types # # Rails Attributes supports type casting so we can utilise this to display # the correct type, unfortunately, AR uses database typecasting for this # method so...
true
a8c6b6d365a805e91eada3c37d55939ea8a8e8aa
Ruby
MariethPerez/Mini_assigment_day4
/Remove.rb
UTF-8
328
3.140625
3
[]
no_license
class Array def remove_(integer_list, values_list) resultado = integer_list-values_list end end l = Array.new() integer_list = [1, 1, 2 ,3 ,1 ,2 ,3 ,4] values_list = [1,3] puts l.remove_(integer_list,values_list) # Test.assert_equals(l.remove_(integer_list, values_list), [2, ...
true
3d2ae109a2da79d42741c2c4060fbf1a84cbdc97
Ruby
disruptek/cnote
/classes/note.rb
UTF-8
2,396
3.171875
3
[ "MIT" ]
permissive
require 'time' class Note attr_reader :title, :content, :tags, :filename, :path, :modified, :created attr_writer :created def initialize(path) @meta_regex = /^<!\-{3}(.*)\-{2}>/ @content = '' @tags = [] @filena...
true
6e1ab2a25ccf915b69b3b800e55a86589f8253c4
Ruby
cielavenir/procon
/atcoder/abc/tyama_atcoderABC003C.rb
UTF-8
104
2.65625
3
[ "0BSD" ]
permissive
#!/usr/bin/ruby n,k=gets.split.map(&:to_i) p gets.split.map(&:to_f).sort[-k..-1].reduce(0){|s,e|(s+e)/2}
true
f82caf629a05906506fbe932a9cf18b8d775a908
Ruby
mikeyduece/showoff.ie-test
/app/services/instagram_service.rb
UTF-8
509
2.578125
3
[]
no_license
class InstagramService def initialize(uid, token=nil) @uid = uid @conn = Faraday.new("https://api.instagram.com/v1/") do |faraday| faraday.params['access_token'] = token faraday.adapter Faraday.default_adapter end end def own_pics get_url("users/#{uid}/media/recent/") end def me...
true
6223dc0bd4e2684fa29b57a53f793987319c3959
Ruby
alchemycyberblaze/selenium101
/exercises/common/mylib.rb
UTF-8
43
2.71875
3
[ "Apache-2.0" ]
permissive
def echo(s) puts "[ECHO]: " + s end
true
55f988ffc613fc6b554ff45b967de228009c3d28
Ruby
steveny91/phase-0-tracks
/ruby/santa.rb
UTF-8
1,542
3.53125
4
[]
no_license
class Santa attr_reader :ethnicity, :reindeer_ranking attr_accessor :age, :gender def initialize (gender, ethnicity) puts "Initializing Santa instance..." @gender = gender @ethnicity = ethnicity @reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer", "Vixen", "Comet", "Cupid", "Don...
true
8cb72b0332dcdcf33b44cb6aca9e0b27f37bfb92
Ruby
jsthatcher/phase-0
/week5/calculate-mode/my_solution.rb
UTF-8
2,419
3.890625
4
[]
no_license
# Calculate the mode Pairing Challenge # I worked on this challenge with Jack # I spent [] hours on this challenge. # Complete each step below according to the challenge directions and # include it in this file. Also make sure everything that isn't code # is commented. # 0. Pseudocode # What is the input? array ...
true
9d073c63637e3e37d521a70b2dbedfceaf76a31f
Ruby
bnorton/micro_q
/lib/micro_q/fetchers/sqs.rb
UTF-8
1,189
2.609375
3
[ "MIT" ]
permissive
module MicroQ module Fetcher class Sqs include Celluloid attr_reader :name def initialize(name, manager) @name = name.to_s @manager = manager end ## # Long poll the SQS messages API and if there are messages # then fetch more right away. Send messages to...
true
0d2693e42a3f858f3a0da01255adc818341e43e6
Ruby
dancingshell/ruby_practice
/annagram/spec/anagram_of_palindrome_spec.rb
UTF-8
889
3.4375
3
[]
no_license
require "spec_helper" require_relative "../lib/anagram_of_palindrome" describe "solution" do it "should return 1 if letters of an even word can be arranged in a palindrome" do expect(solution("dooernedeevrvn")).to eq(1) end it "should return 1 if letters of an odd word can be arranged in a palindrome" do ...
true
8e4ca78c3e7cf2402ab1665935b62fb1a7f597e9
Ruby
Mic92/dmarc-reporter
/lib/dmarc/email.rb
UTF-8
536
2.53125
3
[]
no_license
require 'mail' module Dmarc class Email def initialize(email) @doc = email end def report c = content return nil unless c Dmarc::Report.new(c) end private def content message = Mail.new(@doc) zip_content_type = /^application\/(x-)?zip/ if message.conte...
true
00748736f1f4f06c7de2ce33d066777fc50e7d56
Ruby
glenc/rpoint
/lib/rpoint/extensions/string.rb
UTF-8
128
2.75
3
[]
no_license
class String ## # Convert a string to a url friendly version def url_friendly self.downcase.gsub(/ /, '') end end
true
0a8831b03247ac07d27855d445a7ee9ff1389456
Ruby
Jackwhitener/Random_Pairs
/random_pairs.rb
UTF-8
558
3.21875
3
[]
no_license
def pair(options,func) paircount = 0 pairs = [] deeppair = [] count = 0 half = options.length/2 if options.class != Array return "No." else half.times do while deeppair.length < 2 && options.length > 0 picked = options.sample deeppair << picked options.delete(picked) end pairs << deeppair ...
true
be6e1f8abac2174251f04b562b79fbe0486234ae
Ruby
cypok/learn_words
/lib/learn_words.rb
UTF-8
7,336
3.484375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'rubygems' require 'highline/import' ############################################################### # READING WORDS FILE ############################################################### class Word attr_reader :orig, :trans, :variants_number attr_accessor :times_...
true
731e0e74ef007432947216a5d50dc08cacfb7321
Ruby
KrisD2/RB101-RB109-small_problems
/Easy_8/fizzbuzz.rb
UTF-8
361
3.96875
4
[ "Unlicense" ]
permissive
def fizzbuzz(start_num, end_num) fizzbuzz_arr = [] (start_num..end_num).each do |x| case when x % 3 == 0 && x % 5 == 0 fizzbuzz_arr << "FizzBuzz" when x % 3 == 0 fizzbuzz_arr << "Fizz" when x % 5 == 0 fizzbuzz_arr << "Buzz" else fizzbuzz_arr << x end end fizzbuzz_...
true
4148ad01f0173235e5f90f732400fa44f774a42a
Ruby
true-runes/suikoden-election-2019
/app/lib/collect_tweets/execute.rb
UTF-8
6,706
2.59375
3
[ "MIT" ]
permissive
# rubocop:disable Layout/LineLength, Naming/VariableNumber module CollectTweets class Execute include MyTwitter::Client # TODO: メソッド名がわかりにくい def call # TODO: これだと、100ツイート以内に最新ツイートが収まらない場合に取得漏れが発生する # TODO: したがって、既存ツイートの ID に達するまでにループを回すことが本当は必要 # TODO: その際も、「検索結果は『上』から調べていく」ということに留意する必要...
true
cbd087ff404b3f0c9aa85908b9da0f2c85deebf7
Ruby
MMkkff12/ruby
/paycheck.rb
UTF-8
978
4.21875
4
[]
no_license
## Annual Pay Estimator puts "Enter from list below the letter next to your pay method." puts "Enter 1 if you are paid Every Week" puts "Enter 2 if you are paid Every Other Week" puts "Enter 3 if you are paid Semi- Monthly( twice a month)" puts "Enter 4 if you are paid Monthly" timeframe = gets.chomp puts "Enter the ...
true
7ad818c53d74796db96ecdd2d7e9afb30395e82b
Ruby
Priyanka4328/train
/try_inheritance2.rb
UTF-8
408
3.03125
3
[]
no_license
class Intern def initialize @a = 2 @b = 1 end end class Me < Intern attr_reader :gg def initialize @gg = 44 end end module A class Me attr_reader :gg def initialize @gg = 1 end end end class You def print p Me.new.gg p Me.ancestors end end #You.include A #p Me...
true
4ace069e6fa4e824059899824c5732a46f3a7292
Ruby
paolo2299/betscrape
/lib/betscrape/models/event_type.rb
UTF-8
327
2.6875
3
[]
no_license
module Models class EventType attr_reader :data def initialize(data) @data = data end def id @data.fetch('id') end def name @data.fetch('name') end # Pretty sure these never change, so safe to hard-code them FOOTBALL = new({'id' => '1', 'name' => 'Soccer'}) ...
true
e705d6725fd4763020e457bdcc3a0f9a8448a14a
Ruby
guynicolas/myflix
/spec/models/video_spec.rb
UTF-8
3,285
2.75
3
[]
no_license
require 'spec_helper' describe Video do it {should belong_to(:category)} it {should validate_presence_of(:title)} it {should validate_presence_of(:description)} it {should have_many(:reviews).order("created_at DESC")} describe "#title_only?" do it "returns true when description is nil" do vide...
true
fbe51813353ebfb41893fc4001ccd2a531824686
Ruby
chris-ramon/wordmarks
/_temp/temp2.rb
UTF-8
210
2.546875
3
[]
no_license
require 'json' array = JSON.parse(IO.read("array.json")) array_translate = array[0][2] x = array_translate.collect do |s| s[0] end puts x # if /^\w+$/ =~ 'shaystack' # puts 1 # else # puts 0 # end
true
4480870c5f1d4430ba705de58ce2c99ba2cb70b5
Ruby
spikeburton/deli-counter-prework
/deli_counter.rb
UTF-8
528
4.375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your code here. def line(arr) if (arr.size == 0) puts "The line is currently empty." else str = "The line is currently:" i = 0 while i < arr.size str += " #{i+1}. #{arr[i]}" i += 1 end puts str end end def take_a_number(arr, str) arr << str puts "Welcome, #{str}....
true
2fa14b014725562c2b274cfa4b1e82aaecd8b49c
Ruby
cool-beetles/treasures
/lib/collections/treasures_collection.rb
UTF-8
1,882
3.03125
3
[]
no_license
class TreasuresCollection @@treasures = [] def self.add(treasure) @@treasures << treasure end def self.all @@treasures end def self.find_by_id(id) @@treasures.detect { |treasure| treasure.id == id } end def self.by_user(user) @@treasures.select { |treasure| treasure.o...
true
82a9154ea524c36f8b817592e5bc6ba81bfa2db9
Ruby
jmporchet/tealeaf_prework
/iterating_over_hashes.rb
UTF-8
126
3.03125
3
[]
no_license
person = {name: 'bob', height: '1m75', weight: '66kg', hair_color: 'brown'} person.each do |k,v| p "Bob's #{k} is #{v}" end
true
26cc1f5d5218b20d41c2e9e42c0a047f3358178b
Ruby
viveksraghuwanshi/test
/case.rb
UTF-8
154
2.671875
3
[]
no_license
#!/usr/bin/ruby -w # per=75; case per when 10 .. 40 puts "Grade F"; when 50 .. 80 puts "Grade B"; when 90 .. 100 puts "A"; else puts "A+"; end
true
677caa3e65197f37228d84ce7eea6b3fc7c49d0b
Ruby
MartinVald2170/ruby-hackathon
/modules/questions.rb
UTF-8
5,253
3.640625
4
[]
no_license
module Questions # Rating Scale for multiple chopice options # Each response has a score value of it's index # example "Applied to me to a considerable degree, or a good part of time" at index 2 has a score value of 2 $rating_scale = [ "Did not apply to me at all", "Applied to me to some...
true
47a5b44c94fdb6dc4b83f19b9ed6b21c07c53b84
Ruby
dcurtis/typekit
/lib/typekit/variation.rb
UTF-8
1,710
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Typekit # @todo Move lazy loading into a module class Variation include MassAssignment attr_accessor :id, :name, :font_style, :font_variant, :font_weight, :foundry, :libraries, :postscript_name # Typekit::Variation.new isn't expected usage private :initialize class << self ...
true
774fcaa2ae773d417f436798631b19abfc358a4d
Ruby
K80Git/ruby
/paiza/s1.rb
UTF-8
102
3.0625
3
[]
no_license
for a in 0..3 for b in 0..(5-a) puts "#{a} #{b}" end end pp= 1 a =5 a = [pp, a].max puts a
true
0f6a50e5d7cb8cf0a466b13a250c05351f1b004b
Ruby
andocmdo/rbga1
/worker.old.rb
UTF-8
1,226
3.015625
3
[]
no_license
require 'json' require 'faraday' require 'time' # read in commandline args # Should be: worker_daemon {check for new job interval in s} {update status in s} {name} if ARGV[0] != nil && ARGV[1] != nil && ARGV[2] != nil @worker_id = ARGV[0].to_i @update_interval = ARGV[1].to_i @server_url = ARGV[2] else puts "Us...
true
2f4a0ab8de5430b841a8ee53b9ae547ede3c9903
Ruby
Neve/algorithm_design
/Ruby/duplicate_remover.rb
UTF-8
751
3.78125
4
[]
no_license
given_string = "abcdeafab" def duplicate_remover (input_string) for i in 0 .. input_string.length for j in 1 .. input_string.length if (input_string[i] == input_string[j]) && (j != i) puts "duplicates #{input_string[i]} == #{input_string[j]}" input_string[j] = " " end end put...
true
91def49614ca435ca6b428d1d9fdfba2d8dd5374
Ruby
esmaeilmirzaee/rubycode
/bp/#emacs_pry.rb#
UTF-8
146
2.765625
3
[]
no_license
#!/bin/ruby env p 1.next p 1.next.to_s.to_i p 1.odd? p 1.even? p 5.class p 5.0.class p 5 == 5.0 class BankAccount def initialise end end
true
f9ae4085a9730150bc44763d94c8dbf04677334f
Ruby
mehdic/magic_web_service
/lib/magic_web_service.rb
UTF-8
1,815
2.8125
3
[]
no_license
require 'java_dependencies' require 'inflector_methods' require 'java_property_setter' # The MagicWebService responds to operation calls using method_missing. It converts the method # name called and arguments into the correct request object and invokes the SOAP operation. class MagicWebService # Initializes the S...
true
e8a7088760fa1551fef161b05bac92fb1a226ecc
Ruby
t-tanahara/algorithms
/search/linear_search.ruby
UTF-8
880
3.53125
4
[]
no_license
# 線形探索法 if ARGV.size() < 2 p '必要な引数が足りません' exit end @search_num = ARGV[0].to_i if @search_num > 99 p "検索する数:#{@search_num} 桁数オーバー" exit end p "検索する数:#{@search_num}" @num_of_target = ARGV[1].to_i if @num_of_target > 99 p "検索する要素数:#{@num_of_target} 桁数オーバー" exit end p "検索対象の要素数:#{@num_of_target}...
true
89b181a39bf7127f4fbea114d0d02f6d85c099a1
Ruby
bitodeme-integrations/bitodeme_rb
/lib/bitodeme/resources/fund.rb
UTF-8
958
2.546875
3
[ "MIT" ]
permissive
module Bitodeme module Resource # Fund resource class Fund < Base private_class_method :new # Account identifier attr_reader :account_id # Current balance attr_reader :amount # When it is created attr_reader :created_at # Currency code attr_reader :cur...
true
c66f4cbbfc99c7890dca2eb4f3d88fa97ef2a987
Ruby
MatayoshiMariano/intercomTest
/point_3/invitation.rb
UTF-8
755
3.078125
3
[]
no_license
require_relative './user' require 'json' class Invitation attr_reader :file_path, :coordinates, :max_distance def initialize(file_path:, coordinates:, max_distance:) @file_path, @coordinates, @max_distance = file_path, coordinates, max_distance end def print_users_to_invite users_to_invite.each do |...
true