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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fabc1299ebef85030ab4679275f5604dfbc8e4de | Ruby | tsuyopon/ruby | /basic_func/default_arg1.rb | UTF-8 | 192 | 3.40625 | 3 | [] | no_license | #
# デフォルト引数のサンプルプログラムです
#
# 第3引数は指定されなければ、3になる。
def func(a, b, c = 3)
a + b + c
end
p func(1, 2)
p func(1, 2, 4)
| true |
07af0c01e0c9c382e1255e7437618e4cc019ea3e | Ruby | tied/DevArtifacts | /master/fresh-samples-master/fresh-samples-master/Ruby_api_samples/filter_contact.rb | UTF-8 | 470 | 2.59375 | 3 | [
"MIT"
] | permissive | #Filter contact
require "rubygems"
require "rest_client"
require "json"
#contacts can also be filtered by phone,email etc
params = URI.escape("query=phone is 123245890")
puts "#{params}"
#state can be of type [verified/unverified/all/deleted]
site=RestClient::Resource.new("http://yourcompany.freshdesk.com/contac... | true |
7bfd9f644b5c9e5444d9b7678b11f47b8d98e313 | Ruby | stardstryr/ics_bc_s18 | /week1/ch05/bigger_better_favorite_number.rb | UTF-8 | 499 | 3.8125 | 4 | [] | no_license | puts "If you could pick a favorite number in the whole wide world, what would it be?"
fav_number = gets.chomp
real_fav_number = fav_number.to_i + 1
puts "Hmmmm... That's a good choice"
puts 'but have you ever considered the number ' + real_fav_number.to_s + ' as a favorite number?'
puts real_fav_number.to_s + ' is a g... | true |
4122d079374497616d441640430104e5b039e25a | Ruby | alirezaandersen/black_thursday | /lib/stats.rb | UTF-8 | 389 | 3.125 | 3 | [] | no_license | module Stats
def self.average(nums)
BigDecimal.new(nums.reduce(:+)/(nums.length.to_f),10)
end
def self.sample_variance(nums)
mean = average(nums)
sq_diffs = nums.reduce(0) do |sum, num|
sum + (num-mean)**2
end
BigDecimal.new(sq_diffs/(nums.length-1),10)
end
def self.sample_std_dev(... | true |
ba1f3c5a640027fc2e8a1d756fef2ecd6e9002ec | Ruby | Edgar-Cortez/AppAcademyOpen | /01-Intro to Programming/05-Array Methods and Enumeration/11-Combinations.rb | UTF-8 | 1,647 | 4.96875 | 5 | [] | no_license | # Write a method combinations that takes in an array of unique elements, the
# method should return a 2D array representing all possible combinations of 2
# elements of the array.
# ---------- Steps ----------
# - Create an empty array
# - Iterate through the array lookin at two elements at a time
# - You will nee... | true |
0f9fc7cec3502e30665e2f8b4e0276fc9685a723 | Ruby | Toady00/eff | /lib/eff/verifier.rb | UTF-8 | 443 | 2.8125 | 3 | [
"MIT"
] | permissive | module Eff
class Verifier
class << self
def check(file, checksum, hash_function)
return unless File.exists?(file)
function = function_const_get(hash_function)
file_digest = function.file(file).hexdigest
file_digest == checksum
end
private
def function_cons... | true |
9db6f37b933cf1bddd81c843ea820cfd8d304803 | Ruby | andreev/eport | /lib/request.rb | UTF-8 | 1,047 | 2.765625 | 3 | [] | no_license | require "net/http"
require "net/https"
class Request
attr_accessor :point, :private_key_path, :host, :path, :additional_headers, :body
def initialize(&block)
yield self
@headers = {
"Content-Type" => "text/plain; charset=Windows-1251",
"Content-Length" => @body.size.to_s,
"X-Eport-Au... | true |
6a6bbae1f6fe1c6fc61b03a8b6c2f0495e8bd0c0 | Ruby | notahat/nested_attributes_example | /app/helpers/nested_attributes_helper.rb | UTF-8 | 1,074 | 2.59375 | 3 | [] | no_license | module NestedAttributesHelper
# Renders a partial to generate a HTML template for a nested model in
# a form. Use this with the addNestedItem JavaScript function to
# support dynamically adding nested models.
#
# For example, given a form builder for a Post, you could call:
#
# generate_nested_model_te... | true |
caf302d67ddb1eb9092bf6fa50d1a14b2157ea1f | Ruby | jwhitehorn/dht | /lib/dht/hash.rb | UTF-8 | 542 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'dht/node'
module DHT
class Hash
attr_reader :node
def initialize(options = {})
@node = DHT::Node.new(options)
@node.start
end
def me
DCell.me
end
def storage
me[:storage]
end
def manager
me[:manager]
end
def store(key, value)
m... | true |
50a330ecdc724e069250a7d52313fc4263da1e51 | Ruby | strychemi/assignment_ruby_warmup | /fibonacci_nth_digit.rb | UTF-8 | 938 | 3.90625 | 4 | [] | no_license | #outputs the Fibonacci Sequence
#up to the specified number of digits
def fibonacci(n)
#term array
fib = [1, 1]
#digit array
fib_dig = [1, 1]
#term counter nth, digit counter d
#count from 3rd digit but
#d = 2 because of array 0 indexing
nth = 2
d = 2
while d < n
#calculate new term and its nu... | true |
7a6493482b183b2aa6b33b90b246eff82f1381b0 | Ruby | kliuchnikau/tooth | /spec/test_app.rb | UTF-8 | 1,289 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | require 'sinatra/base'
class TestApp < Sinatra::Base
class TestAppError < StandardError; end
set :root, File.dirname(__FILE__)
set :static, true
set :raise_errors, true
set :show_exceptions, false
get '/simple_link' do
'Hello world! <a href="with_html">Link</a>'
end
get '/simple_divs' do
<<S... | true |
89c4926f91085efa0bd2324fdf1076268e099f76 | Ruby | junya-gera/drill | /drill17.rb | UTF-8 | 206 | 3.453125 | 3 | [] | no_license | #1 このハッシュに対してメソッドを使用して、キーだけを1つの配列に入れてください
attr = {name: "田中", age: 27, height: 180, weight: 75}
array = attr.keys
puts array
| true |
1078e14fc0656f8033c821b9ef1e04fec7143bd4 | Ruby | CepCap/intern | /work/casino/player.rb | UTF-8 | 1,051 | 3.546875 | 4 | [] | no_license | class Player
attr_accessor :bank, :placed_bet, :name, :bet, :status
def initialize
@name = ''
@bank = 2000
@status = :ingame
@bet = 0
@won = nil
end
def check_win(result)
if @placed_bet == result.first || @placed_bet == result.last
won(2) if @placed_bet.is_a? Symbol
won(5) ... | true |
06e903f6d409cd4b67dd38a1119fd61d07282f99 | Ruby | dmentry/midnight_movie | /main.rb | UTF-8 | 623 | 3.375 | 3 | [] | no_license | require_relative 'lib/movie'
require_relative 'lib/movie_collection'
require_relative 'lib/movie_parser'
movie_collection = MovieParser.from_wiki_imdb250
puts 'Программа «Фильм на вечер»'
puts
movie_collection.uniq_producers.each.with_index(1) do |producer, index|
puts "#{index}: #{producer} "
end
pu... | true |
a38b246887bba7b417169615e17cb34d1f27416e | Ruby | jlm/dir-to-tablepress | /lib/dirtp/tptable.rb | UTF-8 | 5,352 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | ####
# Copyright 2017 John Messenger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writi... | true |
0e615043d05482953b2b70527844860cd42eecb2 | Ruby | oleander/levenshteinish | /lib/levenshteinish.rb | UTF-8 | 717 | 3.765625 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Some code borrowed from http://www.erikveen.dds.nl/levenshtein/doc/index.html
require 'hintable_levenshtein'
class Levenshtein
def self.distance(s1, s2, threshold = nil)
# If the arguments is nil
s1 = s1.to_s unless s1
s2 = s2.to_s unless s2
s1, s2 = s2, s1 if s1.length > s2.length # s... | true |
aed837da2b1386f34077d72d238ac81f2bb7a3b9 | Ruby | castor4bit/leetcode | /contests/Biweekly_Contest_18/5152.Sort_the_Matrix_Diagonally/5152.rb | UTF-8 | 486 | 3.359375 | 3 | [] | no_license | # @param {Integer[][]} mat
# @return {Integer[][]}
def diagonal_sort(mat)
m = mat[0].size
n = mat.size
x = m - 1
y = 0
loop do
a = []
xx = x
yy = y
while xx < m && yy < n
a.push(mat[yy][xx])
xx += 1
yy += 1
end
a.sort!
xx = x
yy = y
while xx < m && yy... | true |
620795f7ca452e92cb04d4950cefd832932cb6f6 | Ruby | wyanez/ejemplos_ruby | /bd/active_record_01.rb | UTF-8 | 521 | 2.59375 | 3 | [] | no_license | #require "rubygems"
require 'active_record'
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "geografico.db"
)
class Estado < ActiveRecord::Base
has_many :municipio
end
class Municipio < ActiveRecord::Base
b... | true |
911bee448b781fed6abce9d42525d9cc69a30b1a | Ruby | SeanGallen/Cheatsheets | /intergers.rb | UTF-8 | 363 | 3.953125 | 4 | [] | no_license | # Intergers are whole numbers.
# + additions
1 + 2 = 3
# - subtration
3 - 2 = 1
# < less than
1 < 3 => true
2 < 2 => false
2 < 3 => flase
# == comparison / equal to
1 + 2 == 3 => true
# > greater than
1 > 3 = false
1 > 0 = true
# <= less or equal to
1 <=1 => true
# >= greater than or equal to
4 >= 5 => false
# to_f ... | true |
cf93ca1b4e5030c8297ee4055e82a3a76b60da00 | Ruby | nathaniel-miller/flatiron-bnb-methods-v-000 | /lib/modules/areas.rb | UTF-8 | 1,034 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Areas
module InstanceAreas
def openings(checkin_date, checkout_date)
openings = listings.reject do |l|
l.reservations.any? do |r|
dates = (checkin_date..checkout_date)
dates.include?(r.checkin) || dates.include?(r.checkout)
end
end
openin... | true |
e16aee7cfaae6714e38c6dea9a9bd83f7b02eb86 | Ruby | rj-ortega/wolves | /lib/character.rb | UTF-8 | 1,376 | 3.25 | 3 | [
"MIT"
] | permissive | class Wolf < Sprite
attr_accessor :health
end
class Character
def new_character(sprite_path, clip_width: 30, width: 80, height: 80, time: 100, x: 0, y: 0)
Sprite.new(
sprite_path,
clip_width: clip_width,
width: width,
height: height,
time: time,
loop: true,
x: x,
... | true |
be67adeaf82b4573f901ec50d0d2bcb7a4125728 | Ruby | tombeau19/fan_watch | /app/services/yelp_services.rb | UTF-8 | 635 | 2.609375 | 3 | [] | no_license | module Services
class YelpService
include HTTParty
def self.search_for_bar(barname)
@response = HTTParty.get("https://api.yelp.com/v3/businesses/search?term=#{barname}&location=atlanta&categories=bars,restaurants,pubs&limit=1", :headers => headers)
end
def self.get_bar_from_yelp_id(yelp... | true |
5960c70a246612faadc99c06fa783ecbe6aa0838 | Ruby | JonClayton/phase-0 | /week-4/errors/errors.rb | UTF-8 | 8,167 | 4.59375 | 5 | [
"MIT"
] | permissive | # Analyze the Errors
# I worked on this challenge by myself.
# I spent 1 hours on this challenge.
# --- error -------------------------------------------------------
# "Screw you guys " + "I'm going home." = cartmans_phrase
cartmans_phrase = "Screw you guys " + "I'm going home."
# This error was analyzed in the READ... | true |
716ddf021f97c5e9623c5bf7dfe714c88f86427e | Ruby | Atsoamazed/looping-loop-v-000 | /looping.rb | UTF-8 | 80 | 2.734375 | 3 | [] | no_license | def looping
loop do
puts "Wingardium Leviosa"
end
end
#call your method here
looping()
| true |
e35c40b3af89daaa65425ef66dec7877d281d036 | Ruby | punchcafe/makers-academy-projects | /beedles-hotbox/lib/order.rb | UTF-8 | 614 | 3.03125 | 3 | [] | no_license | require 'twilio-ruby'
require_relative 'printbasket.rb'
class Order
def place_order(basket)
send_message(PrintBasket.new.string(basket))
#just sends text
#prints basket (or do that in user!)
end
private
def send_message(body)
@client = Twilio::REST::Client.new(
account_sid=ENV['TWILIO_A... | true |
fe979a8a17dcfa774928a9b27a89ae960bab0e02 | Ruby | AnnAllan/assignment_knights_travails | /knight_searcher.rb | UTF-8 | 1,095 | 3.09375 | 3 | [] | no_license | class KnightSearcher
include KnightsTravails
attr_reader :move_tree
def initialize(move_tree)
@move_tree = move_tree
end
def bfs_for(target)
start = move_tree.start_node
start.depth = 0
queue = [start]
until queue.empty?
current = queue.pop
if target == [current.x, current.y]
... | true |
fb6e859b460aad6b5c5ce00193a675a1b4260ece | Ruby | KylaBendrik/prg101 | /Prg 101/lab_9/lab9.rectangle.rb | UTF-8 | 396 | 3.328125 | 3 | [
"MIT"
] | permissive | class Rectangle
attr_reader :width, :height
def width=(value)
if value.negative?
raise "invalid width: #{value}"
else
@width = value
end
end
def height=(value)
if value.negative?
raise "invalid height: #{value}"
else
@height = value
end
end
def area
@width... | true |
56694ae6bac3573d464aeaa3018aeb742f6972da | Ruby | miguelfrde/sodascript | /test/production_test.rb | UTF-8 | 2,395 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
describe Sodascript::Production do
before do
@p1 = Sodascript::Production.new(:S, '', :A, :B)
@p2 = Sodascript::Production.new(:S, '', :A, :B)
@p3 = Sodascript::Production.new(:S, '', :B, :A)
@p4 = Sodascript::Production.new(:Z, '', :A, :B)
@p5 = Sodascript::Production.new(:... | true |
70d26e4e7327e68c5b8b977399507ee2cffa4083 | Ruby | tsengsational/object-relations-assessment-web-060517 | /app/models/review.rb | UTF-8 | 239 | 2.578125 | 3 | [] | no_license | class Review
attr_accessor :customer, :restaurant, :content
@@all = []
def initialize(customer, restaurant)
@@all << self
self.customer = customer
self.restaurant = restaurant
end
def self.all
@@all
end
end
| true |
bea93b6919635b0af9c071c185060615a0293239 | Ruby | caporta/ruby-oo-assessment-001 | /lib/mark_odds.rb | UTF-8 | 235 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Modify the Array class to support an odds? method that
# returns all the odd integers in the array.
class Array
def odds?
odds_arr = []
self.each { |x| x.odd? ? odds_arr << true : odds_arr << false }
odds_arr
end
end | true |
7072deffd0cd9e557d9c9058dd74173283d0fff3 | Ruby | willcurry/ruby-ttt-console | /spec/console_game_spec.rb | UTF-8 | 2,167 | 3.3125 | 3 | [] | no_license | require 'console_game'
require 'board'
require 'game'
require 'human_vs_human'
require 'game_recording'
RSpec.describe ConsoleGame do
before (:each) do
@board = Board.new(['x', 'x', '-', '-', '-', '-', '-', '-', '-'])
@output = StringIO.new
@input = StringIO.new
@console_game = ConsoleGame.new(@outpu... | true |
be6eddf0bd974d7781bceb0316bbd7379de20d0d | Ruby | purplefishies/Scripts | /acces_hours.rb | UTF-8 | 3,115 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'chronic'
require 'time'
require 'date'
require 'business_time'
require 'holiday'
require 'time_diff'
lines = File.read( ARGV[0] ).split("\n")
subt = lines.find_all { |i| i =~ /^\s*\|(\s*\-)/ }
lines = lines.find_all { |i| i !~ /^\s*(\#.*)?$/ && i !~ /(In|Out)/ && i !~ ... | true |
19d91d9c9f7e73b8998865a8733a70ff59c4753b | Ruby | bhavanisarma/imageblur1 | /image1/image.rb | UTF-8 | 268 | 3.359375 | 3 | [] | no_license | class Image
attr_accessor :image
def initialize(image)
@image=image
end
def output_image
@image.each do |row|
puts row.join
end
end
end
image=Image.new([
[0,0,0,0],
[0,1,0,0],
[0,0,0,1],
[0,0,0,0]
])
image.output_image
| true |
3bdf6e60790bf82812273b5db23acae7bf091dcb | Ruby | billg3/dumbo-web-031119 | /07-inheritance/runner.rb | UTF-8 | 316 | 2.78125 | 3 | [] | no_license | require_relative "animal"
require_relative "fish"
require_relative "dog"
require_relative "cat"
require "pry"
dory = Fish.new("Dory")
elliott = Cat.new("Elliott")
einstein = Dog.new("Einstein")
peanut = Dog.new("Peanut")
teddy = Dog.new("Teddy")
gordon = Fish.new("Gordon")
# puts einstein.speak
Pry.start
false
| true |
cca75dbee9069f97179161ea5babb5eca6673271 | Ruby | 0308199710520/MakersBnb | /lib/user.rb | UTF-8 | 1,023 | 2.734375 | 3 | [] | no_license | require "bcrypt"
require 'pg'
class User
def create(email:, password:)
con = connection()
result = con.exec("INSERT INTO user_info (email, password) VALUES ('#{email}', '#{BCrypt::Password.create(password)}');")
end
def login(email:, password:)
con = connection()
result = con.exec("SE... | true |
4f5f28afc80beff91049fd1cf894b7436b3f69ce | Ruby | navyboys/TeaLeaf_BlackJack_OO | /oo_blackjack_game.rb | UTF-8 | 3,951 | 4.0625 | 4 | [] | no_license | # Object Oriented Blackjack Game
require 'rubygems'
require 'pry'
class Card
attr_accessor :suit, :value
def initialize(s, v)
@suit = s
@value = v
end
def to_s
"[#{suit}, #{value}]"
end
end
class Deck
attr_accessor :cards
def initialize
@cards = []
['Hearts', 'Diamonds', 'Spades'... | true |
994cd55a165a25a5557f71d873aeb166d628218c | Ruby | TobyRet/rubyist_week4_test | /task_2/lib/takeaway.rb | UTF-8 | 376 | 2.9375 | 3 | [] | no_license | class Takeaway
attr_accessor :menu
def initialize
@menu = {'pizza' => 15, 'hamburger' => 6, 'steak' => 3, 'icecream' => 3}
end
def order_sum_check (order_items, total, sms)
check_total = order_items.map { |k, v| @menu[k] * v }.inject { |sum, n| sum + n }
check_total != total ? (raise 'Total w... | true |
4abc7038be7f3831e919270f24b265bb1cfc872b | Ruby | skipchris/bigcommerce-oauth-api | /spec/bigcommerce_oauth_api/resource_spec.rb | UTF-8 | 1,511 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
require 'bigcommerce-oauth-api/resource'
module BigcommerceOAuthAPI
describe BigcommerceOAuthAPI::Resource do
context 'when initialized with a hash' do
let(:instance) do
described_class.new({ a: 'foo', b: 'bar', c: { foo: 'bar'} })
end
it 'responds to the methods ... | true |
9a61a44dfa852ccd5beb338044b8e6237c1914e7 | Ruby | wusher/exercism_code | /ruby/sum-of-multiples/sum.rb | UTF-8 | 263 | 3.65625 | 4 | [] | no_license | class SumOfMultiples
def self.to(number)
return 0 if number <= 1
multiples_of(number).inject(:+)
end
def self.multiples_of(number)
puts number
nums = (number - 1).downto(1).select { |x| number % x == 0 }
puts nums
nums
end
end
| true |
f0026893ad087e29463b796e0446f0853e912cc6 | Ruby | usgo/gocongress | /app/exporters/daily_plan_csv_exporter.rb | UTF-8 | 1,761 | 2.765625 | 3 | [
"MIT"
] | permissive | class DailyPlanCsvExporter < Exporter
def initialize(year)
@year = year
@plan_names = Plan.yr(@year).daily.order(:name).to_a.map(&:name)
super()
end
def header
["user_id", "attendee_id", "Family Name", "Given Name", "Alternate Name"] + @plan_names
end
def render
xtab = crosstab(run_query... | true |
4b6543a2b256a6f0cea49145cc950ecd3e3dbe78 | Ruby | EvianneKeeney/API-Dashboard | /lib/news.rb | UTF-8 | 842 | 2.65625 | 3 | [] | no_license | require "net/http"
require "json"
require "pry"
require 'dotenv'
Dotenv.load
class News
attr_reader :news
def initialize
@news_data = get_news
end
def show_news
count = 0
news_snippets = []
while count < 5
news_snippets << snippet = @result["response"]["docs"][count]["snippet"]
co... | true |
95debfac2920f82ffa7e3f261b67c375f9562387 | Ruby | superposition/Research | /ruby/binint.rb | UTF-8 | 102 | 3.40625 | 3 | [] | no_license | #!usr/bin/ruby
=begin
Write a function that prints out the binary form of an int
=end
p 9.to_s(2)
| true |
094ee97a21bfd9254c6b7d8b3495750923abd6a6 | Ruby | men32z/ten-pin-bowling | /spec/integration/two_players_spec.rb | UTF-8 | 1,288 | 2.90625 | 3 | [
"MIT"
] | permissive | require './lib/game'
require './lib/file_helper'
require './lib/data'
require './bin/printer'
RSpec.describe 'Two players Scenario' do
describe 'two playes scenario' do
before(:each) do
file = FileHelper.read('./spec/fixtures/example_default.txt')
data = GameData.new(file)
data.format("\t")
... | true |
1935829874e5d475e81a8f668c65c18d195a93f9 | Ruby | macro6461/the-bachelor-todo-web-071717 | /lib/bachelor.rb | UTF-8 | 1,884 | 4 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def get_first_name_of_season_winner(data, season)
#code here
winner = ""
data.each do |season_name, season_data| #season_data is an array of each contestant (hash)
if season_name == season
season_data.each do |contestant|
if contestant["status"] == "Winner"
winner = contestant["name"]... | true |
30abb1ad97f4f45c26423cf9f293548c69ccd886 | Ruby | hopsoft/field_mapper | /test/readme_test.rb | UTF-8 | 3,748 | 2.8125 | 3 | [
"MIT"
] | permissive | require_relative "test_helper"
class ReadmeTest < PryTest::Test
test "readme examples" do
class StandardUser < FieldMapper::Standard::Plat
field :name, type: String
field :screen_name, type: String
field :info, type: String
field :website, type: String
field :age... | true |
d2febc79e455f52ef89fe8c7dcffcb26054e2842 | Ruby | wesleyan/cmdr-server | /lib/server/MAC.rb | UTF-8 | 1,304 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | module MAC
class << self
def addr
return @mac_address if defined? @mac_address and @mac_address
re = %r/[^:\-](?:[0-9A-F][0-9A-F][:\-]){5}[0-9A-F][0-9A-F][^:\-]/io
cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'ipconfig /all'
null = test(?e, '/dev/null') ? '/dev/null' : 'NUL'
lines = nil
... | true |
e93ae62e9e17006bf9196197742cdd461aae94e4 | Ruby | cedretaber/codes_for_atcoder | /other/msolution/2020/e_mk.rb | UTF-8 | 208 | 3.21875 | 3 | [] | no_license | puts 15
memo = {}
15.times do
x = y = 0
loop do
x = rand(-10000..10000)
y = rand(-10000..10000)
break unless memo[[x,y]]
end
memo[[x,y]] = true
puts "#{x} #{y} #{rand(1..1000000)}"
end | true |
f3f5b2ec549d30dd9dda895114daed0f5fbae742 | Ruby | rustydigg918/vscode-git | /userinput.rb | UTF-8 | 141 | 3.71875 | 4 | [] | no_license | puts "Enter Your Name"
name= gets.chomp()
puts "Enter Your Age"
age= gets.chomp()
puts ("Hello "+ name + ", you are "+ age + " years old.") | true |
bf84014ba0db010f803b0c7d6a16274b875366f9 | Ruby | benwbooth/mseq | /lib/mseq/parser/mseq.rb | UTF-8 | 1,269 | 2.734375 | 3 | [] | no_license | require File.dirname(__FILE__)+'/rdparser'
require File.dirname(__FILE__)+'/ast'
parser = RDParser.new do
s = /[\t\r\n ]*/
sp = /[\t\r\n ]+/
names = {}
start :score do
match(s, :exprs) do |_, exprs|
Score.new(*exprs)
end
end
rule :exprs do
match() do |first_expr|
exprs = []
... | true |
865ed5fffca407f1796aa053ed29c46487087602 | Ruby | Clannis/dog-land-api | /app/models/trick.rb | UTF-8 | 706 | 2.765625 | 3 | [
"MIT"
] | permissive | class Trick < ApplicationRecord
has_many :trick_courses
has_many :courses, through: :trick_courses
validates :name, uniqueness: {case_sensitive: false}
validates :name, :description, :difficulty_rating, presence: true
def trick_course(course)
if self.trick_courses.count == 0
ni... | true |
cc5c902f90183e55791933352fd3b5ce2a16cc86 | Ruby | knoxknox/dev-labs | /bit-masks/specs/date_spec.rb | UTF-8 | 126 | 2.609375 | 3 | [] | no_license | date = BitDate.new
date.day = 10
date.month = 12
date.year = 2017
puts "#{date.year}-#{date.month}-#{date.day}" # 2017-12-10
| true |
85392603d219c41560fddf859a656d4e2c495de1 | Ruby | wpietri/ankimaker | /ankimaker-cfa.rb | UTF-8 | 2,654 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/ruby
# encoding: UTF-8
require 'nokogiri'
require 'open-uri'
require 'pp'
# Anki (http://ankisrs.net/) is a flashcard program. This script
# extracts pictures and descriptions from the codeforamerica.org
# source tree and assembles it into an Anki-friendly format to
# make it easy to learn who people are.
... | true |
0edb052766f1748712c6eab433d2259dc538084a | Ruby | nastymike/bbb | /lib/BBB/circuit.rb | UTF-8 | 1,849 | 3.359375 | 3 | [
"MIT"
] | permissive | module BBB
##
# The idea here is to attach a piece of equipment to a circuit.
#
# A component (e.g. Led or Servo) will define generic pins, like
# DigitalInput or AnalogOutput. And then, when the component gets attached to
# the circuit those pins will be initialized using the file system.
#
# For now t... | true |
7d92c3b6fe64ee5c0618868427fc1f740a1cccab | Ruby | jyang2017/cs83r | /unit_15/OrderApp/test/models/customer_test.rb | UTF-8 | 769 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class CustomerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "there should be 6 records" do
counter = Customer.count()
assert_equal( counter, 6, "not 6 records found" )
end
test "Varner User System is found" do
cust = Customer.find_by_c... | true |
d38a0d22ed066f9590c6407b08cded7bb2641272 | Ruby | elizahyde/fandangr | /db/seeds.rb | UTF-8 | 2,237 | 2.515625 | 3 | [] | no_license | movies = Movie.create([
{ name: 'The Lone Ranger', duration: 149, rating: "PG-13",
synopsis: "Native American spirit warrior Tonto and man of the
law John Reid join forces to battle greed and corruption." },
{ name: 'The Heat', duration:... | true |
57e759dbecf22394947acb316db4b173c796ec10 | Ruby | katharinechen/train_system | /spec/station_spec.rb | UTF-8 | 1,489 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'Station' do
describe :initialize do
it 'initializes an instance of the Station class' do
expect(Station.new({'name' => "Expo Center"})).to be_an_instance_of Station
end
it 'sets its name to the value passed in a hash' do
create_examples
expect(@station1... | true |
74ee25ddd42738594350703619ff8d145730d830 | Ruby | viing937/codeforces | /src/34A.rb | UTF-8 | 244 | 2.765625 | 3 | [
"MIT"
] | permissive | n = gets.to_i
a = gets.split.collect{|i| i.to_i}
ans = 0
(1...n-1).each{|i| ans = i if (a[i]-a[i+1]).abs < (a[ans]-a[ans+1]).abs}
if (a[0]-a[n-1]).abs < (a[ans]-a[ans+1]).abs
print n, " ", 1, "\n"
else
print ans+1, " ", ans+2, "\n"
end
| true |
158666e5d5d16c325b96ad2a602e10306b02647b | Ruby | collinbarnwell/ninjanews | /spec/lib/tag_reader_spec.rb | UTF-8 | 635 | 2.515625 | 3 | [] | no_license | require 'tag_reader'
describe TagReader do
describe '#extract_quoted_phrases' do
let(:normal_input) { "'those dang' commies 'are' outta control".split }
let(:nested_input) { "those 'dang commies 'are outa' control'".split }
let(:misplaced_quotes) { "those' dang 'commies".split }
it do
TagR... | true |
1014a65193c1c79c3919de8343cbeed7ebdfe45e | Ruby | christianfp/TennisATDDyTDD | /lib/Tennis.rb | UTF-8 | 1,011 | 3.359375 | 3 | [] | no_license | class Tennis
attr_accessor :Player1, :Player2
def initialize
@Player1=0
@Player2=0
end
def anotarJugador1
if @Player1!=30
@Player1 += 15
else
@Player1 += 10
end
end
def anotarJugador2
if @Player2!=30
... | true |
0ec4754deffd2d61f9541cc1c28bf0dc2dc8c959 | Ruby | johnvoon/launch_school | /exercise_sets_for_101_109/easy5/after_midnight_bonus_features.rb | UTF-8 | 659 | 3.828125 | 4 | [
"MIT"
] | permissive | require 'date'
MINUTES_PER_HOUR = 60
HOURS_PER_DAY = 24
MINUTES_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR
def time_of_day(delta_minutes) # delta_minutes is the number of minutes to wind the clock backwards or forwards
delta_minutes = delta_minutes % MINUTES_PER_DAY # i.e. 1440. Let's say delta_minutes is 1440
ho... | true |
52fce1301520c2cb2e4aca4dc7fc5f5ca50b5022 | Ruby | JonahMoses/csv_exercises | /shopping_list/lib/shopping_list.rb | UTF-8 | 378 | 2.953125 | 3 | [] | no_license | require 'csv'
require_relative 'item'
class ShoppingList
def initialize(filename)
@filename = filename
end
def filename
@filename
end
def items
@items ||= build_items
end
private
def build_items
data.collect do |row|
Item.new(row)
end
end
def data
CSV.open(filenam... | true |
4bfa5b99b2e924b9fa758fc2f5961a58fb918de4 | Ruby | traciechang/algorithm-problems | /search_sorted_and_rotated_array.rb | UTF-8 | 788 | 4.03125 | 4 | [] | no_license | require 'pry'
def search_rotated_array(arr, target)
return 0 if arr[0] == target
pivot = find_pivot(arr)
if arr[0] > target
idx = binary_search(arr[pivot+1..-1], target)
pivot + 1 + idx
else
binary_search(arr[0..pivot], target)
end
end
def binary_search(arr, target)
re... | true |
d6e3819b5156bcb3dfb670e9e1b0b56292427a80 | Ruby | proheng/CreditCardNumberValidation | /creditcard.rb | UTF-8 | 721 | 3.453125 | 3 | [] | no_license | class Creditcard
attr_accessor :number
def initialize(number='')
@number = number.gsub(/\s+/,"").strip
end
def valid?
@number.chars.to_a.reverse.each_with_index.inject(0) do |sum, (dig,i)|
dig = dig.to_i
dig *=2 if(i%2==1)
dig -= 9 if(dig > 9)
sum += dig
end % 10 == 0
end
... | true |
6d18a878aa2e6be0c1ee774da0bbcf09b907424d | Ruby | healthycola/healthycola.github.io.raw | /_plugins/tag_gen.rb | UTF-8 | 4,772 | 2.6875 | 3 | [] | no_license | require_relative 'global.rb'
module Jekyll
module Categories
class TagIndex < Page
def initialize(site, base, dir, tag)
@site = site
@base = base
@dir = dir
@name = 'index.html'
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'tag_index.html'... | true |
d4ca1c1d0b901c0048b9155c2c3997cf0d880fef | Ruby | neilmarion/plankbot | /app/services/plankbot/toggle_presence_service.rb | UTF-8 | 1,177 | 2.578125 | 3 | [
"MIT"
] | permissive | module Plankbot
class TogglePresenceService
attr_accessor :slack_id, :status, :note, :kind
ONLINE = "online".freeze
OFFLINE = "offline".freeze
def initialize(slack_id:, status:, note:, kind:)
@slack_id = slack_id
@status = status
@note = note
@kind = kind
end
def exe... | true |
a73ff9fc2d35e19c46818b9398b158e6bcc46490 | Ruby | lukas-gartman/ITG-Forums | /app/models/Subforum.rb | UTF-8 | 3,959 | 2.90625 | 3 | [] | no_license | class Subforum < Database
attr_reader :id
attr_accessor :name, :description, :forum_id
def initialize(id)
subforum = @@db.execute("SELECT * FROM subforums WHERE id = ?", id).first
@id = subforum[0]
@name = subforum[1]
@description = subforum[2]
@forum_id = subforum[3... | true |
dca7e16485b57fe86d4a12499e24dd115a7d3ddf | Ruby | sa2taka/mstdn_ivory | /lib/mstdn_ivory/parser.rb | UTF-8 | 639 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'http'
require 'oj'
module MstdnIvory
# This class parse stream data.
class Parser
def initialize(&block)
@parser = HTTP::Parser.new(self)
@buffer = {}
@block = block
end
def <<(body)
@parser << body
end
def on_body(data)
if (match_data = data.match(/even... | true |
e9b06a49977e4ab82ead460b4c0068e70c7237d2 | Ruby | steveoro/goggles | /app/strategies/header_year_picker.rb | UTF-8 | 1,824 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'wrappers/timing'
#
# == HeaderYearPicker
#
# Pattern to pick handled header yers
# Header years are intended to manage groups of seasons referred to the
# same period. EG For the same year there are more than one seasons owned by different federations
#
# @author Leega
#
class HeaderYearPicker
# These mu... | true |
0ea516fd4f936ec974e29339d5cceddf3897a7bd | Ruby | SCCP2016/ruby_mid_answer | /4/4.rb | UTF-8 | 664 | 4.4375 | 4 | [] | no_license | # 末尾の改行を削除した文字列をtextという変数に代入
text = STDIN.gets.chomp
puts text
# Stringが長さを求めるメソッドを提供している
puts text.size
# 文字列を逆順に並べ替えるメソッド、reverseを使う
puts text.reverse
# 文字列内のアルファベットを大文字に変えるメソッド、updcaseを使う
puts text.upcase
# Rangeで書くと -1で末尾, -2でその前を指す
puts text[1..-2]
# 文字列を配列として一文字ずつに分解し、a, b, cであるときにupcaseを適用するような処理を書く
puts t... | true |
fb245021d9af8411ccc4426e36dbfbc64958c29b | Ruby | nateg101/tic-tac-toe | /lib/player.rb | UTF-8 | 101 | 2.546875 | 3 | [] | no_license | class Player
attr_reader :mark
def initialize(input)
@mark = input.fetch(:mark)
end
end
| true |
13a198147e7aef11b67d6335e44d9d5ea13a0e23 | Ruby | ewollesen/ruby-wamp-client | /lib/wamp/client.rb | UTF-8 | 2,523 | 2.640625 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require "wamp/client/version"
require "net/ws"
require "yajl/json_gem"
require "timeout"
module WAMP
class Client
TYPEID_WELCOME = 0
TYPEID_PREFIX = 1
TYPEID_CALL = 2
TYPEID_CALLRESULT = 3
TYPEID_CALLERROR = 4
TYPEID_SUBSCRIBE = 5
TYPEID_UNSUBSCRIBE = 6
TYPEID... | true |
bad4c4b72fd1cec512e238a5b6f7600f6d0f6928 | Ruby | inosyo/ABC | /ary_by.rb | UTF-8 | 338 | 3.015625 | 3 | [] | no_license | #!/usr/koeki/bin/ruby
# -*- coding: utf-8 -*-
suu = [1, 2, 3, 4, 5]
kazu = ["いち", "に", "さん", "し", "ご"]
# sort_by で小さな数順もしくは文字コード順
p suu.sort_by{|no|
no}
p suu.max_by{|no|
no}
p suu.min_by{|no|
no}
p kazu.sort_by{|no|
no}
p kazu.max_by{|no|
no}
p kazu.min_by{|no|
no}
| true |
927131edb035fdb548e03d48b1c3ea705d9d6890 | Ruby | NBojang/OOP-LAB-2 | /animal_types/bird.rb | UTF-8 | 522 | 3.546875 | 4 | [] | no_license |
module Birds
def self.common_bird_traits
puts 'All birds have beaks, or bills, made of a bony core surrounded by a thin layer of keratin. '
end
class CommonTraits
def wings
puts 'All birds have wings, although not all birds fly.'
end
end
class Biped < CommonTraits
def legs
... | true |
15c4b79ebdb203afa160087a7e8e9e4263e752b4 | Ruby | ransingh/flickrapp | /spec/models/photo_list_spec.rb | UTF-8 | 2,792 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
describe Flickr::PhotoList do
let(:current_page) { 3 }
let(:total_pages) { 100 }
subject { Flickr::PhotoList.from(photo_hash) }
describe ".from" do
it "should build the photo list from the hash" do
subject.page.should be current_page
subject.pages.should be total_pag... | true |
ed16ba0e34e054d71017e88dcfe6e5609fb67f15 | Ruby | leilamirghaderi/pine_book | /chapter14/example_14_3.rb | UTF-8 | 1,166 | 4.46875 | 4 | [] | no_license | # number 1:
class Array
def each_even(&was_a_block__now_a_proc)
is_even = true
self.each do |object|
if is_even
was_a_block__now_a_proc.call object
end
is_even = !is_even
end
end
end
fruits = ['apple', 'bad apple', 'cherry', 'durian']
fruits.each_even do |fruit|
puts "Yum! I ... | true |
2e15710b9e2caa16056b9d129c34a0aa8cc0f69d | Ruby | nlicalzi/launch_school | /120-object_oriented_ruby/lesson_5/tic_tac_toe/oo_tictactoe_start.rb | UTF-8 | 1,165 | 4.125 | 4 | [] | no_license | # Source: https://launchschool.com/lessons/97babc46/assignments/7dcb53f1
# OOP Tic Tac Toe Description
# Tic-tac-toe is a 2-player board game played on a 3x3 grid. Players take turns marking a square. The first player to mark 3 squares in a row wins.
# Nouns: boad, player, square, grid
# Verbs: play, mark
# Board
#... | true |
552f7827133784ad5bff3e397fd0a6ae6fabc7bf | Ruby | goatapp/ebayr | /test/ebayr/record_test.rb | UTF-8 | 948 | 2.703125 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
require 'test_helper'
require 'ebayr/record'
module Ebayr
class RecordTest < MiniTest::Unit::TestCase
def test_lookup_is_case_insensitive
record = Record.new('Foo' => 'Bar')
assert_equal 'Bar', record['Foo']
end
def test_records_are_nested
record = Record.new... | true |
3a98795703430b843bd54bcb41777ec2901d4d83 | Ruby | CandyFet/thinknetica_ruby | /lesson9.1/route.rb | UTF-8 | 851 | 3.328125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'instance_counter.rb'
require_relative 'validation.rb'
class Route
include InstanceCounter
include Validation
LOGIC_ERROR = 'Ошибка! Начальная станция не должна равняться конечной.'
attr_reader :stations
validate :start_station, :type, Station
validate :end... | true |
7b8959b81b64f2fd60af5078427cddf5e533ced9 | Ruby | rajalaxmi6/test-resp | /rubyplayers.rb | UTF-8 | 848 | 3.40625 | 3 | [] | no_license | class Player
def initailize(total_no_of_balls)
@total=0
@value=0
end
def add_run(run)
@player1=Array.new
@total=Array.new
@find_run=Array.new
@player1=4
@player1=6
@player1=0
end
def no_of_dots_balls(balls)
@total = @total+value
if value>=4
@total+=0
puts... | true |
9b1d60df026dbeedb26d05f3f498cd57c504c2a1 | Ruby | xpositivityx/SommTest | /regionseed.rb | UTF-8 | 123 | 2.828125 | 3 | [] | no_license | array = ["United States", "Germany", "Spain", "Italy"]
array.each do |region|
r = Region.new
r.name = region
r.save
end | true |
437f5b827778ce07486c5bca37ca6bea0f3d0cfc | Ruby | hasandeveloper/advanced-ruby | /combination-of-comprehensive-and-advance-ruby-from-udemy-handpicked-ruby-practice/02-class-methods-and-objects/getter-setter-method.rb | UTF-8 | 323 | 3.609375 | 4 | [] | no_license | class Hasan
def initialize(name)
@name = name
end
#attr_reader
def name
@name
end
#attr_writer
def name=(name)
@name=name
end
#For both reader and write is attr_accessor
end
ob = Hasan.new "Burak"
p ob.name
p ob.name="Horse"
# o/p
# "Burak"
# "Hor... | true |
99b6f97177e53ff687b393d2486994097705a1e2 | Ruby | guanwenw/Ruby | /BreakNextRedo.rb | UTF-8 | 308 | 2.828125 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: UTF-8 -*-
for i in 0..5
if i > 2 then
break
end
puts "Local variable is #{i}"
end
for i in 0..5
if i < 2 then
next
end
puts "Local variable is #{i}"
end
for i in 0..5
if i < 2 then
puts "Local variable is #{i}"
redo
end
end
| true |
dcc7a1cd69198722b0286a5ef49031b00b8137fa | Ruby | enthal/ecdf_ruby_demo | /lib/util.rb | UTF-8 | 951 | 2.859375 | 3 | [] | no_license | # Copyright © 2011 Timothy James; All rights reserved
class Struct
def to_hash
Hash[*members.zip(values).flatten]
end
end
class String
def convert_to_type_of other
return case other
when String
self
when Symbol
to_sym
when Integer
to_i
when Float
to_f
when Tru... | true |
d3d21c580693f3dabc8858b645728141e4a066fd | Ruby | sineed/drivy | /backend/level1/models/rental.rb | UTF-8 | 509 | 2.78125 | 3 | [] | no_license | require "virtus"
class Rental
include Virtus.model
attribute :id, Integer
attribute :car_id, Integer
attribute :start_date, Date
attribute :end_date, Date
attribute :distance, Integer
attribute :context, Object
def car
@car ||= context.cars.find { |car| car.id == car_id }
end
def price
t... | true |
9538db84282e77d4a92ac3388e9eef49266251ff | Ruby | artichoke/ferrocarril | /mruby-gems/vendor/ruby/2.6.0/gems/rack-2.0.7/test/spec_common_logger.rb | UTF-8 | 2,449 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'rack/common_logger'
require 'rack/lint'
require 'rack/mock'
require 'logger'
describe Rack::CommonLogger do
obj = 'foobar'
length = obj.size
app = Rack::Lint.new lambda { |env|
[200,
{"Content-Type" => "text/html", "Content-Length" => length.to_s},
[obj]]}
ap... | true |
15dc981b605f575fe13754d3ecb9bdb8c65db460 | Ruby | markevans/object_mapper | /spec/mapper_spec.rb | UTF-8 | 4,498 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "#{File.dirname(__FILE__)}/spec_helper"
include ObjectMapper
describe Mapper do
describe "the classes to map to and from" do
before :each do
class Class1; attr_accessor :meth_1; end
class Class2; attr_accessor :meth_2; end
class ExplicitMapperClass
extend ObjectMapper::Mapper
... | true |
2f76d916a5d0889adbd0945574fe9bb53041ebee | Ruby | dbayo/knorbitheroku | /tools/html_differ/html_differ_test.rb | UTF-8 | 5,067 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require "html_differ"
require "test/unit"
class DocumentTest < Test::Unit::TestCase
def perform_test(ori,des,exp,user)
result = HtmlDiffer.diff(ori, des, user)
# puts result.to_s
assert_equal(exp, result.to_s)
return result.to_s
end
def test_equal
str1 = %Q{<p>First simpl... | true |
85268c3bda2825c572eec980e7084d2e73623859 | Ruby | jgsmith/ruby-second-contract | /lib/second-contract/service/admin.rb | UTF-8 | 1,510 | 2.5625 | 3 | [] | no_license | require 'eventmachine'
module SecondContract::Service
end
class SecondContract::Service::Admin < EventMachine::Connection
def server
SecondContract::Driver.instance
end
def game
SecondContract::Game.instance
end
def post_init
send_data("Second Contract Administrative Console\n\n> ")
end
... | true |
7425c38c7caa4ab6d570644e0bdaac8053dc4401 | Ruby | ar-shestopal/algorigthms | /max_pq.rb | UTF-8 | 2,354 | 4.15625 | 4 | [] | no_license | require 'pry'
class MaxPQ
attr_accessor :arr, :size
def initialize(arr)
@arr = arr
@size = arr.size
build_heap if arr.size > 1
end
def get_max
arr[0], arr[-1] = arr[-1], arr[0]
result = arr.delete_at(-1)
self.size -= 1
heapify(0)
result
end
def add(val)
arr << val
... | true |
a3f23254d6a163bbf7016481f89d16cee9d11d2c | Ruby | bofinbabu/spoj | /0005-palin/0005-palin.rb | UTF-8 | 1,998 | 3.609375 | 4 | [] | no_license | #!/usr/bin/ruby
# Returns true if n is a palindrome and false otherwise
def is_palindrome(n)
s = n.to_s
half = (s.size / 2.0).ceil - 1
n = 0
while (n <= half)
back = (n+1) * -1
return false if s[n] != s[back]
n += 1
end
true
end
# Returns the first number after 'n' that is a palindrome
def n... | true |
d3124c3483e01c06aa05f67924da156593a5533d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/8b03cbf55022493e8b503e8326e8daf8.rb | UTF-8 | 592 | 3.3125 | 3 | [] | no_license | class Complement
def self.of_dna(dna)
rna = ""
codons = dna.split("")
codons.each do |codon|
case codon
when 'G'
rna += "C"
when "C"
rna += "G"
when "T"
rna += "A"
when "A"
rna += "U"
end
end
rna
end
def self.of_rna... | true |
576c578f3c9f51890b6b28d0674e5958c05d1df6 | Ruby | nkhil/chitter-challenge | /spec/peep_spec.rb | UTF-8 | 1,349 | 2.65625 | 3 | [] | no_license | require './app/lib/peep'
require 'pg'
require 'time'
require 'timecop'
RSpec.describe Peep do
describe '.all' do
it 'returns all peeps' do
Peep.create(peep: 'I ate some cake')
expect(Peep.all.first.peep).to eq('I ate some cake')
expect(Peep.all.length).to eq(1)
end
it 'returns peeps in... | true |
28a4ed74152239161f394b53ac926a8749fddd9f | Ruby | Rainbow-Ninja/ruby | /Day10/error.rb | UTF-8 | 434 | 4.15625 | 4 | [] | no_license | def division(num1, num2)
return result = num1/num2
end
begin
puts "Enter a number "
num1 = gets.chomp.to_i
puts "Enter another number"
num2 = gets.chomp.to_i
result = division(num1, num2)
puts "division of two numbers is #{result}"
rescue
#gets executed if there was a proble... | true |
1a6a35542376d703e86eacce59585ae186107ca2 | Ruby | chrisnatali/ledger-tools | /lib/ledger_tools/csv2ledger.rb | UTF-8 | 7,134 | 3.0625 | 3 | [] | no_license | require 'ledger_tools'
require 'csv'
module LedgerTools
include Model
# class for CSV to Ledger translation and output
# Assumes each CSV row corresponds to a single transaction
# with 2 entries (from and to)
# And that the account to balance each transaction with is
# always the same (i.e. a bank account... | true |
8ce6505e3e9b5bc52dbe565a5022cb9cd70b87bf | Ruby | callum-marshall/oystercard | /lib/journey.rb | UTF-8 | 468 | 2.96875 | 3 | [] | no_license | class Journey
def initialize
@entry_station
@exit_station
end
attr_reader :in_journey, :entry_station, :exit_station
def start(station)
@entry_station = station
end
def finish(station)
@exit_station = station
end
def complete?
@exit_station != nil
end
def fare
complete?... | true |
d8794977298c3ac6d72c95361625715344d52af3 | Ruby | ATLANTBH/testing-research | /s3_file_uploader/file_uploader.rb | UTF-8 | 937 | 2.53125 | 3 | [] | no_license | class FileUploader
attr_accessor :s3_resource
def initialize(options)
if options['aws_access_key_id'].nil? || options['aws_secret_access_key'].nil?
raise ArgumentError.new("Please provide region") if options['region'].nil?
@s3_resource = Aws::S3::Resource.new(region: options['region'])
else
... | true |
ce14de0018cbcecfb3f8d5dd788eedf61e730bba | Ruby | ikneeda/two-player-game | /fun_game.rb | UTF-8 | 1,339 | 3.6875 | 4 | [] | no_license | def start_game
puts "What is the first player's name?"
@nameone = gets.chomp
puts "What is the second player's name?"
@nametwo= gets.chomp
@turn = 0
@playeronelives = 3
@playertwolives = 3
@playeronescore = 0
@playertwoscore = 0
end
def game_setup
@numberone = rand(20)
@numbertwo = rand(20)
... | true |
b66b67d8da2a01ee9f0236ce1844667920577e08 | Ruby | imclab/stormsavvy | /spec/pdfs/first_report_spec.rb | UTF-8 | 2,831 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
require 'set'
require 'pathname'
require 'prawn'
require 'pdf/reader'
require 'pdf/inspector'
describe FirstReport do
let(:filename) { "#{Prawn::DATADIR}/images/reports/CEM2030-2012_Page_01.png" }
let(:content) { "stormsavvy" }
before {
create_pdf
}
describe 'pdf images' do
it... | true |
496c9319c1f0ab78addb4fc8f2da2fe47b7fa322 | Ruby | reckocp/week3-day2 | /bin/todo.rb | UTF-8 | 3,075 | 3.890625 | 4 | [] | no_license | class ToDoList
def welcome
puts "Welcome to your Daily Planner!"
puts "Please enter your name below."
print ">> "
@user_name = gets.chomp
puts "Thanks, #{@user_name}."
sleep 2
welcome_loop
end
def welcome_loop
system ("clear")
loop do
puts "Press (T) to update your to-do... | true |
690d48c9e42822cb97a759f99fd1d3a6db51688a | Ruby | gsheppard/BroadwayByRequest | /app/models/performance.rb | UTF-8 | 557 | 2.5625 | 3 | [] | no_license | class Performance < ActiveRecord::Base
has_many :set_lists
has_many :songs, through: :set_lists
def clean_time
date.to_datetime.strftime("%m/%d/%Y %H:%m")
end
def song_builder(ids)
returns = []
ids.each do |song_id|
set = SetList.new(song: Song.find(song_id), performance: self)
retur... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.