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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3993a7bd6c72f38b5b8e168a0faf28be6e904348 | Ruby | lskalkos/BandersnatchGraphQL | /config/choice_initializer.rb | UTF-8 | 5,306 | 2.640625 | 3 | [] | no_license | require_relative '../models/choice'
choices = [
{beginning_decision_point_id: 1, ending_decision_point_id: 2, name: 'Sugar puffs'},
{beginning_decision_point_id: 1, ending_decision_point_id: 2, name: 'Frosties'},
{beginning_decision_point_id: 2, ending_decision_point_id: 3, name: 'Thompson Twins'},
{beginning_deci... | true |
2fb11d36011e77c627567b6adc1cb73d0d89f51d | Ruby | jatin-baweja/rails-project | /app/models/subscriber.rb | UTF-8 | 435 | 2.53125 | 3 | [] | no_license | class Subscriber
include ActiveModel::Validations
include ActiveModel::Conversion
attr_accessor :email, :first_name, :last_name
validates :first_name, :last_name, :email, :presence => true
validates :email, format: { with: REGEX_PATTERN[:email], message: 'is in incorrect format' }, allow_blank: true
def... | true |
5810ca58efbd4f4586b6c3fe2c0a72e74c165f80 | Ruby | seansu4you87/cake | /bracket_validator_spec.rb | UTF-8 | 811 | 2.59375 | 3 | [
"MIT"
] | permissive | require_relative 'bracket_validator'
describe BracketValidator do
it "validates properly" do
expect(BracketValidator.validate("{ [ ] ( ) }")).to eql true
expect(BracketValidator.validate("{ [ ( ] ) }")).to eql false
expect(BracketValidator.validate("{ [ }")).to eql false
expect(BracketValidator.valid... | true |
a5b16653ffb536d80accea9cbe52325d2c6ba502 | Ruby | cycloped-io/syntax | /utils/csv_column.rb | UTF-8 | 684 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require 'bundler/setup'
require 'progress'
require 'csv'
require 'slop'
options = Slop.new do
banner "#{$PROGRAM_NAME} -i input.csv -c number -o filtered.csv\n" +
'Get n-th column of CSV file.'
on :i=, :input, 'Input CSV file', required: true
on :c=, :column, ... | true |
e08f369e854f539112d60d6a8d7abfa735e36820 | Ruby | fizx/rwget | /test/controller_test.rb | UTF-8 | 834 | 2.59375 | 3 | [] | no_license | require "test/unit"
# require File.dirname(__FILE__) + "/server"
require File.dirname(__FILE__) + "/../lib/rwget"
require "fileutils"
class Foo
class Bar
class Baz
end
end
end
class ControllerTest < Test::Unit::TestCase
include FileUtils
def setup
@tmp = File.dirname(__FILE__) + "/tmp"
mkdir_p... | true |
ff2c0f5b83e297732e1bb1e334fdfa16e282fd3b | Ruby | Xa1n/Battle | /spec/features/player_vs_computer_spec.rb | UTF-8 | 934 | 2.5625 | 3 | [] | no_license | feature 'Playing vs. a Computer' do
scenario 'computer gets an automatic name' do
sign_in_and_play(true)
expect(page).to have_content 'Player 1 vs. Computer'
end
scenario 'computer makes an attack' do
sign_in_and_play(true)
attack_and_confirm
expect(page).to have_content 'Computer attacked Pl... | true |
9db3066793b5b98b62b084b659e29751a6786a54 | Ruby | JodieGarden/w1d2_homework_2 | /month.rb | UTF-8 | 340 | 3.75 | 4 | [] | no_license | def month(number)
case number
when 1
puts "January"
when 2
puts "Feburary"
when 3
puts "March"
when 4
puts "April"
when 5
puts "May"
when 6
puts "June"
when 7
puts "July"
when 8
puts "August"
when 9
puts "September"
when 10
puts "October"
when 11
puts "November"
when 12
puts "December"
end... | true |
9e79182c2124ac42c32bc815168a4cd347c70599 | Ruby | cgns1122/genre-song-finder | /models/homepage_API.rb | UTF-8 | 2,017 | 3.046875 | 3 | [] | no_license | require_relative 'song.rb'
require_relative 'youtube_scraper.rb'
class HomepageAPI
attr_accessor :songs, :videos, :what_is_genre, :description, :genre, :random
def initialize(genre=nil)
@array = []
if genre != nil
@genre = Echonest::Genre.new('S0XF9YS0UTCYEHQFQ', genre.downcase)
genre = genre.downcase
e... | true |
23da7f8a50ed124128d1959e29c0b5d3554b47b9 | Ruby | aashi0001/ruby-grading-project | /lib/parser.rb | UTF-8 | 1,964 | 3 | 3 | [] | no_license | module Definitions
require_relative "extensions.rb"
class HandyMethods < Tools
class << self
def convert_arr_to_h(arr,_h)
arr.each_with_index{|_,k|_h.merge!("#{k+1}"=>_)}
return _h
end
def add_total_to_h(temp, x)
temp.each_with_index{|k,v| x["#{v+1}"].merge!("total" => k)}
return x
... | true |
2064a06d7aec14b4d651c339d689a73887dbb892 | Ruby | BenRKarl/WDI_work | /w02/d04/Paul_Hiam/library/library.rb | UTF-8 | 660 | 3.40625 | 3 | [] | no_license |
module E_text
def copy_paste
'it worked!'
end
end
module Print_text
def info
'i can be held'
end
end
module Art
def affect_people
'I move you. Aesthetically'
end
end
module Fiction
def plot_twist
'And now all you knew is suddenly wrong'
end
end
module NonFiction
def historical_fact
... | true |
ba63fa83a3b30ca87fe641cbb947dae4aeff7419 | Ruby | benjaminhyw/data-structures-fixed-array-challenge | /fixed_array_spec.rb | UTF-8 | 812 | 3.1875 | 3 | [] | no_license | require_relative 'fixed_array'
describe FixedArray do
let(:array) { FixedArray.new(4) }
describe "new" do
it "initializes an array with the size parameter provided" do
expect(array.size).to eq 4
end
end
describe "set" do
it "raises an error if index is out of bounds"do
expect(array.se... | true |
9f9f8a41ef2d6cf7132c47357a5bc20dc3e59300 | Ruby | domenicode/Ruby-App | /Program.rb | UTF-8 | 2,152 | 3.796875 | 4 | [] | no_license | x=1
puts 'use Help to see a list of commands'
while x == 1
command = gets.chomp.downcase
if command == 'whatsyourname'
puts 'My Name is Joe'
elsif command == 'howareyou'
puts '| |'
puts '_ _'
puts ' -- '
elsif command == 'whatdayisit'
puts 'Today is ' + Time.now.strftime("%A")
elsif command == 'whatt... | true |
b1e4fdf22afa211624ecd808771ca41a8c782a36 | Ruby | BH792/chess_ruby | /old/spec/rook_spec.rb | UTF-8 | 687 | 2.8125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe "Rook" do
board = Board.new
board.board = Array.new(64, 0)
context "valid_moves_rook" do
it "returns array of all valid moves" do
test_rook = Rook.new("black", board).tap { |this| board.board[17] = this }
expect(test_rook.ortho_valid_moves).to eq([1, 9, 16, 18, 19,... | true |
55ece85a4d0267274c20e0d03fa87544fd7ed8a0 | Ruby | firebat75/ruby-hangman | /hangman.rb | UTF-8 | 4,266 | 3.953125 | 4 | [] | no_license | require 'json'
class Hangman
def initialize (lives = 10, guesses = [], right_guesses = [], wrong_guesses = [], progress = [], round = 0, word, original)
'''
New game just needs the word and original arguments
'''
@lives = lives
@guesses = guesses
@right_guesses = rig... | true |
cec3e2507f35af924247f47fd344a863d0e500cf | Ruby | lennhy/oxford-comma-v-000 | /lib/oxford_comma.rb | UTF-8 | 557 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
# join method turns the array into a strings
# and the comma in brackets seperates each string with a comma, the space inside the apostrophees creates a
if array.size == 1
array.join
elsif array.size == 2
array.join(' and ')
elsif array.size == 3
last = array.pop ... | true |
74f7bb3905a8b323020210256f13ecb70b35c597 | Ruby | choltz/devtools | /spec/remote_spec.rb | UTF-8 | 1,162 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
require 'ostruct'
describe Remote do
it "initializes it's connection with a connection path" do
remote = Remote.new "#{Dir.pwd}/spec/data/test_s3.yml"
expect(remote.connection.class).to eq Fog::Storage::AWS::Real
end
it 'returns the latest file in the folder' do
remote = Remote... | true |
ac68d1e8eab41e440d4673a33724f4d3e132a58c | Ruby | topher6345/treddit | /app/models/post.rb | UTF-8 | 1,698 | 2.625 | 3 | [] | no_license | # == Schema Information
#
# Table name: posts
#
# id :integer not null, primary key
# title :string
# body :text
# created_at :datetime not null
# updated_at :datetime not null
# ancestry :string
# ancestry_depth :integer ... | true |
729003dc4d829c03a7d10505caacffe5329e4fce | Ruby | mirrec/kata | /lib/codility/counting_elements/permutation_check.rb | UTF-8 | 895 | 3.34375 | 3 | [] | no_license | # https://codility.com/programmers/task/perm_check/
module Codility
module CountingElements
module PermutationCheck
# O(n)
def solution(a)
uniq_numbers = {}
max = 0
a.each do |element|
if uniq_numbers.key?(element)
return 0
end
uniq_n... | true |
b5d7b84de576affde5dea8c4d8863978ff5ffad1 | Ruby | alphagov-mirror/datainsight-govuk-collector | /lib/govuk_collector.rb | UTF-8 | 619 | 2.765625 | 3 | [] | no_license | require "uri"
require "songkick/transport"
require_relative "message_builder"
class GovUkCollector
def initialize(url, formats)
@url = URI(url)
@message_builder = MessageBuilder.new
@formats = formats
end
def messages
client = Songkick::Transport::HttParty.new(
"#{@url.scheme}://#{@url.... | true |
8549a963189298841a12508e25a83193ede4c2d7 | Ruby | ehanderson/rails-blogs | /emily_blog/app/controllers/posts_controller.rb | UTF-8 | 1,049 | 2.6875 | 3 | [] | no_license | class PostsController < ApplicationController
def new
@post = Post.new #we need an object here upon redering below
end
def create
# render text: params[:post].inspect ###This will give us a params print out
#### .permit allos us to take mult params and deal w validations in this action
@po... | true |
d5d09725ffd5654e9051357edc6b6cd3dd2aa385 | Ruby | cyr-kov/ruby_school | /l13/appl13_1.rb | UTF-8 | 450 | 3.359375 | 3 | [
"BSD-2-Clause"
] | permissive | @hh={}
def add_person opts
puts 'Already exists!' if @hh[opts[:name]]
@hh[opts[:name]]=opts[:age]
end
def show_hash
@hh.keys.each do |key|
age=@hh[key]
puts "Name: #{key}, age: #{age}"
end
end
def remove_hash
@hh.clear
end
loop do
print "Enter name: "
name =gets.strip
if name==''
show_hash
exit
... | true |
4495df51e69bec0931fbd64d09aadc3e4fdabb16 | Ruby | manishkakwani/mad_libs | /mad_libs.rb | UTF-8 | 1,171 | 4.0625 | 4 | [] | no_license | puts "Please enter a paragraph, with words you want to substitute written like this: \"((part of speech))\". Or just press Enter for a sample Mad Lib:"
entry = gets.chomp
if entry.empty?
string = "I had a ((an adjective)) sandwich for lunch today. It dripped all over my ((a body part)) and ((a noun))."
else
strin... | true |
975a213caefd100d5cf3267f1c9d101bd9a54161 | Ruby | Archer70/RubyFizzBuzz | /RubyFizzBuzz/specs/fizz_buzz_spec.rb | UTF-8 | 843 | 3.453125 | 3 | [] | no_license | require_relative "../src/fizz_buzz"
describe FizzBuzz do
before :each do
@fizz_buzz = FizzBuzz.new
end
it "does return 'fizz' for multiples of 3." do
output = @fizz_buzz.get_output_for 3
output.should == "fizz"
end
it "does return 'buzz' for multiples of 5." do
output = @fizz_buzz.get_output_fo... | true |
bddfcea12654d9cf113561e1ba4b6b52329d0856 | Ruby | ArwaMA/FinalProject | /CloneDetectionToolApproach/parser.rb | UTF-8 | 1,037 | 2.828125 | 3 | [] | no_license | #! /usr/bin/env ruby
## This class parses the report generated by NiCad and creates objects of type cloneTool.
load "clonetool.rb"
class Parser
def parsexmlfile(content, clonedata)
regnline = /(?<=nlines=\\\")[\d]+/
regsim = /(?<=similarity=\\\")[\d]+/
regs = /(?<=source file=\\\")[\w\s\/\.\-\_]+/
regstar... | true |
5f18cc6781156eee722cccdd451933b8f1c2385d | Ruby | Eden-Eltume/101 | /101_Exercises/Small_Problems/Easy6/ex10.rb | UTF-8 | 200 | 3.65625 | 4 | [] | no_license | def triangle(num)
num_spaces = num - 1
num_stars = 1
num.times do |n|
puts(" " * (num_spaces) + ("*" * num_stars))
num_spaces -= 1
num_stars += 1
end
end
triangle(5)
triangle(9)
| true |
d98e12f6660e8d4ee321258ef9712a4cd6332286 | Ruby | trizen/sidef | /scripts/Tests/topological_sort.sf | UTF-8 | 1,771 | 2.53125 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Topological_sort
#
func print_topo_sort (deps) {
var ba = Hash.new;
deps.each { |before, afters|
afters.each { |after|
if (before != after) {
ba{before}{after} = 1;
};
ba{after} \\= Hash.new;
}... | true |
2a060e1523abf520cabb7fe08304f556116ef7e0 | Ruby | smaraghi/operators-dc-web-career-01719 | /lib/operations.rb | UTF-8 | 342 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def unsafe?(speed)
if speed > 60 || speed < 40
true
else
#if the speed is not greater than 60 or not less than 40
#then speed is already between 60 and 40. Then we just return
#false in else block.
false
end
end
def not_safe?(speed)
speed < 40 || speed > 60 ? ... | true |
468ad8f5f7ea623efd3ee3903b85f8b4d869fcf0 | Ruby | ABStein/fortune-app | /examples/wed.rb | UTF-8 | 364 | 3.34375 | 3 | [] | no_license | class Shoe
def initialize(input_tied, input_owner, input_side)
@tied = input_tied
@owner = input_owner
@side = input_side
end
def tie
@tied = true
end
def untie
@tied = false
end
end
joshs_shoe = Shoe.new(false, "Josh", "right")
p joshs_shoe
joshs_shoe.tie
... | true |
7cbd67ff15c13d8385f39f252aadfceaffb77f70 | Ruby | RealSilo/ruby | /lib/algorithms/search.rb | UTF-8 | 1,367 | 3.59375 | 4 | [] | no_license | class Search
# scenarios
# if item is present:
# best: O(1), avg: O(N/2), worst: O(N)
# if item is NOT present
# best, avg, worst: O(N)
def unsorted_sequential_search(array, value)
array.each_with_index do |element, i|
return i if element == value
end
false
end
# scenarios
# if ite... | true |
0c7b90e238c059535315c367bf2fd0e2fcd6279b | Ruby | Antaresgames/gamemachine | /server/lib/game_machine/data_store.rb | UTF-8 | 4,195 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require 'forwardable'
require_relative 'data_stores/memory'
require_relative 'data_stores/couchbase'
require_relative 'data_stores/mapdb'
require_relative 'data_stores/redis'
require_relative 'data_stores/jdbc'
require_relative 'data_stores/gamecloud'
module GameMachine
class DataStore
include Singleton
exte... | true |
478e8154f259885615dc79e24764060680e41795 | Ruby | gracepacencia/tts-clucker | /app/controllers/api_controller.rb | UTF-8 | 718 | 2.515625 | 3 | [] | no_license | require 'json'
class ApiController < ApplicationController
def catch
fname = params[:fname]
lname = params[:lname]
email = params[:email]
pword = params[:pword]
p fname + '|' + lname + '|' + email + '|' + pword
test = JSON.generate({'fname'=>fname, 'lname' => lname, 'email' => email, 'pword' => pword});... | true |
e7a142edebd4475c84732a18ab66886d6e3bbae7 | Ruby | alphagov-mirror/govuk-component-guide | /app/models/fixture.rb | UTF-8 | 214 | 2.671875 | 3 | [] | no_license | Fixture = Struct.new(:id, :data) do
def name
id.humanize
end
def pretty_data
JSON.pretty_generate(data).gsub('\\n', "\n ").gsub(/"(\w*)":/, '\1:').strip
end
def data?
data.any?
end
end
| true |
f21b5995a8538acd54860015bf1ab8be9b04be2c | Ruby | mikemoore1618/ruby-code-challenges | /who-likes-it.rb | UTF-8 | 1,779 | 4.46875 | 4 | [] | no_license | # You probably know the "like" system from Facebook and other pages. People can "like" blog posts, pictures or other items. We want to create the text that should be displayed next to such an item.
# Implement a function likes :: [String] -> String, which must take in input array, containing the names of people who li... | true |
42108040f9992d5fec321615d5fa08278055fa9f | Ruby | RubyOnRails-JHU-605-484/Module3 | /5_modify_array.rb | UTF-8 | 358 | 4.0625 | 4 | [] | no_license | # You want a stack (LIFO)? Sure
stack = []
stack << "one"
stack.push ("two")
puts stack.pop # => two
# You meant a queue (FIFO)? We have those too...
queue = []
queue.push "one"
queue.push "two"
puts queue.shift # => one
a = [5,3,4,2].sort.reverse!
p a # => [5,4,3,2] (actually modifies the array)
a[6] = 33... | true |
1eb102e7cfa897830d9f9d86952abdaefa0013b1 | Ruby | tiy-indy-bee-ror-jan17/course_notes | /week4/day2/app.rb | UTF-8 | 1,090 | 3.015625 | 3 | [] | no_license | require_relative 'person'
class App
attr_accessor :env, :path
def initialize(env)
@env = env
@path = env["PATH_INFO"]
# puts env.inspect
end
def response
if Array(env["HTTP_USER_AGENT"]).detect{|agent| agent.include? "Googlebot"}
go_away_google
elsif path.split("/").length == 3
... | true |
202e687a034e7b3fcb923cd17b234fbf482c9e0c | Ruby | badgerlucy/Ruby-Practice | /login.rb | UTF-8 | 682 | 3.921875 | 4 | [] | no_license | input_id = gets.chomp()
def login(id) # 2. 그 다음에 함수를 정의
members = ['lemon', 'apple', 'mint']
for member in members do #for 다음에 오는 member에 members의
#각 원소를 대입하도록 하는 식
if member == id
return true
end
end
return false #원소 개수만큼 반복했음에도 input_id와 일치하는
#원소를 찾지... | true |
ac61520f24182878d0b23539ff0481db3120b961 | Ruby | howardmann/wdi-16 | /warm_up/week_10/day_04/phone.rb | UTF-8 | 1,492 | 4 | 4 | [] | no_license | # # Normalized Phone Number
# * If the phone number is less than 10 digits assume that it is bad number
# * If the phone number is 10 digits assume that it is good
# * If the phone number is 11 digits and the first number is 1, trim the 1 and use the first 10 digits
# * If the phone number is 11 digits and the first nu... | true |
37bd15d7d25df7be0ad4c36e9db5e5888a3dd630 | Ruby | anjaliagg/hands-on-ruby | /test.rb | UTF-8 | 398 | 3.078125 | 3 | [] | no_license | anjali=-4
message= if anjali>0
"Shutup"
else "come on!"
end
puts message
class Spaceship
@@thruster_count=2
def self.thruster_count
@@thruster_count
end
end
class SpritelySpaceship < Spaceship
@@thruster_count=4
end
class AnotherSpaceship < Spaceship
@@thruster_count=1
end
pu... | true |
2bef52da011a7ea75528efe0df8560a6b5706c81 | Ruby | thomashalljr/data_structures | /implementation/graph.rb | UTF-8 | 881 | 3.21875 | 3 | [] | no_license | require_relative "../modules/graph.rb"
graph = Graph::Graph.new
graph.add_node(1)
graph.add_edge(1, 2)
graph.add_edge(1, 3)
graph.add_edge(1, 4)
graph.add_edge(1, 6)
graph.add_edge(2, 3)
graph.add_edge(3, 6)
graph.add_edge(4, 6)
graph.add_edge(5, 6)
graph.add_edge(6, 8)
graph.add_edge(7, 8)
puts ""
puts "has path BFS... | true |
00e419b466b1d989ce51eb863a24a1d2d5f7439e | Ruby | Pablo123GitHub/ruby-kickstart | /session1/challenge/7_string.rb | UTF-8 | 503 | 4.0625 | 4 | [
"MIT"
] | permissive | # given a string, return the character after every letter "r"
#
# pirates_say_arrrrrrrrr("are you really learning Ruby?") # => "eenu"
# pirates_say_arrrrrrrrr("Katy Perry is on the radio!") # => "rya"
# pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr"
def pirates_say_arrrrrrrrr(string)
resu... | true |
40473136b70ddb486c276c093c002edcd8f85757 | Ruby | judywu29/ruby_quizzes | /happy_num.rb | UTF-8 | 1,195 | 3.453125 | 3 | [] | no_license | class HappyNum
Max = 100_000
Unhappy = [0, 4, 16, 20, 37, 42, 58, 89, 145].freeze
def initialize()
@sum_of_digits = {}
end
#compare their ranks and get the highest rank
def happiest_num max=Max
max_rank = 1
happiest_num = 1
(1..max).each do |number|
rank = rank_of_happiess numbe... | true |
3dc9994fe0ef27caa094f3cf18c4c8cae376e7f4 | Ruby | ButeraMV/night_rewriter | /lib/encoder.rb | UTF-8 | 775 | 3.328125 | 3 | [] | no_license | require_relative 'alphabet'
require_relative 'lookup'
class Encoder
include Lookup
attr_reader :alphabet
def initialize
@alphabet = Alphabet.new
end
def encode_to_braille(plain)
output = []
[0,2,4].each do |offset|
encode_letter(plain, offset, output)
output << "\n"
end
enco... | true |
34ac5989c42acd5c187fd2b505fae4bea98d233c | Ruby | jessmar94/bank_tech_test | /lib/display.rb | UTF-8 | 773 | 3.640625 | 4 | [] | no_license | # frozen_string_literal: true
# Display class formats money and date and prints the statement
class Display
attr_reader :transactions
def initialize(transactions)
@transactions = transactions
end
def format_statement
statement = "date || credit || debit || balance\n"
@transactions.each do |transa... | true |
b26f8f3dde9fec02e62d2a1fa263a2ccce93f412 | Ruby | kyrylo/patience | /test/patience/test_tableau.rb | UTF-8 | 2,023 | 2.9375 | 3 | [
"Zlib",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative 'helper'
module Patience
class TestTableauArea < TestCase
def setup
@deck = Deck.new
@tableau = Tableau.new(@deck.shuffle_off! 28)
end
test 'Tableau is a child of Area' do
assert_kind_of Area, @tableau
end
test 'Initial Tableau has 28 cards' do
cards = ... | true |
e496b9050a9580068489b0b419f1bda272733a47 | Ruby | din982/drift | /GEGist.rb | UTF-8 | 1,581 | 2.828125 | 3 | [] | no_license | #
# GEGist.rb
# gisteditor
#
# Created by Greg Borenstein on 6/6/09.
# Copyright (c) 2009 __MyCompanyName__. All rights reserved.
#
class GEGist
attr_accessor :gist_id, :created_at, :title, :body
def self.build_multiple(xml)
xml.rootElement.nodesForXPath("//gists/gist", error:nil).collect do |gist_xml|
... | true |
03592bdbd9945984a2dc5dd0578eb0b0d55a6176 | Ruby | Catkin92/week2_day2_homework | /river.rb | UTF-8 | 246 | 3.546875 | 4 | [] | no_license | class River
attr_reader :name
def initialize(name)
@name = name
@fish = []
end
def fish_count
@fish.count
end
def add_fish_to_river(fish)
@fish << fish
end
def lose_fish(fish)
@fish.delete(fish)
end
end
| true |
bcafc1c11e0632679e9d07b2b1a3cff02082e9ba | Ruby | koji509/oriapp_1 | /spec/models/user_spec.rb | UTF-8 | 2,579 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe User do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー新規登録' do
context '新規登録がうまくいくとき' do
it "すべて正しいフォーマットで入力されていれば登録できる" do
expect(@user).to be_valid
end
end
context '新規登録がうまくいかないとき' do
it "userが空だと登録できない" do
@user.us... | true |
2fb356cf8f8ae82620adf4fc9d2ad7c0e3e8613e | Ruby | lhz/c64-ruby | /lib/c64/helpers.rb | UTF-8 | 1,048 | 2.6875 | 3 | [
"MIT"
] | permissive | module C64
module Helpers
# Generate sine table
def sine_table(samples: 256, start: 0.0, length: 2.0, ampl: 128, to_i: true, base: nil)
ampl = ampl.to_f - 0.001 # Avoid rounding anomaly at min/max
base = (base || ampl).to_f
(0...samples).map do |n|
theta = (start.to_f + (n.to_f/samp... | true |
8a412014f9190818098464ed284bca8c4d133ff3 | Ruby | eihli/testing-notes | /test/library_test.rb | UTF-8 | 1,026 | 3.140625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../lib/library'
require_relative '../lib/book'
class LibraryTest < MiniTest::Test
def test_library_init_attributes
library = Library.new 'San Francisco Public Library'
assert_equal library.name, 'San Francisco Public Library'
end
def test_get_books_from_libra... | true |
c6c374b40341709a5c2a41ab85594b4b974bd99b | Ruby | kwren96/square_array-london-web-career-042219 | /square_array.rb | UTF-8 | 96 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
array2 = []
array.each {|square| array2 << square ** 2}
array2
end | true |
c5db35d9015c21c04b2e1828a23e90f62676acd5 | Ruby | samsamkim/mathgame | /player.rb | UTF-8 | 103 | 2.875 | 3 | [] | no_license | class Player
attr_accessor :lives, :turn
def initialize
@lives = 3
@turn = true
end
end
| true |
5d4c181029dc6f28ee8d55013359d7da17308e96 | Ruby | vijayakumarsuraj/automation | /automation/enums/status.rb | UTF-8 | 359 | 2.609375 | 3 | [] | no_license | #
# Suraj Vijayakumar
# 10 May 2013
#
require 'automation/core/enum'
module Automation
# Represent the status of a result.
class Status < Enum
# Indicates that a task is running.
Running = create(0)
# Indicates that a task's analysis is pending.
Analysing = create(1)
# Indicates that a task ... | true |
964f3aa4586529f1dd59c6e754cc41b875281c0c | Ruby | WHomer/enigma | /test/shift_test.rb | UTF-8 | 533 | 2.71875 | 3 | [] | no_license | require './test/test_helper'
class ShiftTest < MiniTest::Test
def setup
@shift = Shift.new
end
def test_does_it_exist
assert_instance_of Shift, @shift
end
def test_it_will_return_correct_keys
assert_equal :decryption, @shift.characters(:decryption, 'hello', '02715', '040895', '-').keys[0]
a... | true |
683e912b9766122de32f1eff6fddab5e9078b435 | Ruby | ruanwz/tinto | /Lib/Tinto/Sanitizer.rb | UTF-8 | 1,129 | 2.6875 | 3 | [] | no_license | # encoding: utf-8
require 'json'
require 'sanitize'
module Tinto
class Sanitizer
def self.sanitize(input, config = Sanitize::Config::RELAXED)
Sanitize.clean(input, config).to_s
end
def self.sanitize_array(array = [])
array.collect do |item|
case item
when Hash
s... | true |
b77bb5d59bdc208d31a82da64a02c2ad68918fa0 | Ruby | silentorb/archmage-old | /ruby/source/workspace.rb | UTF-8 | 1,191 | 2.625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'library'
require 'unit_loader'
require 'registry'
require 'remote'
class Workspace
private
def Workspace.load_config(workspace_path, config_path)
json = File.read(workspace_path + '/' + config_path)
data = JSON.parse(json)
if data.key? 'includes'
data['includes'].each do... | true |
a3a831d24c8e799c6087de5860f954b800c01cd2 | Ruby | QutEcoacoustics/bioacoustic-workbench | /app/models/permission.rb | UTF-8 | 1,765 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | class Permission < ActiveRecord::Base
extend Enumerize
# relations
belongs_to :user
belongs_to :permissionable, :polymorphic => true
# attr
attr_accessible :user_id, :level, :logged_in, :permissionable_type, :permissionable_id
# userstamp
stampable
belongs_to :user, class_name: 'User', foreign_key:... | true |
5e8d9cdf9cfeabf5bdc359ba1591829c46cc9b01 | Ruby | ElenaParchevskaya/thinknetica_2021 | /lesson_10/train_passenger.rb | UTF-8 | 531 | 2.734375 | 3 | [] | no_license | require_relative 'train'
require_relative 'validation_error'
class TrainPassenger < Train
IDFORMAT = /^([а-я]|\d){3}-*([а-я]|\d){2}$/i.freeze
validate :number, :presence
validate :number, :format, IDFORMAT
DEFAULT_PASSENGERS = 90
def initialize(name, number_carriages)
@type = :passenger
@carriage... | true |
352af5caca7a21619f42559bab68308fb63e1fe5 | Ruby | brandonj2858/OO-mini-project-dumbo-web-080519 | /app/models/Recipe.rb | UTF-8 | 1,293 | 3.03125 | 3 | [] | no_license | class Recipe
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def recipes
RecipeCard.all.map do |recipe_card|
recipe_card.recipe
end
end
def add_ingredients(recipe_ingredient_array)
recipe_ingredient_array.each... | true |
b85415d743ed4044a01dce755e9a07b85ae8d12f | Ruby | nattyvega/ruby_challenges | /method_1.rb | UTF-8 | 52 | 2.546875 | 3 | [] | no_license | def my_method
puts "Hello World"
end
my_method
| true |
3ba2d724d1254b70bb39deed2da2eebe539508f3 | Ruby | compsy/u-can-act | /spec/tools/cookie_jar_spec.rb | UTF-8 | 3,246 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
describe CookieJar do
let(:jar) { {} }
describe 'set_or_update_cookie' do
it 'returns true if all provided params are valid' do
current_cookie = {
response_id: '123',
token: 'whatever'
}
jar[described_class::COOKIE_LOCATION] = current_cookie.to_j... | true |
96c1488b56d1d3e6e48d8014f04c8f766ac87b0a | Ruby | aoushana/dsc-product-scripts | /product-server.rb | UTF-8 | 2,734 | 2.84375 | 3 | [] | no_license | # include dependencies
require 'sinatra'
require "rubygems"
require "json"
require "net/http"
require "uri"
# get '/' do
# 'Hello world!'
# end
# get '/myName' do
# 'Adrena Oushana'
# end
# post '/login' do
# # Handle login
# end
#
# get '/login' do
#
# end
# this creates a new route that can be getted. line... | true |
b48af37e61874c9c3c020a89383d3feb8540e711 | Ruby | jlgavale/rubyPent | /009_condicionales.rb | UTF-8 | 522 | 3.421875 | 3 | [] | no_license | =begin
if la condicion se tiene que cumplir (operadores, comparacion, + operadores logicos)
codigo
elif otra condicion
codigo
else sentendia
codigo
=end
puts "Bienvenidos"
print "Ingresa tu nota => "
nota = gets.chomp.to_i
if nota >10 || nota <0
puts "Nota invalida"
else
if no... | true |
da9b0ab7d4bad0e46c31b31a90663302bd211eed | Ruby | brinkar/crp | /lib/crp/sequence.rb | UTF-8 | 259 | 2.84375 | 3 | [] | no_license | module CRP
class Sequence
def initialize(context)
@context = context
@processes = []
end
def process(&block)
@processes << block
end
def run
@processes.each do |block|
@context.instance_eval &block
end
end
end
end
| true |
c8fdd9964bbe5e1a6a1566f05c20f374cf51f943 | Ruby | omc/jekyll-elasticsearch-boilerplate | /.bundle/gems/ruby/2.2.0/gems/elasticsearch-ruby-0.0.4/lib/elastic_search/response.rb | UTF-8 | 1,218 | 2.546875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | module ElasticSearch
class Response
attr_reader :status
def initialize(options)
@body = options[:body].eql?("") ? "{}" : options[:body]
@status = options[:status].to_i
case @status
when 200..206
when 404
if self.body['error'] =~ /^IndexMissingException/ || self.body.eql... | true |
5897cac391df93cefa1817617fb990f72943d8de | Ruby | kitpao/Bubble_Sort_Algorithm | /bubble_sort.rb | UTF-8 | 834 | 3.9375 | 4 | [] | no_license | # frozen_string_literal: true
def bubble_sort(arr)
return arr if arr.size <= 1
len = arr.size - 1
while len >= 1
position = 0
len.times do |i|
if arr[i] > arr[i + 1]
arr[i], arr[i + 1] = arr[i + 1], arr[i]
position = i
end
end
len = position
end
arr
end
def bub... | true |
7a306441e8f49ad2bb366b39d3939f737314c015 | Ruby | karen-lo/CardGame | /specs/deck_spec.rb | UTF-8 | 3,516 | 3.5 | 4 | [] | no_license | # /specs/deck_spec.rb
# Specs for the Deck class
require_relative '../lib/deck'
require_relative 'deck_spec_helper'
describe Deck do
describe ".new" do
context "given no parameters" do
it "returns a Deck" do
expect(Deck.new).to be_truthy
end
end
end
describe ".pass_out_hands" do
... | true |
5d3c38a0bbe3a6d87ae3bdcf807effb085ed4e0c | Ruby | emgreen33/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 3,783 | 4.5 | 4 | [] | no_license | # Alias Manager Prgoram
# - define a method to make an alias name that takes a name string as a paramater
# - split the string of names into an array of words
# - swap the first and last names (helper method)
# - split the array of names into an array of letters
# - create two arrays: 1) consonants 2)vo... | true |
209829731f852a19f76d656b9356def9a73ef10f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/9a5a849c34184342873187d0b9fc9f86.rb | UTF-8 | 300 | 3.796875 | 4 | [] | no_license | class Anagram
def initialize(word)
@letters = Letters.from_word(word)
end
def match(words)
words.select { |w| anagram?(w) }
end
private
def anagram?(word)
@letters == Letters.from_word(word)
end
end
class Letters
def self.from_word(word)
word.chars.sort
end
end
| true |
4f47255bf4e7a3b10fcc4bd0757adbc0b7554e6b | Ruby | alirezaandersen/black_thursday | /test/invoice_repository_test.rb | UTF-8 | 9,678 | 2.703125 | 3 | [] | no_license | require 'test_helper'
require 'invoice_repository'
require 'invoice'
class InvoiceRepositoryTest < Minitest::Test
def test_by_default_has_no_invoices
invr = InvoiceRepository.new
assert_equal 0, invr.all.length
end
def test_can_load_a_single_invoice
inv = Invoice.new({
:id => 6,
:cu... | true |
2c326d9c2a70c0c4bfcc44306e5b32d0d496dc72 | Ruby | renderedtext/kamisama | /lib/kamisama/respawn_limiter.rb | UTF-8 | 823 | 2.890625 | 3 | [
"MIT"
] | permissive | class Kamisama::RespawnLimiter
def initialize(respawn_limit, respawn_interval)
@respawn_limit = respawn_limit
@respawn_interval = respawn_interval
@respawns = []
end
def record!
now = Time.now.to_i
@respawns = @respawns.select { |timestamp| timestamp >= now - @respawn_interval } + [now]
... | true |
f29fff62ea26c507ac55592b63013303e5ba9a7b | Ruby | camfilho/my-exercism-track | /ruby/isogram/isogram.rb | UTF-8 | 180 | 3.46875 | 3 | [] | no_license | module Isogram
LETTERS = /[a-z]/.freeze
def self.isogram?(word)
letters = word
.downcase
.scan(LETTERS)
letters == letters.uniq
end
end
| true |
154e743eabab1ab6f225fb8395136a1a50cbc656 | Ruby | duritong/puppet-ibox_modules | /ib_tor/lib/puppet/parser/functions/get_balanced_nagios_hosts.rb | UTF-8 | 2,789 | 2.65625 | 3 | [] | no_license | module Puppet::Parser::Functions
newfunction(:get_balanced_nagios_hosts, :type => :rvalue, :doc => <<-EOS
Generates a hash that will contain nagios_host resources to be balanced.
Argmuents are a path where the different onion services are stored, as well as a
hash, consisting of all the services and there nagios che... | true |
5a10c8668809ab939178f496bcc20c51cbc4df7c | Ruby | CodingDojoDallas/ruby_dec_16 | /Woodall_Robert/assignments/ruby_oop/wizard_ninja_samurai/samurai.rb | UTF-8 | 717 | 3.484375 | 3 | [] | no_license | require_relative "human"
class Samurai < Human
@@samurai_count = 0
attr_accessor :health
def initialize
super
@health = 200
@@samurai_count += 1
self
end
def death_blow(obj)
if (obj.class.ancestors.any? { |i| i == Human })
puts "attacking with death_blow..."
obj.health = 0
else
puts "Huma... | true |
6cf55d6098bc8c8a6b5a5e3aef1afa054d103c36 | Ruby | loancarcamoh7196/Latam_desafio | /Hashes/ejercicio_2.rb | UTF-8 | 310 | 3.328125 | 3 | [] | no_license | productos = {'bebida' => 850, 'chocolate' => 1200, 'galletas' => 900, 'leche' => 750}
#1
productos.each { |producto, valor| puts "#{producto} : $#{valor}" }
#2
productos['cereal'] = 2200
#3
productos['bebida'] = 2000
#4
array_productos = productos.map
puts array_productos
#5
productos.delete('galletas')
| true |
06146489ca6f8dbc79bf198fc463b4566d504df4 | Ruby | fictionalparakeets/ruby_math_game | /questions.rb | UTF-8 | 265 | 3.5625 | 4 | [] | no_license | class Questions
def initialize
@nums = Array(1..50)
end
def give_question
first_num = @nums.sample
second_num = @nums.sample
output = "What is #{first_num} + #{second_num}?"
answer = first_num + second_num
[output, answer]
end
end
| true |
db78e6f811201f02f17a134462e528e1432f2221 | Ruby | box2-/nahum_destroyer | /kill2.rb | UTF-8 | 4,697 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env ruby
################################################################################
# ruby >=1.9
#
# This bot requires:
# -- apt-get install ruby ruby-dev
# -- gem install eventmachine
#
# We are all sick of nahums shit, so this bot checks at random intervals to see
# if nahum has been "contributing" t... | true |
b037547ddad194531e816068b137563c446be14f | Ruby | tskupinski/marcus | /spec/marcus_commands/restock_spec.rb | UTF-8 | 967 | 2.578125 | 3 | [] | no_license | require 'marcus_commands/restock'
require 'machine'
require 'printer'
RSpec.describe MarcusCommands::Restock do
let(:machine) { Machine.new(Inventory.new, Treasury.new, printer) }
let(:printer) { Printer.new }
before { machine.inventory.products = [Product.new('Mars', 100, 10)] }
context 'when the selected p... | true |
d53de501be8bf377c740553a5d7966212e769410 | Ruby | EFulmer/project_euler | /ruby/problem_1.rb | UTF-8 | 211 | 3.78125 | 4 | [] | no_license | # one-liner
puts ((1..999).select { |n| n % 3 == 0 or n % 5 == 0 }).inject(0) { |x, y| x + y }
# slightly cleaner
mults = (1..999).select { |n| n % 3 == 0 or n % 5 == 0 }
puts mults.inject(0) { |x, y| x + y }
| true |
c8c5d4804c41e720eb00c69b5104cb85f036105d | Ruby | jmichaeln5/coding_challenge_1 | /spec/smallest_absent_int_spec.rb | UTF-8 | 650 | 2.75 | 3 | [] | no_license | class TestArray < Test::Unit::TestCase
def test_arrays
# simple cases
assert_equal( 4, smallest_absent_int([1,2,3]))
assert_equal( 4, smallest_absent_int([3,2,1]))
assert_equal( 2, smallest_absent_int([1,3,4]))
assert_equal( 2, smallest_absent_int([4,1,3]))
assert_equal( 1, smallest_absent_int... | true |
350bf48eed5b7ecf1f4027484342893426139497 | Ruby | unabl4/AoC | /2017/day6/part1/memory_reallocation.rb | UTF-8 | 649 | 3.203125 | 3 | [] | no_license | def redistribution_count(banks)
h = {}
c = 1 # number of redistribtions
b = banks.dup # copy
n = banks.size # number of banks
loop do
# first - select the bank with the most blocks
v = b.max # max value (number of blocks)
i = b.index(v) # bank index
b[i] = 0 # reset count
# redistri... | true |
e5aa6db6597c0d92b870bef5c162a3edf1a541eb | Ruby | davidbliu/pbl-portal-new | /app/models/parse_trello_list.rb | UTF-8 | 2,217 | 2.546875 | 3 | [] | no_license | require 'trello'
class ParseTrelloList < ParseResource::Base
fields :name, :list_id, :board_id, :board_name
def self.due_string(due)
if due
due = due+ Time.zone_offset("PDT")
return due.strftime("%l:%M %p %a %m/%d/%y")
end
return ''
end
def self.list_hash
# a = Rails.cache.read('trello_list_hash')... | true |
3b763e20c7f59e013eabeba7c083371d32e51c17 | Ruby | alejandroereyes/pig | /lib/leaderboard.rb | UTF-8 | 434 | 3.078125 | 3 | [] | no_license | class Leaderboard < ActiveRecord::Base
def self.top_players
all_winners = Leaderboard.group(:name).sum(:score)
puts ""
puts "TOP PLAYERS"
puts "***********"
puts "Name Score"
puts "-----------"
all_winners.sort_by{ |k, v| v}.reverse.take(5).each { |pair| puts pair.join(" - ")}
end
d... | true |
6b308cb829ae18086ddd9310b148bd7027e977ca | Ruby | gangelo/Splattr | /lib/splattr/operators/bitwise_operator.rb | UTF-8 | 544 | 2.734375 | 3 | [] | no_license | require 'splattr/operators/validatable'
require 'splattr/operators/base_operator'
require 'splattr/exceptions'
module Splattr::Operators
class BitwiseOperator < BaseOperator
extend Validatable
def initialize(operator)
super operator
end
def operator=(value)
raise Splattr::Exceptions::InvalidOperatorEx... | true |
73c8018a1af98f40a59b62f04a4420b3bf3e69b5 | Ruby | imonirr/utils | /bashScripts/rscripts/oldones/backup/update-ringid.rb | UTF-8 | 7,263 | 2.546875 | 3 | [] | no_license | #! /usr/bin/env ruby
require './build-methods.rb'
# DEFAULTS
# HANDLE USER INPUTS
_TARGET = (ARGV[0] ? ARGV[0] : 'dev')
puts "\nUpdating default target: ".yellow + _TARGET.blue
TARGET = prompt(_TARGET, "To select default just press ENTER or your desired TARGET(dev/live): ".yellow)
_PROTOCOL = (ARGV[1] ? ARGV[1] : ... | true |
8d43bdfa48fe8f07d225b12a253174e087554324 | Ruby | tdooner/cwru-eecs393-project | /lib/zombie_game/plugin.rb | UTF-8 | 1,052 | 2.75 | 3 | [] | no_license | module ZombieGame
class Plugin
# Class Methods
class << self
##
# This are the magical methods we will define to provide a nice Domain
# Specific Language for plugin authors.
#
# Since all Plugins will extend ZombieGame::Plugin, they can use these
# methods as the way of in... | true |
28303c75a85aa2aa319728baab6f94c76aca7c18 | Ruby | yuumi3/book_store | /app/models/cart.rb | UTF-8 | 303 | 2.6875 | 3 | [] | no_license | class Cart < ApplicationRecord
belongs_to :user
belongs_to :book
validates_numericality_of :quantity, greater_than: 0, only_integer: true
def sub_total
self.book.price * self.quantity
end
def self.total(user)
user.carts.reduce(0) {|total, cart| total + cart.sub_total}
end
end
| true |
87b451755544137d79f4969fef45dd66e2dbed3e | Ruby | YujohnNattrass/ruby_small_problems | /medium2/unlucky_day.rb | UTF-8 | 179 | 3.390625 | 3 | [] | no_license | require 'date'
def friday_13th(year)
(1..12).count { |month| Date.new(year, month, 13).friday? }
end
p friday_13th(2015) == 3
p friday_13th(1986) == 1
p friday_13th(2019) == 2 | true |
dc7dd6abb6c5ab2e026d6deeeabfa81c3650a542 | Ruby | todayiamdaisy/ruby-challenges | /if_else.rb | UTF-8 | 746 | 3.875 | 4 | [] | no_license | if 1 + 1 ==2
puts "1 and 1 does indeed equal 2"
end
my_name = "Skillcrush"
if my_name == "Skillcrush"
puts "Hello, #{my_name}!"
end
my_name = "Alicia"
if my_name == "Skillcrush"
puts "Hello, #{my_name}!"
else
puts "Oops, I thought your name was Skillcrush. Hello, #{my_name}!"
end
fav_color = "turq... | true |
ec4b109120b5d20c37b04241466fa95d42526b12 | Ruby | cblokker/gov | /app/helpers/nytimes_helper.rb | UTF-8 | 5,507 | 3.03125 | 3 | [] | no_license | require 'net/http'
require 'json'
require 'open-uri'
module NytimesHelper
class << self
attr_accessor :url, :parsed_reply
API_KEY = ENV['ARTICLE_SEARCH']
BASE_URI = 'http://api.nytimes.com/svc/search/v2/articlesearch.json?'
CONGRESS_KEY = ENV["CONGRESS_KEY"]
def get_congress
congress_people = Array.new... | true |
abac6c17318a002bf72a14b90fbbb74f4bcf1a96 | Ruby | cihaks/StJosephsWorkers | /app/models/course_search.rb | UTF-8 | 2,167 | 2.53125 | 3 | [] | no_license | # == Schema Information
# Schema version: 20110331225232
#
# Table name: course_searches
#
# course_id :integer
# from_date :date
# to_date :date
#
# TODO: revamp with validates_date method?
class CourseSearch < ActiveRecord::Base
def self.columns() @columns ||= []; end
def self.column(name, sql_type = nil, d... | true |
1e3a1eb6a5b89fef4732a5542e24d012f6d2a487 | Ruby | dustinsmith1024/bracket | /app/models/tournament.rb | UTF-8 | 5,552 | 2.875 | 3 | [] | no_license | class Tournament < ActiveRecord::Base
has_many :games
belongs_to :user
has_and_belongs_to_many :tags
def clear
Participant.destroy self.games.collect{|g|g.participants}
Game.destroy self.games
end
def tag_by_kind(kind)
if self.tags.empty?
nil
else
self.tags.find_by_kind(kind).i... | true |
2b026c17a7cf97f00d8641e39e24d771661a5773 | Ruby | svgiridharreddy/ruby_practice | /overloading.rb | UTF-8 | 781 | 4.1875 | 4 | [] | no_license | class RubyOverload
def my_method(a,b)
puts "I am from method 2"
end
def my_method(a)
puts "I am from method 1"
end
end
r = RubyOverload.new
r.my_method(10,20)
class Person
def print_details(name)
"Hey My Name is #{name}"
end
def print_details(name,age)
"Hey My Name is #{name} and #{age}"
end
end
... | true |
edbad7a2e5a93ab8f2e88964095cc7b69f6e51dc | Ruby | v9n/cracking_the_coding_interview | /lib/algorithms/graph_processing/depth_first_order.rb | UTF-8 | 710 | 3.171875 | 3 | [
"MIT"
] | permissive | module Algorithms
module GraphProcessing
class DepthFirstOrder
def initialize(graph)
@graph = graph
execute
end
def pre
@pre.clone
end
def post
@post.clone
end
private
def execute
@marked = Array.new(@graph.size_vertices)... | true |
fed36fdf775c22208175c4e074ab173e44529ddc | Ruby | dremagic/reverse-each-word-001 | /reverse_each_word.rb | UTF-8 | 161 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
array_sentence = sentence.split(" ")
array_reverse = array_sentence.collect {|word| word.reverse}
array_reverse.join(" ")
end | true |
ac542010ce503300b786901f787ee4fbe1a8cc25 | Ruby | paranoicsan/gtsapp | /app/models/branches/website.rb | UTF-8 | 735 | 2.578125 | 3 | [] | no_license | # encoding: utf-8
# == Schema Information
#
# Table name: branches_websites
#
# id :integer not null, primary key
# name :string(255)
#
# Indexes
#
# index_branches_websites_on_id (id)
#
require 'uri'
class Branches::Website < ActiveRecord::Base
has_and_belongs_to_many :branches, join_table: 'branche... | true |
877d6315b93efdb33b2a650fe7baa8cc2f3a2761 | Ruby | ciousiaocing/leetcode-ruby | /algorithms/plus_one.rb | UTF-8 | 425 | 4.03125 | 4 | [] | no_license | # https://leetcode.com/problems/plus-one/
# Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.
#
# You may assume the integer do not contain any leading zero, except the number 0 itself.
#
# The digits are stored such that the most significant digit is at the head of the ... | true |
6b9af70f77db77de4dbdf86c2faaf31168d3072a | Ruby | marcusmyers/rubyonrailsclass | /week2/labs/lab1.5.rb | UTF-8 | 60 | 3.03125 | 3 | [] | no_license | nums = [1,2,3,4,5,6,7,78,99]
nums.each { |num| puts num }
| true |
43f88a8555f3d4bc3ea8956ca2bf035659901823 | Ruby | ymhuang0808/ruby-self-practice | /range_tricky.rb | UTF-8 | 193 | 3.3125 | 3 | [
"Unlicense"
] | permissive | digits = -1..9
puts digits.include?(5)
puts digits.min
puts digits.max
puts digits.reject {|i| i < 5}
puts digits === 2
puts digits === 3.1415
puts ('a'..'g') === 'c'
puts ('a'..'g') === 'i' | true |
dafe5c78001b65ed7c1467e191bd1cae88dd6d07 | Ruby | kbs5280/chisel | /test/chisel_test.rb | UTF-8 | 346 | 2.515625 | 3 | [] | no_license | gem 'minitest', '~>5.2'
require 'minitest/autorun'
require 'minitest/pride'
require './lib/chisel.rb'
require 'pry'
class ChiselTest < Minitest::Test
def test_it_can_read_a_text_sample
chisel = Chisel.new
assert_equal "This is the first line of the paragraph. This is the second line of the paragraph.", chis... | true |
8a5cb338cb670ba5bb276a6173f59a6ee545f986 | Ruby | johnisom/ruby-challenge-problems | /advanced_1/ocr_numbers.rb | UTF-8 | 1,227 | 3.3125 | 3 | [] | no_license | # frozen_string_literal: true
# ocr digit recognization class
class OCR
NUMS = { " _\n| |\n|_|" => '0', " _ \n| |\n|_|" => '0',
" |\n |" => '1', " \n |\n |" => '1',
" _\n _|\n|_" => '2', " _ \n _|\n|_ " => '2',
" _\n _|\n _|" => '3', " _ \n _|\n _|" => '3',
"|_|\n |... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.