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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
81aede7f00b62462e4f1e6effeb9dc13b38df767 | Ruby | mattTea/seven-languages | /ruby/ruby_codecademy/control_flow.rb | UTF-8 | 572 | 3.984375 | 4 | [] | no_license | print "Integer please: "
user_num = Integer(gets.chomp)
if user_num < 0
puts "You picked a negative integer!"
elsif user_num > 0
puts "You picked a positive integer!"
else
puts "You picked zero!"
end
# -----------------
hungry = false
unless hungry
puts "I'm writing Ruby programs!"
else
puts "Time to eat!... | true |
664f9c6ffcaaace85a68fd4d1e2c349101a54a6e | Ruby | tnvr000/ruby_basics | /ex043_enumerator_chaining.rb | UTF-8 | 306 | 3.375 | 3 | [] | no_license | def print_cities cities
cities.each {|city| print "#{city} "}
end
def print_cities_with_index cities
cities.each {|city, index| puts "#{index} : #{city}"}
end
cities = %w[tokia london rio paris].map
print_cities cities
puts ""
city_list = cities.with_index
print_cities_with_index city_list
puts ""
| true |
b60b136afc85fb3cd044794c13a05498822393e6 | Ruby | bratishka11/project1 | /Untitled-1.rb | UTF-8 | 363 | 3.40625 | 3 | [] | no_license | puts "Как тебя зовут?"
name = gets.chomp
puts "Привет, #{name}"
puts "Какой у тебя рост?"
height = gets.chomp
weight = height.to_i - 110
if weight < 0
puts "Твой вес уже оптимальный"
else
puts "Твой оптимальный вес, #{name}, равен #{weight} кг"
end
| true |
5883d0be58b4950a0b97a21920d4376a4dae91ef | Ruby | microcerebus/ttt-3-display_board-example-cb-gh-000 | /lib/display_board.rb | UTF-8 | 249 | 3.625 | 4 | [] | no_license | # Define a method display_board that prints a 3x3 Tic Tac Toe Board
def display_board
cell = " "
row = cell + " | " + cell + "| " + cell
separator = "-----------"
board = [row, separator,row, separator,row]
puts(board)
end
display_board
| true |
088201c453bdaa62ade5d9c981c7a56c1155f496 | Ruby | s-taichan/hiroshimarb-gem | /lib/hiroshimarb/commands/event.rb | UTF-8 | 590 | 2.609375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
module Hiroshimarb::Commands
class Event < Hiroshimarb::Command
def call(*args)
sub_command = args.first
if sub_command == "all"
puts all
else
puts recent
end
end
def recent
<<EOD
2012-12-01 (土) 14:00-18:00 広島Ruby勉強会 #026
http://hir... | true |
b9a8fc219e9899852024b1ef0b963f5debd72a90 | Ruby | VorontsovIE/myo_gesture | /compact_string.rb | UTF-8 | 343 | 3.625 | 4 | [] | no_license | def most_common_element(arr)
arr.each_with_object(Hash.new(0)){|elem, hsh|
hsh[elem] += 1
}.max_by{|elem, count|
elem
}.first
end
compactified_string = readline.each_char.each_cons(5).map{|letters|
most_common_element(letters)
}.each_with_object(''){|letter, s|
s << letter unless s[-1] == letter
}
p... | true |
346ac6164e4314f8f0ba3e9e5ba9b68a2f8bebce | Ruby | DanTheMan114/ruby-oo-object-relationships-kickstarter-lab | /lib/backer.rb | UTF-8 | 284 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Backer
attr_reader :name
def initialize(name)
@name = name
end
def back_project(project)
ProjectBacker.new(project,self)
end
def helper
ProjectBacker.all.select{|pb|pb.backer == self}
end
def backed_projects
helper.map{|pb|pb.project}
end
end
| true |
553951ba0aedc6f520eff9b04c342f0daf6bbab2 | Ruby | thebravoman/software_engineering_2013 | /class23_homework/A-Ivaylo-Hristov-13/Ruby/data/Group.rb | UTF-8 | 147 | 3.28125 | 3 | [] | no_license | class Group
def initialize
# Generates a group with random members [1;3]
@members = 1 + rand(3)
end
def members
return @members
end
end | true |
5eec9ac9b7275c8c8853cacac89b45596ec22508 | Ruby | passwordiscomputer/find_replace | /lib/find_replace.rb | UTF-8 | 255 | 3.453125 | 3 | [] | no_license | class Phrase
def initialize(sentence)
@sentence = sentence
end
def replace(input_word, output_word)
@sentence = "." + @sentence + "."
output = @sentence.split(input_word).join(output_word).chop
output[0] = ""
output
end
end
| true |
6f07a54ee9e3e13a358aa388c7245b6e83c58017 | Ruby | Ryednap/topcgen | /spec/method_parser_spec.rb | UTF-8 | 1,531 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
module Topcgen
describe MethodParser do
it "should parse method parameters" do
data = {
:method=>"leastShots",
:parameters=>"String[], int[], long, float",
:returns=>"int",
:signature=>"int leastShots(String[] damageChart, int[] bossHealth, long a, f... | true |
be1f7b3d3bbeb3737c317e337d4085b153a54c8f | Ruby | cit-jmu/workshop | /test/models/course_test.rb | UTF-8 | 3,472 | 2.859375 | 3 | [] | no_license | require 'test_helper'
class CourseTest < ActiveSupport::TestCase
test "course attributes must not be empty" do
course = Course.new
assert course.invalid?
assert course.errors[:course_number].any?
assert course.errors[:title].any?
assert course.errors[:short_title].any?
assert course.errors[:s... | true |
74f39430f346e7090280c256a9e743b4fc13e015 | Ruby | pointybird/danewatch | /lib/danewatch/optparser.rb | UTF-8 | 721 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'optparse'
class OptParser
# Parse command line options
def self.parse_options(args)
parsed_options = {
interval: 1,
notify: []
}
options = OptionParser.new do |opts|
opts.on('-t', '--time INTERVAL', Integer, 'Update interval in hours') do |i|
parsed_options[:interval... | true |
15b0320b7e28112b7834fd7ab377b0262c749adf | Ruby | NTHUDEV/hw_4-credit_card_api | /helpers/creditcard_helper.rb | UTF-8 | 3,987 | 2.625 | 3 | [] | no_license | require 'jwt'
require 'pony'
require 'sendgrid-ruby'
require 'base64'
require 'rbnacl/libsodium'
require_relative 'email_helper'
module CreditCardHelper
include EmailHelper
def validate_card(card_num)
creditcard = CreditCard.new
creditcard.number = card_num
creditcard.validate_checksum ? validation="Ok... | true |
d3c8dee807b50857a993311af86d00a72f4b83fa | Ruby | bjornblomqvist/biosphere | /core/lib/biosphere/extensions/hash.rb | UTF-8 | 768 | 2.6875 | 3 | [
"MIT"
] | permissive | module Biosphere
module Extensions
module HashExtensions
def deep_stringify_keys
inject({}) { |result, (key, value)|
value = value.deep_stringify_keys if value.is_a?(Hash)
result[(key.to_s rescue key) || key] = value
result
}
end
def deep_stringify_keys... | true |
c1709a1fa52c1b0232c189ce9175f4a957970884 | Ruby | casturm/mycodewars | /calc_with_functions.rb | UTF-8 | 91 | 2.984375 | 3 | [] | no_license | def five
5
end
def seven op
op.call(7)
end
def times f2
-> (f1) { f1 * f2 }
end
| true |
f6d1ae2f0b56e3c1d73404c7009f24f0402f47e5 | Ruby | sjmoody/sinatra-dynamic-routes-lab-cb-000 | /app.rb | UTF-8 | 2,421 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
# Write your code here!
get '/reversename/:name' do
#accepts a name and renders the name backwards
@name = params[:name].reverse
"#{@name}"
end
get '/square/:number' do
#accepts a number and returns the square of that number
@... | true |
5f414cdbea9a8a622de2575c8556d53c55554218 | Ruby | GuilhermeAltmann/Examples | /objects.rb | UTF-8 | 675 | 3.75 | 4 | [] | no_license | class Car
attr_reader :price
attr_accessor :year
def initialize(fuel_type, year, price)
@fuel_type = fuel_type
@year = year
@price = price
end
def price
@price * discount_tax
end
private
def discount_tax
0.92 # 8% de desconto
... | true |
20fc05ba2b209e75269e2e9c61771839da725d58 | Ruby | luizkowalski/chathub-rails | /app/services/room_service.rb | UTF-8 | 254 | 2.546875 | 3 | [] | no_license | class RoomService
def top_rooms
result = []
Message.top_rooms_from_messages.each do |room|
top_room = Room.find room[:_id]
result << TopRoom.new(top_room.avatar, top_room.name, room[:count]) if top_room
end
result
end
end
| true |
cf127148d9ba40abb6d58e4b3bb0a7d80c803ed2 | Ruby | yuan-xy/c-closure-example | /1/find_by_name_and_size.rb | UTF-8 | 273 | 2.671875 | 3 | [] | no_license | def find(dir,find_str,min_byte)
Dir.open(dir).each do |x|
full_path = dir+x
puts "#{x}, #{File.size(full_path)}" if x.start_with?(find_str) && File.size(full_path)>min_byte
end
end
if ARGV.length==3
find(ARGV[0],ARGV[1],ARGV[2].to_i)
else
find("./", "a", 10)
end
| true |
9f0e2e469754674083cfb08e2bff8026af424625 | Ruby | Dadario23/Ruby | /Ejercicios/ej_bmi2.rb | UTF-8 | 295 | 3.96875 | 4 | [] | no_license | print "ingrese su peso: "
peso = gets.chomp.to_i
print "Ahora ingrese su altura: "
alt = gets.chomp.to_i
bmi = peso / alt**2
if bmi < 18.5
puts "usted esta en bajo peso"
elsif bmi < 25
puts "peso normal"
elsif bmi < 30
puts "usted esta en sobre peso"
else
puts "usted es un obeso"
end
| true |
2d1737be110122548fde3caa608dfbec1c01886c | Ruby | esthersweon/Ruby_Basics | /correct_hash.rb | UTF-8 | 174 | 2.953125 | 3 | [] | no_license | def correct_hash(wrong_hash)
corrected_hash = {}
wrong_hash.each do |key, value|
key = value[0].to_sym
corrected_hash[key] = value
end
corrected_hash
end
| true |
8535b7f499752b162739ba326123616fb3af5f3d | Ruby | TheGuth/launch_school | /course_170/book_viewer_practice/dynamic_directory_index/dynamic_directory_index.rb | UTF-8 | 624 | 2.703125 | 3 | [] | no_license | require "sinatra"
require "sinatra/reloader"
require "tilt/erubis"
require 'pry'
get "/" do
# @data = Dir.glob("public/*") # grabs all files that meet description which
# the * splat operator says grab everything.
@data = Dir.glob("public/*").map { |file| File.basename(file) }.sort # grabs all files in a directo... | true |
6178891ac32ba8e9cf7700cfb1442c8d67c78bec | Ruby | appabhop/mastermind | /compact.rb | UTF-8 | 255 | 3.03125 | 3 | [
"MIT"
] | permissive | w=File.readlines("wordslist.txt").sample.chomp.upcase;l=w.length;v=l
while 1
if(l==0)then puts w;exit end
g=gets.upcase;s=(0..w.size-1).count{|i|g[i]==w[i]}
if(s==v)then puts"W";exit;else l-=1;puts"#{s.to_s}/#{v.to_s}, #{l.to_s} left";end
end
| true |
f7bf47b070b7e89f2178b32440e0d0438871f0c4 | Ruby | Keemotion/myrrha | /examples/to_ruby_literal_foo.rb | UTF-8 | 233 | 3.21875 | 3 | [
"MIT"
] | permissive | require "myrrha/to_ruby_literal"
class Foo
attr_reader :arg
def initialize(arg)
@arg = arg
end
def to_ruby_literal
"Foo.new(#{arg.inspect})"
end
end
Myrrha.to_ruby_literal(Foo.new(:hello))
# => "Foo.new(:hello)"
| true |
90a1835e8e1cc38f9036189dc8b927360d412b1e | Ruby | kylemccurley/RB101_RB109_Small_Problems | /Easy4/string_to_signed_integer.rb | UTF-8 | 2,345 | 4.6875 | 5 | [] | no_license | =begin
In the previous exercise, you developed a method that converts simple numeric strings to Integers.
In this exercise, you're going to extend that method to work with signed numbers.
Write a method that takes a String of digits,
and returns the appropriate number as an integer.
The String may have a leading + o... | true |
72863ee1540beb1b0354779fba3bcce91d1acbc1 | Ruby | karthiks/conways_game_of_life_1 | /spec/game_of_life_spec.rb | UTF-8 | 3,191 | 2.921875 | 3 | [] | no_license | require 'spec_helper'
describe GameOfLife::Game do
describe "initialization" do
context "no input is given" do
subject { GameOfLife::Game.new }
it " # should initialize colony with a default size of 3 Rows and 3 columns, 0 lives and 0 generations-to-go" do
#subject.colony.seed(lives, genera... | true |
627f547f85925f1d267b2676a49ed9938ddadcff | Ruby | nrser/state_mate | /spec/state_mate/adapters/pmset/write_spec.rb | UTF-8 | 1,730 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'state_mate/adapters/pmset'
describe "StateMate::Adapters::PMSet.write" do
include_context "pmset"
it "errors when the key is not two elements" do
expect{ pmset.write [] }.to raise_error ArgumentError
expect{ pmset.write ["Battery Power"] }.to raise_error ArgumentError
... | true |
4fcc2d690c1a852d0f7f9ba749b25dd97691d87a | Ruby | rubygems/rubygems.org | /app/models/oidc/access_policy.rb | UTF-8 | 2,360 | 2.609375 | 3 | [
"MIT"
] | permissive | class OIDC::AccessPolicy < OIDC::BaseModel
class Statement < OIDC::BaseModel
def match_jwt?(jwt)
return unless principal.oidc == jwt[:iss]
conditions.all? { _1.match?(jwt) }
end
class Principal < OIDC::BaseModel
attribute :oidc, :string
validates :oidc, presence: true
end
... | true |
0c138a15c3d7cf0816b311112d7f079548040948 | Ruby | 18xx/baron | /lib/baron/action/place_token.rb | UTF-8 | 965 | 3.015625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Baron
class Action
# This action is where a company places a tile on the board
#
# The tile is places in a hex with a specific orientation. This placement
# can be either a standard placement of a yellow tile, or an upgrade
# of an existing tile to another tile... | true |
b128bbe0b96a7b72b962a0cd01fb498daeff3c17 | Ruby | sagemlee/restaurant_2003 | /lib/restaurant.rb | UTF-8 | 360 | 3.34375 | 3 | [] | no_license | class Restaurant
attr_reader :opening_time,
:name
def initialize (opening_time, name)
@opening_time = opening_time
@name = name
@dishes = []
end
def dishes
@dishes
end
def closing_time (hours)
storehours = @opening_time.to_i + hours
storehours.to_s + ":00"
end
dishes = []
def a... | true |
8ba4f15b31392b7a0087ea76ef2d08b0b8d2313e | Ruby | daniel2234/rock_paper_scissors_spock_lizard | /rock_paper_scissors_spock_lizard.rb | UTF-8 | 2,465 | 3.78125 | 4 | [] | no_license | VALID_CHOICES = ['rock', 'scissors', 'paper', 'lizard', 'spock']
def prompt(message)
puts "=>#{message}"
end
def win?(player, computer)
(player == 'scissors' && computer == 'paper') ||
(player == 'paper' && computer == 'rock') ||
(player == 'rock' && computer == 'lizard') ||
(player == 'lizard' && computer ... | true |
648647a3c1842a715a743e7faf49a67e0aeaf45c | Ruby | ddmck/roulette | /main.rb | UTF-8 | 592 | 3.875 | 4 | [] | no_license | # ARRAYS =======================
black = [2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33,
35]
red = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34,
36]
zero = [0, 37] # 37 is the equivalent of "00"
# VARIABLES ===================
bk = 0
rd = 0
zr = 0
# # OF ROLLS ==================
... | true |
58eca7c6b750201c86c76cdc3e58454b76fb751d | Ruby | ynonp/rails-2.3-examples | /demo02/lib/magic_hat.rb | UTF-8 | 310 | 3.015625 | 3 | [] | no_license | class MagicHat
STUFF = ['rabbit', 'dove', 'tiger', 'ribbon', 'banana']
def pick_something
STUFF.sample
end
def find_all(query)
# convert query to string as it could be nil
# (and nil converted to string is the empty string)
STUFF.reject {|item| item.index(query.to_s).nil? }
end
end
| true |
2c360edbc4714f96af18323db3634f86d47a69a1 | Ruby | derekle/reverse-each-word | /reverse_each_word.rb | UTF-8 | 214 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
reversedArray = []
splitString = string.split
splitString.collect{|x| reversedArray << x.reverse}
reversedString = reversedArray.join(" ")
return reversedString
end | true |
8d54055dde5d853af4717bb41313d1b596af622b | Ruby | hyde1004/yut_game | /stick.rb | UTF-8 | 278 | 3.3125 | 3 | [] | no_license | class Stick
attr_accessor :state
def initialize(init_state = :front)
if init_state == :front or init_state == :rear
@state = init_state
else
@state = :front
end
end
def shuffle
if rand(0..1) % 2 == 0
@state = :front
else
@state = :rear
end
end
end | true |
71e1572f0b8cca31a8f1e919fa6216d9561cb7d0 | Ruby | srobert1953/introduction-to-programming | /basics/symbols.rb | UTF-8 | 203 | 2.765625 | 3 | [] | no_license | # Symbols are kind of strings, but they don't change as strings may.
# We use them as a reference and we don't want to print them
# Symbols start with ':'
:symbol
:another_symbol
:"And I am also symbol"
| true |
9b904025c7162f722ae41e447615499842c84bfd | Ruby | dmiz6393/dogs_shelter_project | /lib/cli.rb | UTF-8 | 1,721 | 3.40625 | 3 | [] | no_license | $prompt = TTY::Prompt.new
class CommandLineInterface
def greet
puts "Welcome to Paws! Find your perfect dog match here"
end
def create_user
puts "To get started, let's create an account for you"
puts "Please enter your first name"
@first_name= gets.chomp
puts... | true |
95406f531f47a2d162a0edaf07aab4f583824174 | Ruby | mvr/jiggle | /lib/jiggle/vector2.rb | UTF-8 | 708 | 3.3125 | 3 | [
"MIT"
] | permissive | module Jiggle
class Vector2
def -@
jgv(0, 0) - self
end
def +@
self
end
def perpendicular
jgv(-y, x)
end
def unit
jgv(x/length, y/length)
end
alias :<=> :distance_to
def to_s
"(#{x}, #{y})"
end
def inspect
"#... | true |
1cb14b3d862b1887a3237bca307d97d64d038aa9 | Ruby | edhowland/minitest-reporters-json_reporter | /test/fake_tests.rb | UTF-8 | 1,452 | 2.9375 | 3 | [
"MIT"
] | permissive | # fake_tests.rb - methods, classes for specs to simulate Minitest tests
# modify Minitest::Reporters::JsonReporter to override count of failures, errors and skips
class Minitest::Reporters::JsonReporter
def failures
tests.count { |e| !e.skipped? && !e.error? && !e.passed? }
end
def errors
tests.count(&... | true |
456effde9debf43e3ac0608317abca95fa863b7c | Ruby | ejohns11-2019/Casino_Project_Gr4 | /wallet.rb | UTF-8 | 542 | 3.515625 | 4 | [] | no_license | require_relative 'Person'
class Wallet
attr_accessor :person
#
def initialize(person)
@person = person
show_wallet
end
def show_wallet
puts @person.money
puts "Would you like to add more money y/n?"
input = gets.chomp.to_str
if input == 'y'
add_money
else
exit #how do i get this to loop back to... | true |
0c89a35f9aac2ae8757868e5e30239cadbabdb6b | Ruby | latinman/wyncode_projects | /wyncode.rb | UTF-8 | 311 | 3.0625 | 3 | [] | no_license | puts <<END
#Length vs Size
puts "Ernesto".length
puts "Ernesto".Size
END
#Rounding out numbers
p 342.6937.round(2)
#Hockey Teams
NHL = ["Canadiens", "Blackhawks", "Flames", "Canucks", "Ducks"] #Canadiens are the best team:)
puts NHL[0]
#Concatination
puts "Can't wait to be" + " a software engineer." | true |
1943fadf0db32455a48b05c35cea6ac5934ff3af | Ruby | richieganney/bank-tech-test | /spec/bank_account_spec.rb | UTF-8 | 2,216 | 3.15625 | 3 | [] | no_license | # frozen_string_literal: true
require 'bank_account'
describe BankAccount do
subject(:bank_account) { described_class.new }
describe '#deposit' do
it 'allows the user to desposit the first £50 into their bank account' do
bank_account.deposit(50)
expect(bank_account.account_balance).to eq 50
e... | true |
98d118ecfd415ba009da500a601c9bcd8fdf0a4b | Ruby | seanredmond/marcxella | /lib/marcxella/datafield.rb | UTF-8 | 623 | 3.03125 | 3 | [
"MIT"
] | permissive | module Marcxella
class DataField
attr_reader :tag, :ind1, :ind2, :subfields
def initialize(node)
@tag = node['tag']
@ind1 = node['ind1']
@ind2 = node['ind2']
@subfields = node.css('subfield').map{|s| SubField.new(s)}
end
def value
@subfields.map{|s| s.value}.join('')
... | true |
fd27a5af7f73656cf31228c65d96de599dcc0f23 | Ruby | coingecko/cryptoexchange | /lib/cryptoexchange/exchanges/forkdelta/market.rb | UTF-8 | 1,792 | 2.5625 | 3 | [
"MIT"
] | permissive | module Cryptoexchange::Exchanges
module Forkdelta
class Market < Cryptoexchange::Models::Market
NAME = 'forkdelta'
API_URL = 'https://api.forkdelta.app'
TOKEN_URL = 'https://forkdelta.app/config/main.json'
def self.trade_page_url(args={})
"https://forkdelta.app/#!/trade/#{a... | true |
1d5058294918b5b453a5c09f8ae269b3527ee397 | Ruby | cdpalmer/boggle_solver | /boggle.rb | UTF-8 | 969 | 3.34375 | 3 | [] | no_license | class BoggleSolver
%w(board boggle letter_tile scrabble_dictionary_reader word).each do |file|
require "./#{file}.rb"
end
attr_accessor :found_words
def initialize
@found_words = []
end
def start_search
Board.values.each_with_index do |row, y|
row.each_with_index do |letter, x|
... | true |
79f464e780b8c00f12ad5f857e3565dcb119600b | Ruby | davidcornu/minitag | /lib/minitag/tag.rb | UTF-8 | 992 | 3.421875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Minitag
# Represents a tag in our system.
# Provides helper methods to identify the type of a tag, which can
# only one of the following:
# - inclusive
# - exclusive (name with ~ as a prefix)
class Tag
attr_reader :name
# Initializes a tag. Tags with a ~ pr... | true |
07c6e05d09fa45507bba4e4ae77cfa87046a41e7 | Ruby | andruby/anonymize | /examples/ssh_tunnel.rb | UTF-8 | 1,112 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative '../lib/anonymize.rb'
require 'mysql2'
require 'net/ssh/gateway'
require 'faker'
# Set up an ssh gateway
gateway = Net::SSH::Gateway.new('ssh_host', 'ssh_username')
port = gateway.open('127.0.0.1', 3306, 3307)
# Connect through the local ssh gateway to the real server
connection = Mysql2::Client.new... | true |
639094083518ec00e3714bcd9750aaba993c2a5e | Ruby | JK8283/BEWD | /midterm.rb | UTF-8 | 978 | 3.5625 | 4 | [] | no_license | require 'pry' # binding.pry
require 'rest-client'
require 'json'
require_relative 'lib/movie'
# require_relative 'lib/actor'
def lookup_movie
puts "-----------New Movie Actors Search-----------"
puts "What is the name of the movie?"
title = gets.strip
puts "What year was #{title} released?"
year = gets.to_... | true |
d6122949d92cc2b2f03a6c30d207b69927f6ef5d | Ruby | licorm/TwO-O-Play | /players.rb | UTF-8 | 270 | 3.671875 | 4 | [] | no_license | class Players
attr_accessor :name, :lives
def initialize(name)
@name = name
@lives = 3
end
def lives
@lives
end
def lose_life
@lives -= 1
puts "You lost a life."
end
def is_alive
if @lives > 0
true
end
end
end
| true |
6a657e63e6e46d60dfe96fb62e88283af3a5c30a | Ruby | yarmiganosca/devise_ad_authenticatable | /lib/devise_ad_authenticatable/strategy.rb | UTF-8 | 1,207 | 2.515625 | 3 | [] | no_license | require 'devise/strategies/authenticatable'
module Devise
module Strategies
# Strategy for signing in a user based on his login and password using AD.
# Redirects to sign_in page if it's not authenticated
class AdAuthenticatable < Authenticatable
def valid?
valid_controller? && valid_params... | true |
856727392f3fb799c6b2b50e5cf926e757eddb98 | Ruby | DSierra210/Ruby-Exercises | /monkey_patching_project/lib/array.rb | UTF-8 | 1,151 | 3.6875 | 4 | [] | no_license | # Monkey-Patch Ruby's existing Array class to add your own custom methods
class Array
def span
return self.max - self.min if self.length > 0
nil
end
def average
return nil if self.length == 0
self.sum(0.0) / self.length
end
def median
return nil if self.le... | true |
f6b70a04f3acb0171c899d3c9bfee96d8abb8ef9 | Ruby | Mastermindzh/Seven-Languages-in-Seven-Weeks | /Ruby/day1/lib/main.rb | UTF-8 | 440 | 4.15625 | 4 | [
"MIT"
] | permissive | # print hello world
puts 'Hello, world.'
# find index of ruby in Hello Ruby
hello_ruby = 'Hello Ruby'
puts hello_ruby.index('Ruby').to_s
# print name 10 times
my_name = "Rick van Lieshout"
x = 10
while x > 0
puts my_name
x -= 1
end
#Print the string “This is sentence number 1,” where the number 1 changes from 1 ... | true |
7d422726f88aacea809599cfc707329694c21905 | Ruby | GaspardPO/ruby_tuto_openclassroom | /jeu/src/personne.rb | UTF-8 | 659 | 3.234375 | 3 | [] | no_license | class Personne
attr_accessor :nom, :points_de_vie, :en_vie
def initialize(nom)
@nom = nom
@points_de_vie = 100
@en_vie = true
end
def info
if en_vie
"#{nom} (#{points_de_vie}/100 pv)"
else
"#{nom} (vaincu)"
end
end
def subit_attaque(degats_recus)
@points_de_vie -= ... | true |
ed7b3eeb8592ca4a31c4823d50568a868ce97740 | Ruby | holla1144/education | /Learn Ruby the Hard Way/ex45/scenes/indie_studio_scene.rb | UTF-8 | 2,331 | 3.46875 | 3 | [] | no_license | class IndieStudio
@@mk_move_values = {
'k' => 3,
'p' => 5,
'j' => 7,
'c' => 9
}
def play()
puts "You arrive at Indiesoft studios, located in a hip area on the edge of Chicago's Bucktown neighborhood."
puts "You get yourself an $8 coffee, and head inside to talk to someone named \"Jeff\",... | true |
af5d04ed89df0729f5d1cc37d4351bca20181933 | Ruby | helloRupa/petster | /app/models/pet.rb | UTF-8 | 2,940 | 2.625 | 3 | [] | no_license | class Pet < ApplicationRecord
validates :name, uniqueness: true, length: { minimum: 3 }
has_many :photos
has_one :profile_photo, -> { where profile_photo: true }, class_name: 'Photo'
has_many :posts
has_many :comments
has_many :commented_posts, through: :comments, source: :post
has_many :likes
has_many... | true |
62a6d058831888f065f24fc6e685e5efa822aa12 | Ruby | bess/northwest-digital-archives | /vendor/plugins/blacklight/vendor/gems/mwmitchell-rsolr-ext-0.7.35/lib/rsolr-ext/request/queryable.rb | UTF-8 | 1,408 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | # a module to help the creation of solr queries.
module RSolr::Ext::Request::Queryable
# Wraps a string around double quotes
def quote(value)
%("#{value}")
end
# builds a solr range query from a Range object
def build_range(r)
"[#{r.min} TO #{r.max}]"
end
# builds a solr query fragment
... | true |
ea357435ff610dc2fc94d5d67214a52cc46b209a | Ruby | bitflingr/thumby | /lib/thumby/helpers.rb | UTF-8 | 4,315 | 2.546875 | 3 | [
"MIT"
] | permissive | class Thumby
class SinatraApp < ::Sinatra::Base # :nodoc:
helpers do
require 'thumby/helpers/url_helpers'
require 'thumby/helpers/http_helpers'
require 'thumby/helpers/decode_helpers'
def cleanup_gif(img)
# if @gif_mode == 'single'
# $logger.info 'Coalescing GIF, convert... | true |
7308a837ddecb421f9df874c1f47eb8862324a09 | Ruby | el-mark/Ironhack_complete | /Pre_Work/ruby/first-ruby-script/hello.rb | UTF-8 | 838 | 4.0625 | 4 | [] | no_license | puts "Hello, world!"
puts "I"
puts "like"
puts "pie."
print "Cookies"
print "are"
print "good"
print "too."
# This is a comment
puts "Hello, world!"
puts "Hello again!" # This also works for a comment
my_variable = 10
operation_result = 12 * 34
puts "Operation result is "
puts operation_result
puts "my_variable ... | true |
a55afdbad2bdbb3c2f237c4c8750e3548fe6dc50 | Ruby | civol/HDLRuby | /lib/HDLRuby/hruby_values.rb | UTF-8 | 18,034 | 2.828125 | 3 | [
"MIT"
] | permissive | module HDLRuby
##
# Library for implementing the value processing.
#
########################################################################
# To include to classes for value processing support.
module Vprocess
# TRUNC_P_T = 65536.times.map { |i| 2**i - 1 }
# TRUNC_N_T = 6553... | true |
9d5da68cf45090c8462933f0a9987b9e1f223f53 | Ruby | kopischke/mmd2en | /test/metadata_test/processors.rb | UTF-8 | 5,482 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | # encoding: UTF-8
require 'metadata/processors'
require 'tempfile'
class TestProcessor < Minitest::Test
def test_creates_instance_of_shellrunner
shell_runner = Minitest::Mock.new
shell_runner.expect :new, self
Metadata.stub_const(:ShellRunner, shell_runner) do
Metadata::Processor.new
end
sh... | true |
43dfab71ac229a686678cbad01502f21155f3853 | Ruby | evilstreak/pipe-dream-prototype | /lib/tile/block.rb | UTF-8 | 224 | 2.515625 | 3 | [] | no_license | require './lib/tile.rb'
class Tile::Block < Tile
public_class_method :new
private
def draw_water
# No water!
end
def flow_exits
# No exits!
[]
end
def top_layer_image
'block.png'
end
end
| true |
7144516747d3141571400fdd3933a822fec56463 | Ruby | magas4891/soccer | /index.rb | UTF-8 | 509 | 3.125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'game.rb'
puts 'Введите название файла'
filename = gets.chomp.to_s
f = IO.readlines(filename, chomp: true)
team = {}
arr = []
count = 1
f.each do |x|
arr.append(Game.new(x).foo)
team[x.split(', ')[0][0..-3]] = 0
team[x.split(', ')[1][0..-3]] = 0
end
arr.each { ... | true |
5b323a2660f32fe9e4837ac1ab543c8c7723442e | Ruby | chavonrosenthal/tealeaf-precourse | /flow_control/caps.rb | UTF-8 | 337 | 4.8125 | 5 | [] | no_license | #Write a method that takes a string as argument. The method should return the all-caps
#version of the string, only if the string is longer than 10 characters.
#Example: change "hi there" to "HI THERE".
def caps(string)
if string.length > 10
string.upcase
else
string
end
end
puts caps("Hello, world!"... | true |
e088152419d859052e3291fddb118ad37059be4e | Ruby | myokoym/project_euler | /problem024/problem024.rb | UTF-8 | 625 | 3.546875 | 4 | [] | no_license | class Problem024
#def self.lexicographic_order(digits)
# digitss = []
# (digits.size - 1).times { digitss << digits }
# permutation = digits.product(*digitss).reject {|a| a.uniq.size != digits.size }
# return permutation.map {|a| a.to_s }
#end
def self.lexicographic_order(digits)
digits.permuta... | true |
8f27af298393ac600d6b24cd59cdc856e93fb54c | Ruby | nolman/magellan | /lib/magellan/broken_link_tracker.rb | UTF-8 | 1,393 | 3.015625 | 3 | [] | no_license | module Magellan
# The class that will track all broken links, urls that return 4** or 5** http status codes.
class BrokenLinkTracker
include Observable
# All results containing 4** or 5** http status codes
attr_reader :broken_links
# Create a new broken link tracker
def initialize
@b... | true |
3400811de2d6cb0348ca9cfb2b43a154a75f09b6 | Ruby | eventide-project/mimic | /lib/mimic/subject_methods.rb | UTF-8 | 298 | 2.78125 | 3 | [
"MIT"
] | permissive | module Mimic
def self.subject_methods(cls)
instance_method_names = cls.instance_methods.sort
instance_method_names -= Mimic.preserved_methods
instance_methods = instance_method_names.map do |method_name|
cls.instance_method(method_name)
end
instance_methods
end
end
| true |
23b45b8c92dd8de4c958598fdc0da313119f4479 | Ruby | badeball/rmonitor | /lib/rmonitor/commands/cl/list.rb | UTF-8 | 1,129 | 2.53125 | 3 | [
"MIT"
] | permissive | require "rmonitor/commands/list"
class RMonitor
module Commands
module CL
class List
def initialize(options = {})
@out = options[:out] || $stdout
@list = options[:list] || RMonitor::Commands::List.new(options)
@matcher = options[:matcher] || RMonitor::Matcher.new(optio... | true |
5ee46c990b00c4c2819eb275e568ab8b33ad2639 | Ruby | jmkiley/reverse-each-word-001-prework-web | /reverse_each_word.rb | UTF-8 | 203 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
array = sentence.split(' ')
sentence_back = []
array.collect do |word|
sentence_back << word.reverse!
end
sentence_back = array.join(' ')
sentence_back
end | true |
1eca99aeed0c0ea89902f483687188cdf5ead6ee | Ruby | victoriaevandijk/blocitoff | /db/seeds.rb | UTF-8 | 889 | 2.78125 | 3 | [] | no_license | require 'faker'
50.times do
User.create!(
name: Faker::Name.name,
email: Faker::Internet.email,
password: Faker::Lorem.characters(10)
)
end
users = User.all
User.create!(
name: "Torie",
email: 'victoriaevandijk@gmail.com',
password: 'helloworld'
)
100.times do
List.create(... | true |
bd463eb76ef48aaa5c882e9f7b372ff29813661f | Ruby | rstacruz/shake | /test/unit/params_test.rb | UTF-8 | 1,430 | 2.65625 | 3 | [] | no_license | require File.expand_path('../../test_helper', __FILE__)
class ParamsTest < Test::Unit::TestCase
class Bake < ::Shake
task :heat do
wrong_usage if params.size != 1
puts "OK"
end
task :cool do
quiet = params.delete('-q')
type = params.extract('-t') || params.extract('--type') || ... | true |
fc939b51399bd09856b369f689a3032ed52b6ef4 | Ruby | yunglleung1/OO-mini-project-nyc-web-062518 | /app/models/Ingredient.rb | UTF-8 | 889 | 3.4375 | 3 | [] | no_license | class Ingredient
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all# should return all of the ingredient instances
@@all
end
def ingredients_allergens# returns all of allergens for this ingredient
Allergen.all.select do |allergen|
allergen.ingr... | true |
11d22a3028423e6bd49f8cc0632a7372bc499ce0 | Ruby | taylormcdowell/super-anthony-world | /classes/player.rb | UTF-8 | 70,874 | 2.53125 | 3 | [] | no_license | class Player
attr_reader :x, :y, :direction, :coins, :vel_x, :vel_y, :strength, :score, :hiscore, :game_over,
:time_attck, :health, :alive, :tinman, :fireman, :zorro_bat, :pipe_y, :axes, :fireballs, :complete,
:rubies, :emeralds, :sapphires, :battling, :time, :ducking_rate, :fast_time,
:level_super, :level... | true |
1f5c96d4245da012364f5883aeaf3ec6ff99dedf | Ruby | LeahGriffin/imageblur3 | /imageblur3.rb | UTF-8 | 1,398 | 3.75 | 4 | [] | no_license | class Image
def initialize (picture)
@picture = picture
end
def get_ones
ones = []
@picture.each_with_index do |row, row_number|
row.each_with_index do |item, col_number|
if item == 1
ones << [row_number, col_number]
end
end
end
ones
end
def blur!(b... | true |
077771d52eff2e63a18149779e2265a57966c8e9 | Ruby | shsachdev/ls101 | /reversed_number_training.rb | UTF-8 | 58 | 2.703125 | 3 | [] | no_license | def reversed_number(number)
number.digits.join.to_i
end
| true |
58e28635fd1cc2e62d1609f2622dbc6d40a438b1 | Ruby | modulexcite/p2pwebclient | /documents/final/ruby_to_tex.rb | UTF-8 | 4,101 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'erb'
#
# translates a .erb file to latex :)
# note--if you want subfigures then at the very beginning of your latex file you'll want to \include{subfigure}
#
# Helper methods
=begin
doctest: String#indent
>> 'abc'.indent
=> ' abc'
>> "abc\ndef\nyo".indent
=> " abc\n def\n yo"
=end
class String
def inde... | true |
35a21cb2d42ec1ab6619762bdd83998d53bd1f9e | Ruby | edenisn/imgur_clone | /test/models/user_test.rb | UTF-8 | 1,740 | 2.578125 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
setup do
@user = users(:user1)
end
test "should not save user with blank username" do
@user.username = ""
assert_not @user.save
end
test "should not save user with not unique username" do
assert_raise("Username has already been ... | true |
f9dc849a1af0b3fc76b728e30b25ce5ea214745e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/195d4a3f93ec4842affaf0c49cf9a4b0.rb | UTF-8 | 340 | 3.46875 | 3 | [] | no_license | class Phrase
attr_reader :phrase
def initialize(phrase)
@phrase = phrase
end
def word_count
counts = Hash.new { 0 }
words.each do |w|
counts[w] += 1
end
counts
end
private
def words
normalized_phrase.split
end
def normalized_phrase
phrase.downcase.gsub /[^A-Z\d... | true |
b71652e10e4857c1967d46b32048c4489b45765e | Ruby | Terry-Thompson/ttt-with-ai-project-v-000 | /lib/players/computer.rb | UTF-8 | 4,046 | 3.203125 | 3 | [] | no_license | class Players::Computer < Player
def move(board)
viable = []
@mine = []
@theirs = []
board.cells.each_with_index do |cell, index|
viable << index if cell == " "
end
board.cells.each_with_index do |cell, index|
if cell == self.token
@mine << index
elsif cel... | true |
a17b9210b31d50903abf6fbe7adcbde3193c0293 | Ruby | JoyRandel/coding-challenges | /love_letter.rb | UTF-8 | 936 | 3.34375 | 3 | [] | no_license | puts "I Love You. Do you Love Me?"
answer = gets.chomp.downcase
my_love_loop = [
"Love bears all things, believes all things, hopes all things, endures all things. - The Bible : 1 Corinthians., Do you love me?",
"You don't marry someone you can live with, you marry the person who you cannot live without. - Anonymo... | true |
42159a47a0ce41273a97e99d65e5bf6ab0911ad5 | Ruby | madebymany/environmentor | /lib/environmentor/attribute.rb | UTF-8 | 3,074 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | require_relative 'type_coercer'
module Environmentor
class Attribute
Absent = Object.new
class ValidationError < StandardError
attr_reader :attr
def initialize(attr, mappers, opts, message: "Validation error")
@attr = attr
@mappers = mappers
@opts = opts
@message... | true |
2dd9993c27281810990b380775768ae8ab89ec9e | Ruby | achan/budget | /lib/models/income.rb | UTF-8 | 317 | 3.09375 | 3 | [
"MIT"
] | permissive | class Income
attr_accessor :name, :account, :amount_in_cents, :frequency, :tithable
def tithable?
tithable == true
end
def ==(other_income)
%i(name account amount_in_cents frequency tithable).each do |attr|
return false unless send(attr) == other_income.send(attr)
end
true
end
end
| true |
0ad279e125045f64b9034fab0886c23eadaadb3e | Ruby | adamrubin/teacup | /lib/teacup-ios/stylesheet_extensions/device.rb | UTF-8 | 2,438 | 2.890625 | 3 | [
"BSD-2-Clause"
] | permissive | # Example:
# Teacup::Stylesheet.new :main do
# style :root,
# origin: [0, 0]
#
# # device returns a bitmask of devices,
# # device? expects a device bitmask, and returns true if it is present in
# # device (the conditions below are equivalent)
# if 0 < device & iPhone || device... | true |
eb4e962cd66f16feecc6de52c5671ba7cde4d906 | Ruby | lmrodriguezr/enveomics | /Scripts/lib/enveomics_rb/utils.rb | UTF-8 | 1,998 | 2.75 | 3 | [
"Artistic-2.0"
] | permissive |
require 'enveomics_rb/errors'
require 'zlib'
def use(gems, mandatory = true)
gems = [gems] unless gems.is_a? Array
begin
require 'rubygems'
while !gems.empty?
require gems.shift
end
return true
rescue LoadError
abort "\nUnmet requirements, please install required gems:" +
gems.ma... | true |
77dfe4e0200f1d6bf4b87a26980ab2d83f3cd8a9 | Ruby | kudzooman/wikiota | /db/seeds.rb | UTF-8 | 1,081 | 2.796875 | 3 | [] | no_license | require 'faker'
5.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: Faker::Lorem.characters(10)
)
user.skip_confirmation!
user.save
end
users = User.all
10.times do
Article.create(
user: users.sample,
title: Faker::Lorem.sentence,
body: Fake... | true |
08e01b06a0b44919ee43ffff7890bb489e7c6254 | Ruby | remi/venyr | /lib/broadcast.rb | UTF-8 | 982 | 2.71875 | 3 | [] | no_license | class Broadcast
def initialize
@thread = Thread.new do
redis = Redis.new(timeout: 0)
Thread.current['channels'] = []
redis.psubscribe("broadcast.*") do |on|
on.pmessage do |pattern, channel, message|
user = channel.split(/^broadcast\./).last
broadcasters = Thread.cu... | true |
4e20f64f3f449edb9c7d8074fce252bdbb2e6f51 | Ruby | pulibrary/figgy | /app/services/geo_discovery/document_builder/basic_metadata_builder.rb | UTF-8 | 3,693 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
module GeoDiscovery
class DocumentBuilder
class BasicMetadataBuilder
attr_reader :resource_decorator
def initialize(resource_decorator)
@resource_decorator = resource_decorator
end
# Builds fields such as id, subject, and publisher.
# @param [A... | true |
5cbc91b30299270a564436baf419275b19452993 | Ruby | redmansal/C41100_Ruby | /6 spam rater/p6_1_spam_rater/lib/main.rb | UTF-8 | 901 | 3.03125 | 3 | [] | no_license | #
# main.rb
#
# author: Colm Nolan
# last modified: 27 October, 2011
# description This program check 10 emails and rates how much they might be consided
# to be advance-fee fraud emails. The first five are while the second fine are not
require '../lib/email.rb'
require '../lib/spam.rb'
spam... | true |
125e08244061ccd351e415801d1ba119196eaa17 | Ruby | kanayataichi/e-learning_app | /app/controllers/user_controller.rb | UTF-8 | 3,605 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# 画面名:ユーザマスタメンテナンス
# クラス名:ユーザマスタメンテナンスコントローラー
# 概要:ユーザマスタへの登録・更新・削除を行なう。
# 作成日:2014/01/05 金谷
class UserController < ApplicationController
# 初期表示
def index
# フォーム表示用インスタンス生成
@user = User.new
# 一覧表示用にユーザ情報を取得
@users = User.paginate(page: params[:page], :per_page => 3)
... | true |
919fb8368143dd2dce8bb310a702e55181777b5f | Ruby | erinleeny/spring-scripting-2017 | /fakergem.rb | UTF-8 | 573 | 3.0625 | 3 | [] | no_license | require "Faker"
require "CSV"
#puts Faker::Name.name
CSV.open("fakerlife.csv","wb") do |csv|
array = Faker::Name.name.split()
email = Faker::Internet.email
number = Faker::PhoneNumber.phone_number
lat = Faker::Address.latitude
lon = Faker::Address.longitude
puts array
if array.length == 2
csv << [arra... | true |
625e89cf1cc8016e68ab83b850a85ded68e07f76 | Ruby | krlenell/app-academy-open | /Foundations/oop/mastermind_project/spec/code_spec.rb | UTF-8 | 5,208 | 3.71875 | 4 | [] | no_license | require 'code'
puts "\nNOTE: Once you complete all specs, run `ruby lib/play_mastermind.rb` in your terminal!"
describe 'Code' do
let(:code) { Code.new(%w[R G R B]) }
describe '::POSSIBLE_PEGS' do
it 'is a hash containing letters containing letters as keys and colors as values' do
expect(Code::POSSIBLE... | true |
9d40146f60eacaa7b7b72d1c61940d544e384358 | Ruby | Benc93/boris-bikes | /lib/garage.rb | UTF-8 | 248 | 2.8125 | 3 | [] | no_license | require 'bike_container'
require 'bike'
class Garage
include BikeContainer
def initialize(options = {})
self.capacity=(options.fetch(:capacity, capacity))
end
def repair
bikes.map {|bike| bike.fix!}
end
end | true |
18e8169972d1e351aeac2dea3adfe458404e173c | Ruby | ojbucao/knights-tour | /lib/unique_queue.rb | UTF-8 | 335 | 3.46875 | 3 | [] | no_license | require 'set'
class UniqueQueue
def initialize
@queue = []
@history = Set.new
end
def push(arg)
if !@history.include?(arg) && !@queue.include?(arg)
@history << arg
@queue << arg
end
end
def items
@queue
end
def shift
@queue.shift
end
def empty?
@queue.e... | true |
3eeb7ab317eead44118e8f0b2ab020bb7517e000 | Ruby | cyclingzealot/canadaWithPR | /main.rb | UTF-8 | 2,182 | 3.09375 | 3 | [] | no_license | #!/usr/bin/ruby -w
require 'nokogiri'
require 'open-uri'
require 'pp'
require 'set'
start = Time.now
url = "https://www.sfu.ca/~aheard/elections/1867-present.html"
doc = Nokogiri::HTML(open(url))
rows = doc.xpath('//*[@id="table6"]//tr')
data = {}
rowCount = 0
year = 10000
limit = 1945
if ! ARGV[0].nil?
limit... | true |
211c32ba73e20e96b5496e6f9a656febf472853a | Ruby | frankliu81/fundsy | /spec/controllers/campaigns_controller_spec.rb | UTF-8 | 7,986 | 2.625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe CampaignsController, type: :controller do
# shortcut for memoization
let(:campaign) { FactoryGirl.create(:campaign)}
# make use of memoization
# def campaign
# # if @campaign is nil it will call FactoryGirl.create(:campaign)
# # otherwise it will just return @camp... | true |
7cdd2a7958e973cc46323de16217fc902132a455 | Ruby | boddhisattva/checking_credit_cards | /lib/card_input_parser.rb | UTF-8 | 943 | 3.515625 | 4 | [] | no_license | # frozen_string_literal: true
require_relative '../lib/card'
class CardInputParser
def parse
card_numbers = get_card_numbers
card_numbers.map do |card_number|
Card.new(card_number)
end
end
private
def get_card_numbers
puts get_card_numbers_message
card_numbers = []
w... | true |
ed1180147e0989b8cecc3b26d4f89196ee75aa3e | Ruby | jr1412594/ruby-check | /ternary_operator.rb | UTF-8 | 468 | 3.953125 | 4 | [] | no_license | # if 1 < 2
# puts "Yes"
# else
# puts "Nope"
# end
# puts 1 < 2 ? "yes" : "no"
# puts "Yes" == "yes" ? "Yes you dummy" : "no you dummy"
# def even_or_odd(number)
# number.even? ? "This is even" : "Not even"
# end
# p even_or_odd(6)
# p even_or_odd(13)
# pokemon = "Pikachu"
def check_pokemon(pokemon)
... | true |
0c4ae9c378e8176ba5cf8817613708d5f7301807 | Ruby | RongRongTeng/phone_number_formatter | /formatter/phone_number/uk.rb | UTF-8 | 1,099 | 3.125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Formatter
module PhoneNumber
module UK
PREFIX = '+447'
DIGIT_LENGTH = 9
PREFIX_REGEXP = /^(?<prefix>\+44|44|0)(?<fixed_digit>7)/.freeze
DIGIT_REGEXP = /(?<digits>\d{#{DIGIT_LENGTH}})$/.freeze
FORMAT_REGEXP = Regexp.new(PREFIX_REGEXP.source + DIG... | true |
29ea4d13a07fc12b6d03153d04e8a085ccf469f5 | Ruby | ivanburrola/billing-telephony | /lib/mediator_options.rb | UTF-8 | 1,652 | 2.640625 | 3 | [] | no_license | # encoding: utf-8
require 'optparse'
require 'optparse/time'
# This script is supposed to be run every 20 minutes.
$minutes_between_runs = 20
class MediatorOptions
Version = [ 0, 0, 1 ]
def self.parse(args)
options = OpenStruct.new
default_time = ->(t){ tt=t-(($minutes_between_runs * 1.5).ceil * 60);... | true |
b813d5d45cf5aa8830cb7422ff6be2ae2f60334c | Ruby | apwn-pm/Mardi | /exo_12.rb | UTF-8 | 149 | 3.421875 | 3 | [] | no_license | puts "Donne moi un nombre et pose pas de question !"
n = gets.chomp.to_i
puts "Okey, let's gooooooow !"
i=1
n.times do
puts "#{i}"
i+=1
end | true |
862d4af6a0211dfabc0865f67b669f94aab10488 | Ruby | rock-core/base-types | /bindings/ruby/lib/sisl/spline.rb | UTF-8 | 20,019 | 3.171875 | 3 | [] | no_license | require 'base_types_ruby'
require 'eigen'
require 'set'
# Bindings for the SISL spline library
module SISL
# Representation and manipulation of N-dimensional B-splines
class Spline
# @!method initialize(dimension, geometric_resolution = 0.1, order = 3)
# @param [Integer] dimension
# ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.