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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b0e2b4fcd2e5620ffca97ad543116e0a35a583a3 | Ruby | skirkpatrick/iSite | /tools/average.rb | UTF-8 | 908 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env ruby
if ARGV.size < 2
puts "USAGE: ./average.rb <input files> <output file>"
exit
end
ifile = Array.new
for i in (0..ARGV.length-2)
ifile.insert(-1, File.open(ARGV[i], "r"))
end
ofile = File.open(ARGV[-1], "w+")
sums = Array.new(19, 0)
nvals =0
header = "JOBID subfuncProb asymmetry self... | true |
1f7f86407220d988bfb36047d49b083b0309059c | Ruby | cvent/windows-server-info | /lib/windows_server_info/cli.rb | UTF-8 | 2,139 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | require 'windows_server_info/checks'
require 'colorize'
require 'thor'
module WindowsServerInfo
class Cli < Thor
class_option :username, type: :string, required: true
class_option :password, type: :string, required: true
no_commands do
@@config_types = [
Checks::ScheduledTasks,
Ch... | true |
e564cc390463b42bf581d0a110ff280d5ecd2bf3 | Ruby | CelesteComet/Launch-School | /challenges/Pascal/pascals_triangle.rb | UTF-8 | 901 | 3.671875 | 4 | [] | no_license | class Triangle
attr_reader :rows
def initialize(steps)
@rows = [[1]]
@steps = steps
@rows = create_row(@rows)
end
private
def create_row(previous_row)
# stop recursion once function creates the necessary number of rows.
if @steps == @rows.length
return @rows
end
# leng... | true |
e3ed7b2a2943f37f03da2af6ef17a97543dfb372 | Ruby | inglesp/ruby-crash-course | /examples/minitest_testing/test/functions_2_test.rb | UTF-8 | 2,038 | 3.390625 | 3 | [] | no_license | require 'minitest/autorun'
require 'functions_2'
class FunctionsTests < Minitest::Test
def test_is_longer_than?
assert_equal(false, is_longer_than?("fish", "fingers"))
assert_equal(true, is_longer_than?("fingers", "fish"))
assert_equal(false, is_longer_than?("fish", "fish"))
end
def test_is_uppercas... | true |
b8cc07bff31e68859664b8eb82b75d3337ce54f3 | Ruby | edwardloveall/bestiary | /lib/bestiary/attributes/aura.rb | UTF-8 | 705 | 2.828125 | 3 | [
"LicenseRef-scancode-ogl-1.0a",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Bestiary::Attributes::Aura
attr_reader :title, :dc, :feet, :rounds, :minutes
def initialize(title:, dc: nil, feet: nil, rounds: nil, minutes: nil)
@title = title
@dc = dc
@feet = feet
@rounds = rounds
@minutes = minutes
end
def ==(other)
title == other.title &&
dc == other.dc... | true |
0b980a114c89d581575d5a7fd6d96dc6680bf736 | Ruby | cloudcity/deathstare-demo-test | /lib/widget_fake/widget.rb | UTF-8 | 340 | 2.515625 | 3 | [] | no_license | require 'faker'
module WidgetFake
class Widget
attr_reader :device
def initialize(device)
@device = device
@title = Faker::Commerce.product_name
@description = Faker::Company.catch_phrase
end
def to_h
{
title: @title,
description: @description
}
... | true |
a7600df06bac4aa1348c6aca2094c337cc3b9e3a | Ruby | vladveterok/ruby | /learning/roman_numerals_to_numbers.rb | UTF-8 | 877 | 4.1875 | 4 | [] | no_license | def roman_to_integer roman
digit_vals = {'i' => 1,
'v' => 5,
'x' => 10,
'l' => 50,
'c' => 100,
'd' => 500,
'm' => 1000}
total = 0
prev = 0
index = roman.length - 1
while index >= 0
# Find a separate character
c = roman[index].downcase
#find and pick value of this character
... | true |
3de8f7a140beea46becaa72e847f77840a7d7c82 | Ruby | swistak35/Frog-in-the-Fog | /waves/wave_5_circle.rb | UTF-8 | 490 | 2.65625 | 3 | [
"MIT"
] | permissive | class Wave5Circle < Wave
@@waves << self
Min = 7600
Max = 11350
def generate_enemies
3.times do |k|
x = 190 + 300*k
10.times do |i|
y = -40 - i*40
d = (i % 2 == 0 ? :right : :left)
q = EnemyCircle.new(@game, x, y, {
hit_points: 40.0,
... | true |
db217baaf4f0e653a056313b023f6740d354d9a3 | Ruby | katahirado/kkfoodstuff | /app/models/search_content.rb | UTF-8 | 2,086 | 2.59375 | 3 | [
"MIT"
] | permissive | class SearchContent < ActiveRecord::Base
belongs_to :recipe
validates :origin_title, presence: true
validates :origin_content, presence: true
before_save :analyze_title_and_content
scope :fulltext_search, ->(query_array) {
conditions = query_array.map { |q|
where("match(search_contents.title,sear... | true |
20a495171b0a3f9d38374f41b52c7a8cc3e3d772 | Ruby | biagioo/oo-my-pets-onl01-seng-ft-021020 | /lib/owner.rb | UTF-8 | 969 | 3.546875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Owner
attr_reader :species, :name
@@all = []
def initialize(name)
@name = name
@species = "human"
save
end
def say_species
"I am a #{@species}."
end
def save
@@all << self
end
def self.all
@@all
end
def self.count
self.al... | true |
f6d1c60612207a0afa8d56474a30d949915c33f5 | Ruby | cassandre5/product-owner-upskilling-challenges | /05-api-consumption/02-sinatra-web-app/app.rb | UTF-8 | 1,767 | 2.5625 | 3 | [] | no_license | require "json"
require "rest-client"
require "sinatra"
require "sinatra/link_header"
require "sinatra/reloader" if development?
enable :static
# -----------------------retrieve all the activities from the API----------------
get "/" do
# -------- appel API de toutes les catégories pour afficher les filtres--------... | true |
3818dcd8585c0b54f007ce5305e11a9abcc91ef3 | Ruby | andyhartland/ezproxy-temp | /lib/ezproxy/loader/base.rb | UTF-8 | 428 | 2.515625 | 3 | [
"MIT"
] | permissive | module EZproxy
module Loader
# The base class for EZproxy stanza loaders
class Base
attr_accessor :transformer
def initialize(transformer: nil, &block)
self.transformer = transformer || block
end
def load(url)
raise NotImplementedError
end
def stanza(url)... | true |
39a3ae56940f2039af1ca3533969156110abc004 | Ruby | Liusos/CC_Ruby_maraton | /model.rb | UTF-8 | 692 | 3.515625 | 4 | [] | no_license | require 'csv'
class Question
attr_accessor :question, :answer
def initialize(question, answer="")
@question = question
@answer = answer
end
end
class Record
def read
question_list = []
CSV.foreach('cards.csv') do |row|
question_list << Question.new(row[0], row[1])
end
question_list
end
... | true |
7e0919b29b8df683bdf571b03e238a41cc738610 | Ruby | drothschild/phase-0 | /week-5/gps2_2.rb | UTF-8 | 3,855 | 4.34375 | 4 | [
"MIT"
] | permissive |
# create a new (empty) list
# add an item and optional quantity
# remove an item list
# Update quantity
# Print
# view the list
# Method create_list
# Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# create new list
# LOOP Through Items on Lis... | true |
a341ceb3c1b2af57e75605238e6fd8aa78da62ea | Ruby | chadmetcalf/reek | /spec/reek/smells/instance_variable_assumption_spec.rb | UTF-8 | 4,241 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative '../../spec_helper'
require_lib 'reek/smells/instance_variable_assumption'
RSpec.describe Reek::Smells::InstanceVariableAssumption do
describe 'warning' do
context 'smell line' do
it 'should report the lines' do
src = <<-EOS
class Dummy
def test
... | true |
d66059766cd83d660f03aeb1a9d6aabaa3a12068 | Ruby | torpedo-t/reverse-each-word-onl01-seng-ft-021020 | /reverse_each_word.rb | UTF-8 | 315 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
original_array = sentence.split(" ") #created original_array to set it equal to sentence.split(" ")
return_array = [] #created return_array to set it equal to an empty array
original_array.collect do |sentence|
return_array << sentence.reverse
end
return_array.join(" ")
end
| true |
5163454d496040b99766471ddff10ddf19d1228e | Ruby | ynonp/secure-code-demos | /03_Crypto/lab_passwords/app_starter.rb | UTF-8 | 439 | 2.546875 | 3 | [] | no_license | require 'sinatra'
require 'sqlite3'
db = SQLite3::Database.new "users.db"
get '/' do
erb :index
end
post '/login' do
db_details = db.execute("SELECT password FROM users WHERE login = ?",
params[:email]).first
login_fail unless db_details
db_password = db_details.first
password = params[:passw... | true |
0c51a42e500ce529788828525e456b118c98076e | Ruby | klbennett/triangle-classification-london-web-082718 | /lib/triangle.rb | UTF-8 | 642 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Triangle
# write code here
attr_accessor :equilateral, :isosceles, :scalene
attr_reader :a, :b, :c
def initialize(a, b, c)
@a = a.to_f
@b = b.to_f
@c = c.to_f
end
def kind
raise TriangleError, 'Sum of two sides must be greater than the third.' if a + b < c || b + c < a || a + c <... | true |
bd1f03874fe0a4619b86428fd8db56247c20025a | Ruby | Jmonzon0415/Phase-0 | /week-5/gps2_2.rb | UTF-8 | 2,419 | 4.34375 | 4 | [
"MIT"
] | permissive | #Psuedocode
# Define a method that makes hash
# create a new list
# item, quantity
def new_list(item, quantity)
groceries_list = {item => quantity}
end
groceries_list = new_list("lemonade", 2 )
#pseudocode
# define a method that adds an item to our list
# add a key/value pair to our existing list
# output up... | true |
c359134fa69e9fad15324cdd35e0898bbcb2351a | Ruby | sumeetkr/katas | /Katas_in_Java/features/steps/two_sum_problem_solver_steps.rb | UTF-8 | 287 | 2.546875 | 3 | [] | no_license | require 'rspec'
require "java"
require 'Katas_In_Java.jar'
java_import Java::Katas.TwoSumProblemSolver
puts "Hello from ruby"
Given /I have a calculator/ do
end
When /I add the numbers (\w+) and (\w+)/ do |first_number, second_number|
end
Then /I get (\w+)/ do |result|
end | true |
ab406a28f87cfe3c413f501e4953e8ee56179929 | Ruby | eyaltoledano/sinatra-logging-in-and-out-online-web-pt-021119 | /app/helpers/helpers.rb | UTF-8 | 205 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Helpers
def self.current_user(session_hash)
@user = User.where(id: session_hash[:user_id]).first
end
def self.is_logged_in?(session_hash)
true if !!session_hash[:user_id]
end
end
| true |
4a57aeac2660fb530796a9b81ca7756ade937751 | Ruby | ohboyd/code_challenges | /25_string_segmentation.rb | UTF-8 | 1,015 | 4.5625 | 5 | [] | no_license | # String Segmentation
# Write a method that segments a given string. The parameters to the method are the string, a set containing words.
# Example
# Input : applepie
# Output : apple pie
# Set dictionary consists of apple, pear, pier, pie.
require 'pry'
def dict(str)
['apple', 'pear', 'pier', 'pie'].include?(s... | true |
6857838068d9cdf6fe63919cfeca817b3d0e2ed7 | Ruby | richard6428/Clases_Bootcamp | /Ruby/Ejercicios_Ruby.rb | UTF-8 | 1,470 | 3.09375 | 3 | [] | no_license | Calcular las notas y su promedio ?
nota1 = gets.chomp.to_f
nota2 = gets.chomp.to_f
nota3 = gets.chomp.to_f
nota4 = gets.chomp.to_f
suma = (nota1 + nota2 + nota3 + nota4) / 4
mes = gets.chomp
dia = gets.chomp.to_i
if (dia >= 21) or (dia <= 18) and (mes == "enero") or (mes == "febrero")
puts "Su signo es Acuario"
... | true |
39d7a88eac7ef41a3c3a2ddc10b83291f5d1ebd8 | Ruby | benburkert/community_shelf | /app/models/book.rb | UTF-8 | 2,152 | 2.53125 | 3 | [] | no_license | class Book
include DataMapper::Resource
## Properties
property :id, Serial
property :isbn, String, :length => 13, :nullable => false
property :created_at, DateTime, :nullable => false, :index => true
property :updated_at, DateTime, :n... | true |
8960e6eb9accf1446630ab64d3c3a80b20930c64 | Ruby | mquan/grammar_cop | /lib/grammar_cop/sentence.rb | UTF-8 | 1,092 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'grammar_cop/link_grammar'
module GrammarCop
class Sentence
extend LinkGrammar
def self.create(text, dictionary)
create_sentence(text, dictionary)
end
def self.parse(sentence, options)
parse_sentence(sentence, options)
end
def self.destroy(sentence)
delete_sent... | true |
2a02267e8f549b18a5d304b0532224cf8e9669b1 | Ruby | K-Sato1995/ruby_dojo | /RefactoringGuide/use_default_value.rb | UTF-8 | 272 | 3.09375 | 3 | [] | no_license | ## Before
module TwoFer
def self.two_fer(name = '')
if name.empty?
'One for you, one for me.'
else
"One for #{name}, one for me."
end
end
end
## After
module TwoFer
def self.two_fer(name = 'you')
"One for #{name}, one for me."
end
end
| true |
35de003e5caa89a22ac9ba9c067ee4351480bc8f | Ruby | DamirSvrtan/fasterer | /spec/support/analyzer/19_proc_call_vs_yield.rb | UTF-8 | 501 | 3 | 3 | [
"MIT"
] | permissive | # Should detect only the block.call, not the others.
def call_me(number, zumba, &block)
4.call
[1,2].call
block.call
b.call
abakus(:red).calling()
end
# Should detect only the first block call.
def call_meeee(number, zumba, &block)
block.call()
block.call
end
# Shouldn't detect the block call since it i... | true |
dee76516e41f3d54739c4f6d05027e976d4e015a | Ruby | poymanov/railswinter2017 | /np1/lesson05/task-05-06.rb | UTF-8 | 3,200 | 3.296875 | 3 | [] | no_license | # encoding: utf-8
# Получаем текущее время
time = Time.now
# Получаем текущее время суток
hours = time.hour
# Время пробуждения персонажа зависит от текущего времени суток
if (hours <= 7)
puts "Вы проснулись рано утром"
elsif (hours > 7 && hours <= 12)
puts "Вы проснулись утром"
elsif (hours > 12 && hours <= 15... | true |
e020778039ee0239826c5f192e5c2f5c77386c40 | Ruby | destinyd/shenmajia | /lib/get_ip.rb | UTF-8 | 515 | 2.5625 | 3 | [] | no_license | class GetIp
require 'net/http'
attr_accessor :ip,:json
def initialize ip
@ip = ip
@uri = URI.parse "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=#{@ip}"
end
def city
get_content
@city = @json["city"]
end
def get_content
return if @json
@log = Rails.logger
... | true |
bad5ceaa978d092d8ffaf0221f8557457501dd9b | Ruby | kanishkakumar408/Training | /ruby/Iterator/times.rb | UTF-8 | 29 | 2.515625 | 3 | [] | no_license | 7.times do |i|
puts i
end
| true |
c5b039fdd4adbe1031e7d10150f124a8abcd3cb3 | Ruby | Lykos/SquirrelDB | /lib/ast/common/unary_operation.rb | UTF-8 | 518 | 2.625 | 3 | [] | no_license | require 'ast/common/function_application'
module SquirrelDB
module AST
class UnaryOperation < FunctionApplication
def initialize(operator, inner, type=nil)
super(operator, [inner], type)
end
alias :operator :variable
def inner
@arguments[0]
end
... | true |
d7e9c33e559982990ea7c7679dc36686453246bc | Ruby | philipjkim/progruby19 | /ch17/sjis.rb | UTF-8 | 228 | 2.609375 | 3 | [] | no_license | # encoding: sjis
require_relative 'iso-8859-1'
require_relative 'utf'
def show_encoding(str)
puts "#{str} (size: #{str.size}) is #{str.encoding.name}"
end
show_encoding(STRING_ISO)
show_encoding(STRING_U)
show_encoding("cat")
| true |
1c342bf01388040e9c64b4b0d9b8e180bbd4e5f9 | Ruby | Erksters/code | /ruby/collatz.rb | UTF-8 | 1,022 | 3.171875 | 3 | [] | no_license | require 'rubygems'
require 'sinatra'
require 'haml'
def Collatz(n)
s_out = ""
k = 0
while n > 1
k += 1
r = n % 3
if r == 0
s_out += "D"
n /= 3
elsif r == 1
s_out += "U"
n = (4 * n + 2) / 3
elsif r == 2
... | true |
d76af999830124e925d252745ce599c4f54d747b | Ruby | leocabeza/it-books-bot | /lib/it_ebook.rb | UTF-8 | 3,658 | 3.109375 | 3 | [
"MIT"
] | permissive | require 'httparty'
require_relative './version.rb'
module Bot
class Book
include HTTParty
base_uri 'http://it-ebooks-api.info/v1/'
def initialize attrs, total, page
attrs.each do |name, val|
lower_camel_cased = underscore(name)
instance_variable_set "@#{lower_camel_cased}", val
... | true |
8893aace94f8d5d93d67373671417a1516e0e303 | Ruby | rafaltrojanowski/arkanoid | /ball.rb | UTF-8 | 2,340 | 3.03125 | 3 | [
"MIT"
] | permissive | class Ball < Engine::Sprite
def initialize
super
@image = Engine::Game.images["ball"]
@x = @y = @vel_x = @vel_y = 0.0
@angle = rand(90) + 135
@z = ZOrder::Ball
@collided = false
end
def update
puts self.inspect
self.accelerate
self.move
if ((@x > 10 && @x < 500) && (@y... | true |
62c1dba6008c04b6a9790ea7e863bcc379e9241a | Ruby | eidolonsky/alpha-app | /app/models/photo.rb | UTF-8 | 644 | 2.625 | 3 | [] | no_license | class Photo < ApplicationRecord
validates :title, :img_url, presence: true
validates :title, uniqueness: true
validates :img_url, allow_blank: true, format: {
with: %r{\.(gif|jpg|png)\Z}i,
message: 'must be a URL for GIF, JPG or PNG image.'
}
has_many :taggings
has_many :tags, through: :taggings
... | true |
208fc56c468591daeda259d1ee8191217d35f31a | Ruby | aperini/ruby-fundamentals | /Types/hashes.rb | UTF-8 | 922 | 4.46875 | 4 | [] | no_license | # ordered collection os KVPs
# empty hash
puts h = {}
# keys are strings
puts h = { 'min' => 0, 'max' => 10 }
# shortcut
puts h = { min: 0, max: 10 }
puts "Hey, min value is #{h[:min]}, max value is #{h[:max]}"
# adding elements
h[:av] = 5
puts h
# specifying a DEFAULT VALUE = ZERO
# This retu... | true |
f7d28cdfef4cf24128974e700fd85afaadd004dc | Ruby | Bumsuk/MyRubyBase | /MyLearn/0000_test3.rb | UTF-8 | 554 | 2.9375 | 3 | [] | no_license | #!/usr/bin/ruby
require 'benchmark'
n = 1_000_000
print '"foo".equal? "foo" -> ', ("foo".equal? "foo"), "\n"
print '"foo" == "foo" -> ', ("foo" == "foo" ), "\n"
print ':foo.equal? :foo -> ', (:foo.equal? :foo ), "\n"
print ':foo == :foo -> ', (:foo == :foo ), "\n"
Benchmark.bm(10) do |b|
b.re... | true |
3997a0dcb740703ef2011c98ce8a5da4a2bf13fc | Ruby | vanessadean/psychopass | /models/giph.rb | UTF-8 | 579 | 2.53125 | 3 | [] | no_license | class Giph
def random_keyword
wordnik_url = "http://api.wordnik.com/v4/words.json/randomWord?api_key=#{ENV['WORDNIK_API_KEY']}"
uri = URI(wordnik_url)
api_response = Net::HTTP.get(uri)
JSON.parse(api_response)['word']
end
def image_url
giphy_url = "http://api.giphy.com/v1/gifs/translate?api_k... | true |
e12b270f73157fc5dfc3ab283cf679a2c00de20e | Ruby | j-armah/programming-univbasics-nds-nested-arrays-iteration-lab-part-3-nyc01-seng-ft-102620 | /lib/iteration_with_loops.rb | UTF-8 | 448 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def join_nested_strings(src)
# src will be an Array of Arrays of Strings and Integers
# Combine all Strings present in the AoA into a single value and return it
row = 0
string_array = []
while row < src.count do
inner_row = 0
while inner_row < src[row].count do
if src[row][inner_row].is_a? Strin... | true |
49cf01d7c0cf76ad3ed152a6055cdc72f07ceb03 | Ruby | woobaik/udemy_ruby | /random_practice/errors_exceptions.rb | UTF-8 | 488 | 4.03125 | 4 | [] | no_license | =begin
#Exceptions
=end
def sqrt(num)
unless num >= 0
raise ArgumentError.new "Cannot take sqrt of negative number"
end
puts num - 1
end
def main
while true
#get an integer from the user
puts "Please input a number"
num = gets.to_i
begin
sqrt(num)
rescue ArgumentError => e
... | true |
3c2168ee8cf12270974c7213fbac7feb70ec6654 | Ruby | tktcorporation/neptune | /app/models/recipe_ingredient.rb | UTF-8 | 1,832 | 2.828125 | 3 | [] | no_license | # == Schema Information
#
# Table name: ingredients
#
# id :integer not null, primary key
# recipe_id :integer not null
# sort_order :integer not null
# name :string(255) not null
# quantity_and_unit :string(255) not null
# created_at... | true |
37fefb3eec7853dde4c9cbeaf7f41080165a41f4 | Ruby | finalbout/ruby-oo-object-relationships-has-many-lab-sfo01-seng-ft-042020 | /lib/artist.rb | UTF-8 | 551 | 3.640625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Artist
attr_accessor :name
def initialize(name)
@name = name
end
def songs
Song.all #calls the class Song
end
def add_song(song)
song.artist = self #refers to artist instance
# binding.pry
end
def add_song_by_name(song_name)
... | true |
90ddfa0426e544679331ea9433e32c015874a77a | Ruby | baschenbrenner/my-first-hash-v-000 | /my_first_hash.rb | UTF-8 | 921 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_hash
my_hash={"uncle"=>"frank","aunt"=>"diane"}# use the literal constructor to set the variable, my_hash, equal to a hash with key/value pairs of your choice.
end
def shipping_manifest
shipping_manifest={"whale bone corsets" => 5, "porcelain vases"=>2,"oil paintings" =>3}
#set a variable called `shipping... | true |
7ec768df22f39e265a65dd0697749711a937e84c | Ruby | captainvita/learn-coding | /ruby/LRTHW/ex32/ex32.rb | UTF-8 | 434 | 3.96875 | 4 | [
"MIT"
] | permissive | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
the_count.each do |numbers|
puts "This is count #{numbers}"
end
fruits.each do |fruit|
puts "A fruit of type: #{fruit}"
end
change.each do |i|
puts "I got #{i}"
end
e... | true |
c86213ae850235b210f9b8263e4c1a6279c98790 | Ruby | mkr2005/siwapp | /test/unit/invoice_test.rb | UTF-8 | 616 | 2.609375 | 3 | [] | no_license | require 'test_helper'
class InvoiceTest < ActiveSupport::TestCase
test "number is numeric" do
invoice = Invoice.new
invoice.number = 'abc'
assert !invoice.save
end
test "basic calculations" do
invoice = invoices(:one)
assert_equal invoice.get_base_amount , 39.78
assert_equal invoice.get_d... | true |
409db79c024876a17945fb33c8486ce74815d84f | Ruby | tagirahmad/Ruby | /lesson5/carriage.rb | UTF-8 | 171 | 2.734375 | 3 | [] | no_license | require_relative 'company_name'
class Carriage
include CompanyName
attr_reader :name, :kind
def initialize(name, kind)
@name = name
@kind = kind
end
end
| true |
9afa0e13b954a773f170566ea97849c2e567e7e2 | Ruby | eyeson-team/eyeson-ruby | /lib/eyeson/snapshot.rb | UTF-8 | 483 | 2.609375 | 3 | [
"MIT"
] | permissive | module Eyeson
# Get room snapshots
class Snapshot
class NotFound < StandardError
end
attr_reader :id, :url
def initialize(id, url)
@id = id
@url = url
end
def delete
Eyeson.delete "/snapshots/#{id}"
end
def self.find(snapshot_id)
response = Eyeson.get("/sn... | true |
4441cbf071d0566379f394adc9a1da47412bfb7a | Ruby | kmtownley/ORMify | /lib/associatable.rb | UTF-8 | 1,842 | 2.515625 | 3 | [] | no_license | require_relative 'searchable'
require 'active_support/inflector'
require 'byebug'
class AssocOptions
attr_accessor(
:foreign_key,
:class_name,
:primary_key
)
def model_class
@class_name.constantize
end
def table_name
@class_name.capitalize.constantize.table_name
end
end
class Belongs... | true |
0be1c78beee9e110b504de80cf9d7af0292d3047 | Ruby | dolan/rambo | /lib/raml_models/resource.rb | UTF-8 | 397 | 2.515625 | 3 | [
"MIT"
] | permissive | module Rambo
module RamlModels
class Resource
attr_reader :schema
def initialize(raml_resource)
@schema = raml_resource
end
def http_methods
@http_methods ||= schema.methods.map {|method| Rambo::RamlModels::Method.new(method) }
end
def to_s
schema.uri... | true |
e81fddc23d0ee7bc21a31af1903de06940436b9a | Ruby | otuyelu/ProjectEuler-and-Algorithms | /graph_algorithms/lib/graph.rb | UTF-8 | 21,379 | 3.140625 | 3 | [] | no_license | # By Raymond Gan
# See "rspec_screen_output.txt" for RSpec results
class Matrix
# add missing method to Ruby Matrix class
def []=(row, column, value)
@rows[row][column] = value
end
end
class Graph
attr_reader :graphfile, :graphtype, :num_vertices
attr_accessor :adj_lists, :a_matrix, :cadj_lists, :ca_mat... | true |
f0ce8a4fcde90a41c4f0008f002d1f6dda992fda | Ruby | marlonmarcos21/url_shortener | /lib/google_url_shortener.rb | UTF-8 | 2,115 | 2.78125 | 3 | [] | no_license | # I would have used googl gem (https://github.com/zigotto/googl)
# But I wanted to make it more fun & challenging so I implemented my own :)
require 'net/http'
class GoogleUrlShortener
API_URL = 'https://www.googleapis.com/urlshortener/v1/url'.freeze
SCOPE_URL = 'https://www.googleapis.com/auth/urlshortener'.fre... | true |
571ec7e474859bd6c17329dabd9a31f2de11ac56 | Ruby | jweissman/dragon | /lib/dragon/events/gambling_victory_event.rb | UTF-8 | 343 | 3.078125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Dragon
module Events
class GamblingVictoryEvent < Event
attr_reader :amount, :outcome
def initialize(amount: nil, outcome: nil)
@amount = amount
@outcome = outcome
end
def describe
"You correctly predicted the outcome #{outcome}, so you win #{amount}"
... | true |
192f65b4fda54c1c2370091217996cd6aa05628c | Ruby | m11o/algoruby | /src/section3/code3_3.rb | UTF-8 | 436 | 3.484375 | 3 | [] | no_license | #
# 学んだことをコメントを書くようにする
#
# - Fixnumの最大値と最小値は
# - max: 4611686018427387903
# - min: -4611686018427387904
# - ref: https://simanman.hatenablog.com/entry/2014/01/07/154357
#
n = gets.chomp.to_i
array = (0...n).map { gets.chomp.to_i }
INFINITY_NUMBER = 10000
min_value = INFINITY_NUMBER
array.each do |value|
next ... | true |
82339260d20c6e266fda6692e566f5fa7226ae48 | Ruby | ahafele/linked_data | /lib/PerformanceGroup.rb | UTF-8 | 158 | 2.875 | 3 | [] | no_license | class PerformanceGroup
attr_accessor :name, :albums
def list_albums
output = ''
@albums.each { |a|
output += a + "\n"
}
return output
end
end | true |
5edcdddf51bb871cb5c48dfa6d0ed0dee702fb55 | Ruby | TheNaterz/ProjectEuler | /23.rb | UTF-8 | 1,509 | 4.09375 | 4 | [] | no_license | =begin
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
A number n is called deficient if the sum of its proper divisors is less than n and... | true |
5089150f28a39f3d23cce345a3eb0f46aa553033 | Ruby | csalmeida/ruby-fundamentals | /challenges/guessing-game-solution.rb | UTF-8 | 1,084 | 4.28125 | 4 | [] | no_license | #!/usr/bin/env ruby
puts '----------------------'
puts '| Ruby Guessing Game |'
puts '----------------------'
# Retrieving the user name and printing greeting:
print "\nWhat is your name? "
user_name = gets.chomp
puts "Hello, #{user_name}!"
# Generating random number:
MAX_NUMBER = 10
MAX_ATTEMPTS = 3
RANDOM_NUMBER = ... | true |
f659225276491ff21896a867bc6bf69b78db6ae6 | Ruby | bstockus/StaticSiteGenerator | /lib/StaticSiteGenerator/resource.rb | UTF-8 | 1,663 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'sass'
require 'StaticSiteGenerator/site'
module StaticSiteGenerator
module Engine
class Resource
def initialize(site, name, file, results_path)
@site = site
@name = name
@file = file
@results_path = results_path
end
def get_site()
return @si... | true |
8c615b83f3733a23b84f4b4836bd781b2703e7b5 | Ruby | chengbaobao630/shuttle | /exe/shuttle | UTF-8 | 707 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative '../lib/shuttle'
# 可执行文件
module ShuttleCli
# @!method entrypoint
class Cli
class << self
def reader
@reader ||= Shuttle::Reader.new
end
def printer
@printer ||= Shuttle::Printer.new
end
def start
if ARGV && ARGV[0]
... | true |
6365174bbc23589f01eb503331f7f97aeec360c2 | Ruby | holamendi/chilexpress | /lib/chilexpress/shipment.rb | UTF-8 | 467 | 2.609375 | 3 | [
"MIT"
] | permissive | module Chilexpress
class Shipment
attr_reader :order_number, :product_type, :service_type, :status, :receiver, :tracking_entries
def initialize(attributes)
@order_number = attributes[:order_number]
@product_type = attributes[:product_type]
@service_type = attributes[:service_type]
@st... | true |
e5b2eac8c75aac26066c08236e3fc6b0aaf4664a | Ruby | diane-douglas-bva/32degrees | /shared/discount_percentage.rb | UTF-8 | 650 | 3.28125 | 3 | [] | no_license | # Apply a percentage discount to a line item.
class PercentageDiscount
attr_reader :message
def initialize(percent, message)
@percent = Decimal.new(percent) / 100.0
@message = message
end
def apply(line_item)
line_discount = line_item.line_price * @percent
new_line_price = line_item.line_price... | true |
7df48176452d828da7dd4392d154d05d2dc438f9 | Ruby | RJFerguson/FitNasty | /app/models/user_exercise.rb | UTF-8 | 579 | 3.078125 | 3 | [] | no_license | class UserExercise < ApplicationRecord
belongs_to :user
belongs_to :exercise
def calories_burned
cm = self.user.height * 2.54 #convert from inches to cm
kilo = self.user.start_weight * 0.453592 #convert from pounds to kilos
age = self.user.age
if self.user.gender == 'Woman'
bmr = (9.56 * kilo) +... | true |
80984bab2d21c1400ef01feb419c9cd37f93aecf | Ruby | akmoore/tts-ruby | /week_2/day_1/loops.rb | UTF-8 | 819 | 4.46875 | 4 | [] | no_license | puts "1 bird on a wire, ha ha ha!"
# For loop
# for number in 2..100 #=> 1..3 (includes the 3) \ 1...3 (excludes the 3)
# puts "#{number} birds on a wire, ha ha ha!"
# end
# Time Do Loops
# 5.times do |number|
# puts "#{number + 2} birds on a wire, ha ha ha!"
# end
# 2.upto(10) do... | true |
3a3e4fe83cc5d9eb18f14dc69f0d40a7637cd504 | Ruby | sodonnel/puppet-modules | /boxes/hadoop/sanity/hbase/merge_empty_regions.rb | UTF-8 | 2,990 | 2.921875 | 3 | [] | no_license | # Test Mode:
#
# hbase org.jruby.Main merge_empty_regions.rb namespace.tablename
#
# Non Test - ie actually do the merge:
#
# hbase org.jruby.Main merge_empty_regions.rb namespace.tablename merge
#
# Note: Please replace namespace.tablename with your namespace and table, eg NS1.MyTable. This value is case sensitive.
r... | true |
c5db2029bdee99c0a82f1e32452f7dff5c943d50 | Ruby | gmontantez/poker_hands | /poker_hands_test1.rb | UTF-8 | 14,898 | 3.359375 | 3 | [] | no_license | require "minitest/autorun"
require_relative "poker_hands.rb"
class Poker_hands_test < Minitest::Test
def test_true_equals_true
assert_equal(true,true)
end
def test_for_hash
assert_equal(Hash,hand_builder().class)
end
def test_for_two_hands
assert_equal(2,hand_builder().length)
end
def test_for_length_o... | true |
2507e4e9d36001dca809473f38239995d47e8657 | Ruby | robrkerr/anyrhyme | /anyrhyme-api/app/models/phoneme.rb | UTF-8 | 405 | 2.671875 | 3 | [] | no_license | class Phoneme < ActiveRecord::Base
def is_vowel
phoneme_type == "vowel"
end
def possible_stresses
is_vowel ? [0,1,2] : [3]
end
def stressed_name stress
name + (is_vowel ? stress.to_s : "")
end
def autocomplete_format
possible_stresses.map { |i| {
:label => stressed_name(i),
:... | true |
5a9ce1556e93665b2e2755ac8049627f5b12db8e | Ruby | ceclinux/rubyeveryDAMNday | /538.ConvertBSTtoGreaterTree.rb | UTF-8 | 924 | 3.421875 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @return {TreeNode}
def convert_bst(root)
total = 0
if root.nil?
return
end
n... | true |
18a331f69587cc8bee354bdef63c84c3b6a286e0 | Ruby | jasonkaskel/projecteuler | /52/solution.rb | UTF-8 | 498 | 3.828125 | 4 | [] | no_license | # It can be seen that the number, 125874, and its double, 251748, contain exactly
# the same digits, but in a different order.
# Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
# contain the same digits.
# Time to complete: 5 minutes
def same_digits?(a, b)
return a != b &&
a.to_s.spli... | true |
3b53db2af4fea905e25ec9478679a274a05a57c7 | Ruby | gshugh/Practice | /Regex/my_regex.rb | UTF-8 | 1,793 | 3.234375 | 3 | [] | no_license |
require 'date'
module MyRegex
# From the start of the line (^), find all patterns with 0 or more white
# spaces (\x*) followed by a carriage return. Replace with nothing.
def MyRegex.strip_blank_lines(words)
words.gsub(/^\s*\n/,"")
end
# From the start of the line (^), find all patterns with 1 or more wh... | true |
b0e6f4e55eedc294775684fa93a9cee687899cee | Ruby | cristinaocanamanzano/wardrobe-app | /spec/unit/colourSpec.rb | UTF-8 | 487 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../app/lib/colour'
describe Colour do
let(:colour) { described_class.new }
describe '#return_match_message' do
it 'happy return message' do
message = colour.return_match_message('blue', 'red')
expect(message).to eq "Rollin' with the homies!"
e... | true |
a5865ce18f55271c2265b0beba686ca59207a4cb | Ruby | KarmaHater/practice-algorithms | /data_structures/stack.rb | UTF-8 | 1,203 | 4.28125 | 4 | [] | no_license | class Stack
def initialize(max = 10)
@list = []
@max = max
end
def add(element)
@list.unshift(element)
end
def take_away
raise "Stack Underflow - The stack is empty" if self.empty?
@list.shift
end
def empty?
@list.empty?
end
def full?
if @list.length >= @max
true
... | true |
74229060c48ef909a28a5cae12ecf2c98952462f | Ruby | heavenstudio/vzaar | /lib/vzaar/base.rb | UTF-8 | 18,799 | 3 | 3 | [] | no_license | module Vzaar
# You can use Vzaar::Base class for accessing and managing your resources on vzaar.
class Base
attr_accessor :login
# When creating a Vzaar::Base instance you can (but don't have to) specify
# login and application_token. However if you don't specify them you
# won't be able to perfor... | true |
20ebb564a26c6ba0e00895f270a6d6d44483e5af | Ruby | JPLynch35/module_3_diagnostic | /app/models/station.rb | UTF-8 | 314 | 2.59375 | 3 | [] | no_license | class Station
attr_reader :name, :address, :fuel_types, :distance, :access
def initialize(data_set)
@name = data_set[:station_name]
@address = data_set[:street_address]
@fuel_types = data_set[:fuel_type_code]
@distance = data_set[:distance]
@access = data_set[:access_days_time]
end
end
| true |
609d6bb7f3b24b16f9405fc6879204bf82eade31 | Ruby | frangucc/monthlys | /app/services/user_preferences_service.rb | UTF-8 | 841 | 2.640625 | 3 | [] | no_license | class UserPreferencesService
attr_accessor :user
def initialize(target_user)
self.user = target_user
end
def merchant_out_of_area(merchant)
if zipcode
categories = merchant.plans.map(&:categories).flatten.uniq
add_user_preferences(categories)
end
end
def plan_out_of_area(plan)
... | true |
182b7f6db8cec1f56885141a51d26930adf5bdf3 | Ruby | hyunho98/ruby-music-library-cli-online-web-pt-110419 | /lib/song.rb | UTF-8 | 1,298 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name
attr_reader :artist, :genre
@@all = []
def initialize(name, artist = nil, genre = nil)
@name = name
self.artist=(artist)
self.genre=(genre)
self.save
end
def self.all
@@all
end
def self.destroy_all
@@all.clear
end
def save
@@all << self... | true |
45a33ec65810fba185a59f7006c5de1c93e07f6c | Ruby | dashinfall3/ar-sunlight-legislators | /app/main.rb | UTF-8 | 1,532 | 2.78125 | 3 | [] | no_license |
require_relative 'models/congress_member.rb'
require_relative 'models/state.rb'
require_relative 'models/party.rb'
all_members = CongressMember.all
CongressMember.where(:state, "HI")
state_senate_members = CongressMember.where(:state => "HI", :title => "Sen")
state_house_members = CongressMember.where(:state => "HI"... | true |
da56486b5d936c210e20b240d2aa6d4bf48ee6d1 | Ruby | karlxavier/frishtug | /app/helpers/number_helper.rb | UTF-8 | 139 | 2.6875 | 3 | [] | no_license | module NumberHelper
def to_currency(number, unit='$')
number_to_currency number, unit: unit, precession: 2, format: '%u %n'
end
end | true |
908208be9c42a1d25aa4e3c7a5acd87daf989692 | Ruby | stephanesdr/mvc_exercise | /spec/models/item_spec.rb | UTF-8 | 2,383 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
# == Schema Information
#
# Table name: items
#
# id :bigint(8) not null, primary key
# discount_percentage :integer default(0)
# has_discount :boolean default(FALSE)
# name :string
# original_price :float ... | true |
428262546073012cdcc3fdea4b1443929b08799b | Ruby | ityonemo/Basie | /test/test_databases.rb | UTF-8 | 4,120 | 2.84375 | 3 | [] | no_license | #test_databases.rb
#common creation schemes for test databases.
#forward the existence of the Basie class.
class Basie; end
#monkey-patch the MockResponse Class to give a "success?" readout which is agnostic to all forms of HTTP success (not just OK)
class Rack::MockResponse
def success?
@status >= 200 && @sta... | true |
0d691e6b534a6165891a70ca62ff852d99ef629e | Ruby | wnoguchi/kaisya_bot | /lib/time_messenger.rb | UTF-8 | 2,248 | 3.359375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
class TimeMessenger
def self.get_message(year, month, mday, wday, hour)
# 曜日を取得する
weekday = TimeMessenger.get_wday_symbol(wday)
case hour
when 8
ret = "おはようございます!今日は" << get_time_str(year, month, mday, wday) << "です。"
if weekday == :sat or weekday == :sun
... | true |
1ab6f2566e20228c7b44e1ec1d4ba3db190083df | Ruby | lucasbonner/RB120-129 | /lesson_4/medium_1/quest_3.rb | UTF-8 | 931 | 3.796875 | 4 | [] | no_license | #In the last question Alan showed Alyssa this
#code which keeps track of items for a shopping cart application:
class InvoiceEntry
attr_reader :quantity, :product_name
def initialize(product_name, number_purchased)
@quantity = number_purchased
@product_name = product_name
end
def update_quantity(updat... | true |
1ba94737c0069fac01920a0eb4145893952d26fe | Ruby | kenhufford/aA-projects | /W4D2/chess/piece.rb | UTF-8 | 381 | 2.859375 | 3 | [] | no_license |
class Piece
# attr_accessor :pos
attr_reader :color, :pos
attr_writer :pos
def initialize(color, board, pos)
@color = color
@board = board
@pos = pos
@symbol = ""
end
def to_s
p @symbol
end
def empty?
return true if self == NullPiece.instance
false
end
def move_into_c... | true |
bac20e47ce4c0503d2b4dcbed4fe5145e31e710e | Ruby | tjsai93/works | /lib/shopify-cli/commands/deploy/heroku.rb | UTF-8 | 7,174 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'shopify_cli'
module ShopifyCli
module Commands
class Deploy
class Heroku < ShopifyCli::Task
include Helpers::OS
DOWNLOAD_URLS = {
linux: 'https://cli-assets.heroku.com/heroku-linux-x64.tar.gz',
mac: 'https://cli-assets.heroku.com/heroku-darwin-x64.tar.gz',
... | true |
b66cec1d075e70e3cdc00bf2fd05ae68534a01b1 | Ruby | ManageIQ/manageiq | /app/models/physical_server_firmware_update_task/state_machine.rb | UTF-8 | 1,108 | 2.546875 | 3 | [
"BSD-2-Clause",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module PhysicalServerFirmwareUpdateTask::StateMachine
def run_firmware_update
dump_obj(options, "MIQ(#{self.class.name}##{__method__}) options: ", $log, :info)
signal :start_firmware_update
end
def start_firmware_update
# Implement firmware update in subclass, user-defined values are stored in option... | true |
b0e6b6c338c3b92162376b5a3dfde24b94fb8b91 | Ruby | vidur-88/BookingVenues | /app/models/client.rb | UTF-8 | 990 | 2.625 | 3 | [] | no_license | class Client < ActiveRecord::Base
attr_accessible :address, :contact_no, :email_id, :name, :status
has_many :bookings #one to many relation from booking (one client can has many bookings)
validates :name, presence: true
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i #regex for checking email id
... | true |
7849f91bb62e3f711b6f3bc589c5b466afea1473 | Ruby | findmejobs/fire-and-forget-client | /spec/client_spec.rb | UTF-8 | 2,625 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'fire-and-forget-client'
require 'rspec'
require 'rspec-spies'
require 'json'
require 'socket'
describe 'client' do
describe '#initialize' do
it 'should initialize with hostname, port and passphrase parameters' do
client = FireAndForget::Client.new('thing', 12345, 'something')
client.hostname... | true |
14094afd99ceb7d6a0ea41434e770eb5a044fbde | Ruby | xfbs/awesome | /examples/rubocop/example.rb | UTF-8 | 261 | 3.59375 | 4 | [
"Unlicense"
] | permissive | # bad -- four spaces instead of two.
def bad_method
puts "hello!"
end
# bad -- uses semicolon to separate expressions.
bad_method; bad_method
# bad -- no whitespace between operator.
sum = 1+3
# bad -- don't use several empty lines in a row.
puts(sum)
| true |
0595ec30d111c0e6de0b4b79b8dd68cdc541424b | Ruby | yasskin/twilio_texts | /twilio.rb | UTF-8 | 2,321 | 2.515625 | 3 | [] | no_license | TWILIO REST API
https://www.twilio.com/docs/api/rest
REST API: SENDING SMS OR MMS
https://www.twilio.com/docs/api/rest/sending-messages#messaging-services
Rest Client Gem
https://github.com/rest-client/rest-client
RestClient.post 'http://example.com/resource', {param1: 'one', nested: {param2: 'two'}}
require 'rest-... | true |
d8f3f3bfedaa3d6f76f16a6df54cf67884bbc0de | Ruby | WalterDonnellan/_world-1 | /lab_08/regex_tester.rb | UTF-8 | 1,881 | 3.40625 | 3 | [] | no_license | class RegexTester
def initialize(pattern=nil)
@pattern = pattern unless pattern.nil?
end
attr_accessor :pattern
def statements
@statements
end
def statements=(arr)
begin
raise TypeError unless arr.class == Array
raise RuntimeError if arr.empty?
... | true |
3cb738670bc0ab2971532dd3cbc9ddece36a62ba | Ruby | pwnall/igor | /app/jobs/submission_analysis_job.rb | UTF-8 | 1,312 | 2.640625 | 3 | [
"MIT"
] | permissive | # A background job to analyze a student's submission.
class SubmissionAnalysisJob < ApplicationJob
queue_as :default
# Update the submission's analysis to reflect its queued status.
before_enqueue do |job|
arguments.first.analysis_queued!
end
# Update the submission's analysis to reflect its running sta... | true |
bdcc768e46c8f9aa501278534666fa4ed120c336 | Ruby | sercanerhan/citysdk-ld | /importers/gtfs/gtfs_util.rb | UTF-8 | 10,452 | 2.578125 | 3 | [
"MIT"
] | permissive | require "date"
require "socket"
module GTFS_Import
RevMods = {
'0' => 'tram',
'1' => 'subway',
'2' => 'rail',
'3' => 'bus',
'4' => 'ferry',
'5' => 'cable car',
'6' => 'gondola',
'7' => 'funicular'
}
Modalities = {
'Tram' => 0,
'Subway' => 1,
'Rail' => 2,
'... | true |
07164686bb8ce9db07dd2859a82ebf7e186b3877 | Ruby | ernestosbarbosa/qarentena-front-web-ruby | /features/step_definitions/validacoes_datatable_steps.rb | UTF-8 | 528 | 2.578125 | 3 | [] | no_license | require 'csv'
Dado('que estou na página inicial') do
@home_page = HomePage.new
@home_page.load
end
Entao('os links para todas as midias sociais devem ser exibidos') do
CSV.foreach("features/support/data/links.csv", headers: true) do |row|
expect(@home_page.send("exists_#{row['links']}_link?")).to ... | true |
c8affd8a6c06797cd55516d97d0c8336f6ccfa38 | Ruby | MargoSolo/stared-repos-p2 | /AppAcademy/Curriculum/12 Career Quest/W24D3 Pair Boarding/04A.rb | UTF-8 | 2,919 | 4.09375 | 4 | [] | no_license | # uniq_subs
# Write a method that finds all the unique substrings for a word.
# Solution
# A results array and the include? method can be used to enforce uniqueness, but it adds the time cost of iterating through that array to check for inclusion. Keeping track of substrings in a set or hash is more efficient (O(1) lo... | true |
e73f8ce518b375113895b5e05b6cb5d29717278f | Ruby | jmettraux/volute | /examples/traffic.rb | UTF-8 | 1,703 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive |
# license is MIT
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'volute'
#
# our classes
class Light
include Volute
attr_accessor :colour
attr_accessor :changed_at
def initialize(colour)
self.colour = colour
end
def green?
self.colour == :green
end
def red!
self.... | true |
57b095e0a3959f67a5e19d294b817ef32ba24828 | Ruby | marlibs3-zz/codeclan-w3-weekend-homework | /models/film.rb | UTF-8 | 1,232 | 3.328125 | 3 | [] | no_license | require_relative("../db/sql_runner")
class Film
attr_reader :id
attr_accessor :title, :price
def initialize( options )
@id = options['id'].to_i if options['id']
@title = options['title']
@price = options['price'].to_i
end
def self.drop()
sql = "DROP TABLE IF EXISTS films;"
SqlRunner.ru... | true |
16700edc615c46abb415fb5435af312d5823dc42 | Ruby | edgecase/validation_matchers | /lib/validation_matchers/active_model/validate_each_matchers.rb | UTF-8 | 1,674 | 2.890625 | 3 | [] | no_license | module ValidationMatchers
module ActiveModel
def pass_validate_each(attribute, value)
PassEachValidationMatcher.new(attribute, value)
end
def fail_validate_each(attribute, value)
FailEachValidationMatcher.new(attribute, value)
end
private
class Matcher
def initialize(attr... | true |
693a2ac7e65a7ed7bcc92950f2fb62f9d48a14e0 | Ruby | arunkal1/Nasa_API_Testing | /lib/services/nasa_api_service.rb | UTF-8 | 2,875 | 2.984375 | 3 | [] | no_license | require 'json'
require "httparty"
class NasaApiService
include HTTParty
base_uri 'https://api.nasa.gov/neo/rest/v1/feed?start_date=2015-09-07&end_date=2015-09-08&'
attr_accessor :nasa
def initialize
@api_key = 'PexEAtSdu3r7w4t0ifvxM02xjMcCuZEl7lwCDQVB'
@nasa = JSON.parse(self.class.get("&api_key=#{@a... | true |
a4e512168c4d16b7de0f8a8db99387866a99766c | Ruby | albertbahia/wdi_june_2014 | /w04/d01/hoa_newton/twdir_app/db/seeds.rb | UTF-8 | 1,584 | 2.578125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
48305d5b17300faf67913cc1a6b55c80ce7cd82a | Ruby | cararemixed/webmachine-ruby | /lib/webmachine/response.rb | UTF-8 | 1,589 | 2.890625 | 3 | [] | no_license | module Webmachine
# Represents an HTTP response from Webmachine.
class Response
# @return [Hash] Response headers that will be sent to the client
attr_reader :headers
# @return [Fixnum] The HTTP status code of the response
attr_accessor :code
# @return [String, #each] The response body
att... | true |
48af515e2db1f89ee64da58e6b5a2db954c36dde | Ruby | Ayukito/Ruby-File-Loader | /Ruby File Loader/Project/pokemonsdk/scripts/00700 PSDK Event Interpreter/01102 Interpreter_Move_Reminder.rb | UTF-8 | 1,040 | 2.609375 | 3 | [] | no_license | class Interpreter
# Call the move reminder UI with the choosen Pokemon and a specific mode (0 by default)
# @param pokemon [PFM::Pokemon]
# @param mode [Integer] see {GamePlay::Move_Reminder#initialize}
# @return [Boolean] if the Pokemon learnt a move or not
def move_reminder(pokemon = $actors[$game_variables... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.