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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
88d291f3cf3b1b97d653bf18ec4fa94f9961af1a | Ruby | adampats/oroshi | /scripts/etc/subtitle-download/subtitle-download.rb | UTF-8 | 1,683 | 2.984375 | 3 | [] | no_license | # encoding : utf-8
require 'curb'
require 'nokogiri'
# Download subtitles from sous-titres.eu
class SubtitleDownload
def initialize(*args)
@website_url = 'https://www.sous-titres.eu/'
@name = args[0]
@season = args[1]
@episode = args[2]
@movie = !args[1]
end
def page_url
url = @website_u... | true |
9665d076aa34cdf9cd77b7b410cc1458f55aadb6 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/d20c69b6226f4a00bcc35d3cb32b40f0.rb | UTF-8 | 646 | 4.03125 | 4 | [] | no_license | class Bob
RESPONSES = {
:silent? => "Fine. Be that way!",
:screaming? => "Woah, chill out!",
:asking? => "Sure.",
:talking? => "Whatever."
}
def hey(sentence)
respond_to Person.new(sentence)
end
private
def respond_to(person)
RESPONSES.each do |action, response|
retu... | true |
375aa0f565de689864f6f50db40e3c9f84700d4f | Ruby | threadhead/scoutz | /config/initializers/load_constants.rb | UTF-8 | 931 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'yaml'
# loads constants from a yaml file into a method with of the same name as the file
# i.e. /config/constants/users.yml => AppConstants.users
module AppConstants
def self.load!
if !constants_paths.nil? && !constants_paths.empty?
constants_paths.each do |path|
file_name = File.basename... | true |
edb3ae13497b70f30359ca86fafeb07b55d35c3c | Ruby | glassjoseph/homework | /calculator/test/calculator_test.rb | UTF-8 | 673 | 2.734375 | 3 | [] | no_license | require 'minitest/autorun'
require '../lib/calculator'
require 'minitest/pride'
class CalculatorTest < Minitest::Test
def test_calculator_initialized
calculator = Calculator.new
assert calculator
end
def test_total_returns_total
calculator = Calculator.new
assert_equal calculator.total, 0
... | true |
23d79dc00f98c7d68c862b166ad08e2253cc8851 | Ruby | allthatilk/lrthw | /chap07/study-drills/drill1-5.rb | UTF-8 | 1,638 | 3.90625 | 4 | [] | no_license | # Assigns variable 'cars' value of 100
cars = 100
# Assigns variable 'space_in_car' value of 4.0
space_in_car = 4 # Floating point is not necessary. Removing it just
#removes the decimal place to only a whole number. See drill1-sup.png
# Assigns variable 'drivers' value of 30
drivers = 30
# Assigns variable 'passengers... | true |
6da172b4557481e79986095485258c1896f3abc6 | Ruby | kalyco/git_guide | /git_interactive.rb | UTF-8 | 419 | 3.125 | 3 | [] | no_license |
def help_list
puts "Welcome to Git Interactive Help Tutorial!"
puts "please enter a 1-word git topic to learn more about certain methods."
puts "you can also type 'exit' at any time to leave the tutorial.\n\n"
git_tutorial(response)
end
def git_tutorial(answer)
if answer == "exit"
puts "Exiting Git Inter... | true |
e4017ddc93b247a2a556081bbc745e52b5997d77 | Ruby | katel/reffy | /app/helpers/application_helper.rb | UTF-8 | 2,698 | 2.625 | 3 | [
"MIT"
] | permissive | module ApplicationHelper
def hours_for(subject)
minutes = Enquiry.tagged_with(subject).since(1.month.ago).sum(:duration_in_minutes)
return minutes_to_hours(minutes)
end
def minutes_to_hours(minutes)
hours = minutes / 60
minutes = minutes %= 60
if minutes > 0
output = "<span class='tim... | true |
2444053dff17b62dc745a288263230fc41ca5ac9 | Ruby | dcwangmit01/finance-dataservice | /test/unit/util_test.rb | UTF-8 | 2,622 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'dataservice/util'
require 'dataservice/finance'
class UtilTest < ActiveSupport::TestCase
test "Util::EMath" do
assert(Util::EMath::Numeric?("9"))
assert(Util::EMath::Numeric?("-9"))
assert(!Util::EMath::Numeric?("a"))
end
test "ETime.new()" do
et= Util::ETime.now(... | true |
2f27f0ca2817347d94f6271c4dbae32b5442f7dd | Ruby | brabemi/ctu-fit-mi-rub16 | /hw1/my_array.rb | UTF-8 | 1,221 | 3.53125 | 4 | [] | no_license | #!/usr/bin/env ruby
# Immitates some behaviour of the Array class
#
# see: http://www.ruby-doc.org/core/Array.html
class MyArray
def initialize(array = [])
@array = array
end
def size
@array.size
end
def each
size.times { |i| yield @array[i] } if block_given?
Enumerator.new do |y|
siz... | true |
20abb4b76988eef40ff2f2f20199f57df5b13f04 | Ruby | kwikiel/lsruby | /methods/random_sentence.rb | UTF-8 | 255 | 3.5 | 4 | [] | no_license | names = ['Dave', 'Sally', 'George', 'Jessica']
activities = ['walking', 'running', 'cycling']
def sentence(a,b)
a+" went "+ b +" today!"
end
def name(n)
n.sample
end
def activity(a)
a.sample
end
puts sentence(name(names), activity(activities))
| true |
41db780f7725ec6b3aef25ab9e25e1148dbe608f | Ruby | dborski/futbol | /test/game_team_test.rb | UTF-8 | 1,629 | 3.015625 | 3 | [] | no_license | require './lib/team'
require './lib/game'
require './lib/game_team'
require './test/test_helper'
require './lib/collectable'
class GameTeamTest < Minitest::Test
include Collectable
def setup
@game_team = GameTeam.new({game_id: 2012030221, team_id: "3",
hoa: "away", result: "LOSS", head_coach: "John Tort... | true |
46328e0016fcb257131f5ae42a583f56d45d015a | Ruby | Pawaz11/ruby_calc | /calculator.rb | UTF-8 | 1,719 | 4.15625 | 4 | [] | no_license | def select_mode mode
if mode == "b"
basic_mode
else
advanced_mode
end
end
#Basic mode
def basic_mode
puts "Basic mode"
#Prompt for function
puts "What operation would you like to perform?[a]ddition, [s]ubtraction, [m]ultiplcation or [d]ivision? BMI Calculator[b]"
operator = gets.chomp
puts "E... | true |
884e08603603d8e26f310d112675f2395b02d95f | Ruby | BandanaKM/flatiron-practice-problems | /02-flatiron-assessment/2-hashes/b-hashes.rb | UTF-8 | 173 | 3.9375 | 4 | [] | no_license |
# b. Write a statement to print out all the key/value pairs in the hash
instructor = {:name=>"Ashley", :age=>27}
instructor.each {|key, value| puts "#{key} : #{value}" }
| true |
f02f6479fc24ce83bffc47032a96b06e51ef9fa1 | Ruby | Chandrasekarvelraj/Calculator | /ruby_calculator.rb | UTF-8 | 1,616 | 3.890625 | 4 | [] | no_license | require "./module_calculator_validation.rb"
require "./math_operations.rb"
class Calculator
include CalculatorValidation
include MathOperations
attr_accessor :first_number, :second_number ,:option
def initialize(number_1,number_2,option_1)
@first_number = number_1
@second_number = number_2
@option = optio... | true |
fdc30820f48e25dbc63c31d054aa86863ccf4c6f | Ruby | sillygwailo/fully-jabbed-canada | /lib/format_tweet.rb | UTF-8 | 279 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
require './lib/formatter'
class FormatTweet
attr_accessor :percentage
def initialize(args)
@percentage = args[0]
end
def run
puts Formatter.new(percentage).format
end
end
FormatTweet.new(ARGV).run if $PROGRAM_NAME == __FILE__
| true |
4e6b20206cc201ac68d29c49869f5c2728901831 | Ruby | OSSSP/WhereAreTheEyes | /website/ratelimit.rb | UTF-8 | 3,631 | 2.890625 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative 'configuration'
require_relative 'log'
=begin
This file maintains the rate limiting database, which can determine
if an IP address has been posting pins too frequently. This is used
to prevent scripts from annihilating our map, or to prevent users
from skipping down the road t... | true |
cf4566b2054d34a8ad29cf75350245eb68a80ac3 | Ruby | atleastimtrying/co_ruby | /app.rb | UTF-8 | 223 | 2.828125 | 3 | [] | no_license | require "sinatra"
get "/" do
@ages = [23, 43, 56, 72, 12]
@person = {
name: 'Anders',
age: 27,
interests: [
'programming',
'more programming'
]
}
@person[:age]
@total = 2 + 3 + 4
erb :index
end | true |
3c37abd213b7499e7227dfae15e99f2b36f7d025 | Ruby | iLucker93/PersonalProjects | /SinatraTwitterIntegration/my_web_app.rb | UTF-8 | 542 | 2.578125 | 3 | [] | no_license | require 'sinatra'
require 'erb'
require_relative 'twitter_wrapper'
set :port, '3456'
set :bind, '0.0.0.0'
set :server, 'webrick'
get '/' do
@my_name = "Joseph"
@my_things = ["Move to the western USA", "Get to enjoy more outdoor activities", "Become a developer"]
erb :index, layout: :bootstrap
end
get '/tweet_u... | true |
2ed88514e6d75a56db8a5fff6887ba30e7837ba9 | Ruby | rodrigopk/to_the_moon | /src/to_the_moon.rb | UTF-8 | 713 | 3.28125 | 3 | [] | no_license | require_relative './ship'
class ToTheMoon
attr_reader :ship
def initialize(ship: Ship.new)
@ship = ship
end
def parse_input(input)
status = :green
case input
when 'w'
status = :max_speed if @ship.max_speed?
@ship.accelerate
when 's'
status = :min_speed if @ship.min_spee... | true |
dae8dea32635dba5da3599f79d04883d8dd3759d | Ruby | DavisC0801/museum_3 | /test/patron_test.rb | UTF-8 | 639 | 2.875 | 3 | [] | no_license | require "minitest/autorun"
require "./lib/patron"
class PatronTest < Minitest::Test
def setup
@bob = Patron.new("Bob", 20)
end
def test_it_exists
assert_instance_of Patron, @bob
end
def test_it_has_a_name
assert_equal @bob.name, "Bob"
end
def test_it_has_spending_money
assert_equal @b... | true |
780a5c7e88491227ca47f9ff67d441d3908772a9 | Ruby | dpalumbo/codeeval | /moderate/sudoku.rb | UTF-8 | 1,144 | 3.453125 | 3 | [] | no_license | def valid_array(n,arr)
for i in 1..n
return false unless arr.include?(i)
end
return true
end
def check_sudoku(n,arr)
squares = []
for i in 0...n
row = []
column = []
square = []
for j in 0...n
row.push(arr[n*i+j])
column.push(arr[n*j+i])
if n==9
if j > 5
... | true |
12b35d49b90bc6732657c87bb923dd35fd65466f | Ruby | Zalachenka/THP | /tests-ruby/lib/04_simon_says.rb | UTF-8 | 503 | 3.796875 | 4 | [] | no_license | def echo(str)
return str
end
def shout(str)
return str.upcase
end
def repeat(str, n=2)
return [str] * n * ' '
end
def start_of_word(str, n)
str.slice(0, n)
end
def first_word(str)
str.split.first
end
def titleize(str)
array = []
str.split.each do |item|
if item != "and" && item != "or" && item != "t... | true |
24674bb10e0ea3c0c154fc9d2073edb348687d49 | Ruby | EugZol/Benchmark | /example.rb | UTF-8 | 1,112 | 2.75 | 3 | [] | no_license | require File.dirname(__FILE__) + '/benchmark'
class A
def sum(n)
sum = 0
1.upto(n) do |i|
sum += sql(n)
sleep(0.005)
sum += sql(n-i)
end
end
def sql(n)
sleep(0.02)
Kernel.rand(n)
end
def to_s
"just A"
end
end
b = Benchmark.instance(:general)
b.for(A)
Benchmark.in... | true |
2ac8c30a9dd113c802956737f8df78eac6ad46a1 | Ruby | josieyao/module-one-final-project-guidelines-houston-web-career-021819 | /app/methods/Senior/senior_select_hobbies.rb | UTF-8 | 421 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def senior_select_hobbies(current_senior)
puts "\e[H\e[2J"
hobbies = $prompt.multi_select("What are your hobbies?") do |menu|
Hobby.all.each do |hobby|
menu.choice hobby.hobby
end
end
hobbies.each do |hobby|
hobby = Hobby.find_by(hobby: hobby)
Seniorhobby.create(s... | true |
1e8b1aa7eba77bfccb24c1a87f2c791709cea6ba | Ruby | ancastro/ac-test-first-ruby | /11_dictionary/dictionary.rb | UTF-8 | 525 | 3.453125 | 3 | [] | no_license | class Dictionary
def initialize
@entries = {}
end
def entries
@entries
end
def add(entry)
case entry
when Hash
@entries.merge!(entry)
when String
@entries[entry] = nil
end
end
def keywords
@entries.keys.sort!
end
def include?(keyword)
@entries.include?(keyword)
end
def find(keyword)
result =... | true |
811d2fbc3bb4233b5c6a9305c29928304575e120 | Ruby | jdellamore0903/capstone-debate | /front-end-free-form.rb | UTF-8 | 591 | 2.828125 | 3 | [] | no_license | require 'unirest'
p '[1] See all free form'
p '[2] See a free form'
p '[3] Create a free form'
p '[4] Update a free form'
p '[5] Delete a free form'
user_response = gets.chomp
if user_response == '1'
response = Unirest.get("http://localhost:3000/freeform")
p response.body
elsif user_response == '2'
p "What is ... | true |
e0d8d20d8ed23c7bcad1f921a4ef0e378224a9dc | Ruby | pindell-matt/the_pivot | /app/models/reservation_processor.rb | UTF-8 | 989 | 3.015625 | 3 | [] | no_license | class ReservationProcessor
def initialize(cart, user)
@cart = cart
@user = user
end
def create_trip
reservations = process_cart
trip = Trip.create(user_id: @user.id)
trip.reservations << reservations
end
def process_cart
reservations = create_reservations
reservations.each do |r... | true |
32137ae5d73dd1a20a9d294186490b3049f1e4a0 | Ruby | Ohno-Saki/Ruby-second | /game.rb | UTF-8 | 2,094 | 4.21875 | 4 | [] | no_license | def janken
puts "じゃんけん.."
puts "0(グー)1(チョキ)2(パー)"
player_hand = gets.to_i
program_hand = rand(3)
#3未満の数字がランダムに表示
if player_hand > 2
puts "入力された値が無効です"
return true
end
jankens = ["グー","チョキ","パー"]
puts "あなたの手:#{jankens[player_hand]},相手の手:#{jankens[program_hand]}"
#配列jankens に入力された0,1,2を代入し、"グー","... | true |
20654fdfdaef4943bdfac5bc8e61a486ffcdb138 | Ruby | mupkoo/rails-api | /app/lib/unauthorized.rb | UTF-8 | 285 | 2.828125 | 3 | [] | no_license | class Unauthorized < StandardError
attr_reader :message
def initialize(message = nil)
@message = message
@default_message = "You are not authorized."
@default_error_code = '401'
end
def to_s
@message || @default_message
end
end
| true |
fe35479be4ab1b4b36d62c498c3ee9e5ed2dc2ba | Ruby | MichaelDevenport/chromotype_test | /lib/cache_support.rb | UTF-8 | 883 | 2.59375 | 3 | [
"MIT"
] | permissive | module CacheSupport
def cached_with_short_ttl(key, &block)
short_ttl_cache.fetch(cache_key(key)) { yield }
end
def cached_with_long_ttl(key, &block)
long_ttl_cache.fetch(cache_key(key)) { yield }
end
def short_ttl_cache
@short_ttl_cache ||= ActiveSupport::Cache::MemoryStore.new(
:size => 3... | true |
cb04fcaf1ad116ca0fc0e53a7306e21c4088be1f | Ruby | HenryEscobar/twitterSocialMaps | /twitterSocialMapsLib.rb | UTF-8 | 13,320 | 2.765625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# Geek : Henry J. Escobar
# email : henry.escobar@gmail.com
# Legal : The MIT License (MIT)
# File :
# Purpose : Library to poll twitter and add to short/long term storage
# Notes :
# Todo :
# Write stuff to postgres since too much data for redis.
# i.e. Abusing redis to... | true |
cc02bcc0dd025857a95b36d169ea8c7c5aa78e96 | Ruby | dmaster18/tic-tac-toe-rb-online-web-sp-000 | /Practice.rb | UTF-8 | 733 | 3.421875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
board1 = ["X", "X", "X", " ", " ", " ", " ", " ", " "]
WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
]
def won?(board)
WIN_COMBINATIONS.each do |win_combination|
win_index1 = win_combination[0]... | true |
1aa91f468f24c67aef3585ee22f176203f3e833f | Ruby | EdwinRozario/ProjectEuler | /ruby/problem10.rb | UTF-8 | 280 | 3.765625 | 4 | [] | no_license | # Summation of primes
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
# Find the sum of all the primes below two million.
require 'prime'
sum = 2
(3..2000000).each do |number|
next if number.even?
sum += number if Prime.prime? number
end
p sum
# Time: 0m14.369s | true |
748493f28cc611b2e32e8d1ab92c6123151cda26 | Ruby | jaw09/algorithm_for_practice | /ruby/remove_duplicates_from_sorted_array.rb | UTF-8 | 227 | 3.203125 | 3 | [] | no_license | def remove_duplicates(nums)
if nums.count > 0
nums.each_with_index do |num, index|
while index + 1 < nums.count and num == nums[index+1]
nums.delete_at(index)
end
end
end
return nums.count
end
| true |
24b4c804472eef8a0a634a256d46b1fdaa6bc044 | Ruby | joeryan/rspec-mini | /lib/hotel.rb | UTF-8 | 415 | 3.359375 | 3 | [
"MIT"
] | permissive | class Hotel
def initialize
@guests = {}
end
def check_in_guest(guest_name, room_number)
if @guests.include?(room_number)
return false
else
@guests[room_number] = guest_name
return true
end
end
def check_out_guest(guest_name)
@guests.delete(@guests.key(guest_name))
en... | true |
b7667ee6294a0f32b4def2f51c337b9bb7503848 | Ruby | carlogaratti/GameOfLife | /start.rb | UTF-8 | 743 | 3.53125 | 4 | [] | no_license | class Cell
def initialize(live=true)
@live = live
end
def isLive?
@live
end
def live()
@live = true
end
def die
@live = false
end
end
class CellBasket
THREE = 3
TWO = 2
def initialize(cell, vicini)
@cell = cell
@map = {cell =... | true |
7e9b524804e7a19585348e45b9a903c840ece332 | Ruby | fllsouto/ruby-study | /cucumber_and_rspec_book/the_game/lib/game.rb | UTF-8 | 177 | 2.890625 | 3 | [] | no_license | class Game
attr_accessor :phase, :score
def initialize
@score = 0
end
def player_hits_target
@score = 100
end
def output
"Congratulations!"
end
end | true |
8883ba025e8d0dfaefcd804b2fa1f4b4292049cb | Ruby | elissonmichael/heroes_api | /test/models/character_test.rb | UTF-8 | 1,127 | 2.75 | 3 | [] | no_license | require 'test_helper'
class CharacterTest < ActiveSupport::TestCase
context 'validations' do
should have_many(:skills)
should validate_presence_of(:name)
%i[strength dexterity constitution intelligence wisdom charisma]
.each do |ability|
should validate_presence_of(ability)
should v... | true |
4fa35fecc6e0f7df3b2c78bf06b6df408b761c79 | Ruby | ryanjwise/Example_Code | /ruby/chris-pine/ch9_hashes.rb | UTF-8 | 1,692 | 4.15625 | 4 | [] | no_license | nl = "\n-----New_Section-----\n\n"
colorArray = [] # same as Array.new
colorHash = {} # same as Hash.new
colorArray[0] = 'red'
colorArray[1] = 'green'
colorArray[2] = 'blue'
colorHash['strings'] = 'red'
colorHash['numbers'] = 'green'
colorHash['keywords'] = 'blue'
colorArray.each do |col... | true |
4f94df749e45076a63baf21f51b0cabc9dfb4e16 | Ruby | marshallhouston/battleship | /test/gameboard_test.rb | UTF-8 | 394 | 2.578125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/gameboard'
class GameboardTest < MiniTest::Test
def test_it_exists
assert_instance_of Gameboard, Gameboard.new
end
def test_it_has_sixteen_spaces
game_board = Gameboard.new
game_board.game_spaces
expected = 16
actual = game_... | true |
8307e3c1637f71b1a330d61c3e302b5225b3ad65 | Ruby | lreynl/LS-RB101 | /small_problems_again/easy3/palindrome1.rb | UTF-8 | 207 | 3.515625 | 4 | [] | no_license | # works for string or array
def pal?(str)
str == str.reverse
end
p pal?('amanaplanacanalpanama')
p pal?('a man a plan a canal panama')
p pal?([1,2,3,4,3,2,1])
p pal?(['1','2','3','3','2','1'])
p pal?([])
| true |
8236da3f6305601e22883bdb24780ad1bc52ef99 | Ruby | koji0903/FXAnalyzer | /apps/lib/Graph.rb | UTF-8 | 1,393 | 2.890625 | 3 | [] | no_license | require 'rubygems'
require 'gruff'
require 'pp'
class MyGraph
def initialize(inf)
# Output PNG file name
@out_file = inf[:result_dir] + "/img/" + inf[:file]
# The title of Graph
@Title = inf[:title]
@Data = inf[:data] # Expect Hash data (category => data(array))
@Label = inf[:lab... | true |
3daa67ad1ba186a0b996b84a61c996543c4f7fb8 | Ruby | mathewdbutton/exercism-exercises | /ruby/luhn/luhn.1.rb | UTF-8 | 650 | 4.03125 | 4 | [] | no_license | module Luhn
def self.valid?(number)
LuhnNumber.new().valid?(number)
end
end
class LuhnNumber
def valid?(number)
clean_number = number.delete(" ")
return false if illegal_number?(clean_number)
numbers = clean_number.chars.reverse
summed_number = 0
numbers.each_with_index do |value, index|... | true |
614e5e71f30bf5b90e9a8fa58af51a3b6ddb5412 | Ruby | rocky/rb8-trepanning | /processor/virtual.rb | UTF-8 | 1,173 | 2.65625 | 3 | [] | no_license | # The class serves as the parent for Trepan::CmdProcessor which is
# quite large and spans over several files. By declaring initialize
# below, we have a consistent initialize routine and many of the
# others don't need to define initialize.
# Also, simple versions of the I/O routines make it possible
# to do testing... | true |
8d381e868c6682d889b68a21cd5b24773e8cb5f5 | Ruby | mcsham/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 514 | 3.484375 | 3 | [] | no_license | # не знаю чи варто, але якщо це не були тести я бизе вписав захист выд дурня "if string.empty?"
def echo(string)
string
end
def shout(string)
string.upcase
end
def repeat(string, repeat_count = 2)
((string + ' ') * repeat_count).strip
end
def start_of_word(string, count_letters)
string[0, count_letters]
end
... | true |
135191b206b7d05353d26bfb8a0aa59c0dc6cd0d | Ruby | JesselJohn/angular_init | /test/testing_utils.rb | UTF-8 | 392 | 2.703125 | 3 | [
"MIT"
] | permissive | # Some testing utilities
module TestingUtils
# Turn output on or off
class ToggleOutput
def initialize(bool)
case bool
when true
def puts(o)
super(o)
end
def print(o)
super(o)
end
when false
def puts(_)
nil
end
... | true |
db632baf79e242acc32ed41cd917141de3450e9e | Ruby | lucasuyezu/cloud-api-exemplos | /ruby/locaweb_cloud_api_client.rb | UTF-8 | 853 | 2.53125 | 3 | [] | no_license | require "base64"
require "digest"
require "restclient"
class LocawebCloudAPIClient
def initialize(login, chave_secreta)
@login = login
@chave_secreta = chave_secreta
@url_api = "https://cloud.locaweb.com.br/api"
end
def listar_servidores
RestClient.get("#{@url_api}/instances", generate_signatur... | true |
c883f90579d4c80ce660711d4c2c53b89661650e | Ruby | dobestan/codelion.net | /hw/part0/part0-hw4.rb | UTF-8 | 1,515 | 4.125 | 4 | [] | no_license | #encoding=utf-8
# implementation of BMI_checker
def BMI_checker(height, weight)
standard_weight = get_standard_weight(height)
obesity_rate = get_obesity_rate(height, weight)
state = get_state(obesity_rate)
puts "-"*30
puts "Standard Weight(kg) : #{standard_weight}"
puts "Obesity Rate(%) : #{obesity_rate}"
puts... | true |
ad681212b706ad3a263bfd0ef78cb204937dd37f | Ruby | mirichi/dxruby | /sample/new_sample/sprite_simple.rb | SHIFT_JIS | 1,441 | 2.96875 | 3 | [
"Zlib"
] | permissive | #!ruby -Ks
require "dxruby"
class Ruby < Sprite
RT = RenderTarget.new(640,480)
MAX_X = 639 - 32
MAX_Y = 479 - 32
# ImageIuWFNg쐬
@@image = Image.load("ruby.png")
# \bh
def initialize
super
self.x = rand(MAX_X)+1 # xW
self.y = rand(MAX_Y)+1 # yW
self.image = @@image # 摜
self.target =... | true |
e6759f2ae869ad21552e18dbdf9ebc6fcfa7fa1a | Ruby | choltz/mail_check | /sys/mail_updater.rb | UTF-8 | 1,547 | 3.125 | 3 | [] | no_license | require_relative 'event_emitter'
# Public: Register multiple sources for email and check each of them
# for new mail. Send messages to registered services if there are
# new messages.
#
# Examples
# updater = MailUpdater.new
# updater.add_mail_source OfflineImapSource.new
# updater.process
class MailUpdater < Ev... | true |
874ff58db2a22a5b4f56ab771eba648d18197fdb | Ruby | jeffnyman/lucid_checkup | /lib/lucid_cop.rb | UTF-8 | 2,965 | 2.578125 | 3 | [
"MIT"
] | permissive | require "set"
require "gherkin/parser"
require "lucid_cop/config"
require "lucid_cop/cop"
require "lucid_cop/cops/avoid_punctuation"
require "lucid_cop/cops/avoid_non_context_backgrounds"
require "lucid_cop/cops/avoid_single_scenario_backgrounds"
require "lucid_cop/cops/avoid_duplicate_scenario_names"
require "lucid_c... | true |
5891d5b5aeff412dc0fa5c46fe087114677bf4d3 | Ruby | aepstein/charon | /lib/fulfiller.rb | UTF-8 | 981 | 2.53125 | 3 | [] | no_license | module Fulfiller
module ClassMethods
def is_fulfiller(*fulfillable_types)
unless defined? fulfillments
cattr_accessor( :fulfillable_types ) { [] }
send :include, InstanceMethods
end
class_eval <<-RUBY
scope :fulfill, lambda { |fulfillable|
unless #{self.to_s}... | true |
64a37dbc2bb15be9d39f674f7bf5f2faf1fb70c5 | Ruby | brgeen/Learn-Ruby-The-Hard-Way-Practice | /nametest.rb | UTF-8 | 436 | 3.640625 | 4 | [] | no_license | def myname
"Jeff"
end
def lb
"\n"
end
puts "Hello we are going to write your name"
puts lb
puts "What is your first name?"
firstname = $stdin.gets.strip
puts "What is your middle name?"
middlename = $stdin.gets.strip
puts "What is your last name?"
lastname = $stdin.gets.strip
puts lb
puts "Ok so your name is #{... | true |
9937f33710f40e96530d7fe7696f7983ed466b87 | Ruby | kevin-mcm/TDD-FIZZ-BUZZ | /spec/fizzbuzz_spec.rb | UTF-8 | 1,584 | 3.140625 | 3 | [] | no_license | require "./lib/fizzbuzz"
describe FizzBuzz do
before :each do
@fb = FizzBuzz.new()
end
it "deberia generar '1' pra el nro '1'" do
expect(@fb.generar(1)).to eq "1"
end
it "deberia generar '2' pra el nro '2'" do
expect(@fb.generar(2)).to eq "2"
end
it "deberia retor... | true |
add6c76b3b89fa92b94fbe0fa8092c5b653e82b7 | Ruby | 97-Jeffrey/ar-exercises | /exercises/exercise_5.rb | UTF-8 | 479 | 3.21875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
puts "Exercise 5"
puts "----------"
# Your code goes here ...
puts "these are the sums of all revenues"
puts Store.sum("annual_revenue")
puts "these are the ave... | true |
d6a370c00345acef589ff4ace1d68ab3835cd905 | Ruby | davidedelerma/weekend_1_homework | /pet_shop.rb | UTF-8 | 1,725 | 3.25 | 3 | [] | no_license | require 'pry-byebug'
def pet_shop_name(pet_shop)
return name=pet_shop[:name]
end
def total_cash(pet_shop)
return tot_cash=pet_shop[:admin][:total_cash]
end
def add_or_remove_cash(pet_shop,cash)
tot_cash=total_cash(pet_shop)
return pet_shop[:admin][:total_cash]=tot_cash+cash
end
def pets_sold(pet_shop)
r... | true |
35f5a321d4106ffad9c3bd2e0b2d1ee6333b424b | Ruby | ethanhust/devs | /lib/devs/simulation.rb | UTF-8 | 12,787 | 2.546875 | 3 | [
"MIT"
] | permissive | module DEVS
# This class represent the interface to the simulation
class Simulation
include Logging
include Enumerable
attr_reader :duration, :time, :processor, :model
# @!attribute [r] time
# @return [Numeric] Returns the current simulation time
# @!attribute [r] start_time
# @re... | true |
ff59928e474004d7b7e7515a2aa7203e80d233b3 | Ruby | ruby-accel/ruby-viennacl | /tool/bechmark.rb | UTF-8 | 1,343 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'numo/narray'
require 'numo/linalg'
require 'viennacl'
require 'benchmark'
include Numo
include ViennaCL
size = 1300
Benchmark.bmbm do |x|
[["float", SFloat, SFloatMatrix], ["double", DFloat, DFloatMatrix]].each{|tag, na, cl|
a = na.new(size, size).rand(1,10)
b = na.new(size, size).rand(1,10)
# ... | true |
a877015666fe767f811f57f4528a9a3fef7f1f38 | Ruby | tenseisan/movie_choice | /main.rb | UTF-8 | 943 | 3.671875 | 4 | [] | no_license | require_relative 'film'
current_path = File.dirname(__FILE__)
# Create empty arrays for directors and movies
films_list = []
directors_list = []
# File list from folder
files = Dir[File.join(current_path, 'data/*.txt')].sort
# Create object for each file
files.each do |item|
movie = Film.new(item)
films_list <<... | true |
25c0338e6d9cbc98c47aacfade7e2e96a04b345e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/38e6f9535143424084fa8dd275852be2.rb | UTF-8 | 494 | 3.78125 | 4 | [] | no_license | class Bob
def hey(phrase)
raise ArgumentError, 'Bob only likes strings.' unless phrase.respond_to?(:to_str)
phrase = phrase.to_str
silence?(phrase) || shouting?(phrase) || question?(phrase) || statement
end
def question?(phrase)
'Sure.' if phrase.end_with?('?')
end
def shouting?(phrase)
... | true |
d4726cbdd9797905fdffe7dd55e4580708b16595 | Ruby | jgalisteo/submit_badge | /app/services/submit_badge_service.rb | UTF-8 | 328 | 2.609375 | 3 | [] | no_license | class SubmitBadgeService
attr_reader :badge, :post_hash_service
def initialize(badge, service)
@badge = badge
@post_hash_service = service.new(badge.to_sha256)
end
def run
response = post_hash_service.run
proof_id = response['hashes'].first['proof_id']
badge.update(proof_id: proof_id)
... | true |
0261dd9e37e2823945c75a23f20826931afb0ff6 | Ruby | nathaliesantana/my-each-v-000 | /my_each.rb | UTF-8 | 219 | 3.4375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each (array)# put argument(s) here
c = 0
new_each = []
while c < array.length
yield (array[c])
c += 1
end
array
end
array = ['hi', 'hello', 'bye', 'goodbye']
my_each(array) do |n|
"#{n}"
end
| true |
7925a80360662082b67fc313284af79c604c1fe7 | Ruby | tpickett66/Project-Euler-Solutions | /bin/101-150/p149 | UTF-8 | 1,107 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: UTF-8
$:.unshift(File.dirname(__FILE__) + '/../../lib') unless $:.include?(File.dirname(__FILE__) + '/../../lib')
# Looking at the table below, it is easy to verify that the maximum possible sum of adjacent numbers in any direction (horizontal, vertical, diagonal or anti-diagonal) is 16... | true |
2d8555e3b7e22121b46569e83abbba31d99f0c53 | Ruby | hagsey/rubybook | /Intro to programming/4_Flow_Control/3_number.rb | UTF-8 | 864 | 4 | 4 | [] | no_license |
def evaluate_num(num)
if num < 0
p "You didn't pay attention to the instructions."
elsif num <=50
p "#{num} is between 0 and 50"
elsif num <=100
p "#{num} is between 50 and 100"
else
p "You didn't pay attention to the instructions."
end
end
def evaluate_num1(num)
case
when 0..50
p "#{num} is betwee... | true |
2c07e21d666c242052284a75e73d7ebbf8d82078 | Ruby | jcat1504/codewarsruby | /Untitled9.rb | UTF-8 | 203 | 3.53125 | 4 | [] | no_license | #Find the number with the most digits. If two numbers in the
#argument array have the same number of digits, return the first one
#in the array
def find_longest(arr)
arr.max_by{|num| num.to_size}
end
| true |
6b5e65bfa441eb2692e5bcdd6fa0952634465219 | Ruby | Joshuaatt/accessory_app_v2 | /app/models/order.rb | UTF-8 | 602 | 2.546875 | 3 | [] | no_license | class Order < ActiveRecord::Base
belongs_to :order_status
has_many :order_items, :dependent => :destroy
has_one :checkout
before_create :set_order_status
before_save :update_subtotal
def subtotal
order_items.collect { |oi| oi.valid? ? (oi.quantity * oi.unit_price) : 0 }.sum
end
def monthly_subtota... | true |
39ae665132b17729bc16917263419a4e9d8be213 | Ruby | benbristow/train-times | /lib/api/calling_point.rb | UTF-8 | 433 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class CallingPoint
attr_accessor :station, :estimated, :scheduled
def initialize(info)
@station = Station.from_location(info)
@scheduled = info[:st] || info[:sta]
@estimated = parse_estimated(info)
end
private
def parse_estimated(info)
estimated_value = info[:... | true |
0621904739f96db843e6dbb484d9deb69d25794b | Ruby | jessykate/Verneuil | /bloomfilter.rb | UTF-8 | 711 | 3.421875 | 3 | [] | no_license | require 'bitfield.rb'
require 'digest/sha1'
class BloomFilter
=begin
Initializes the Bloomfilter to size bits, and k hash functions
=end
def initialize(size, k)
@size, @k = size, k
@field = BitField.new(size)
end
# Insert an element into the bitfield
def insert(key)
(1..@k).each{|n|
d = Dig... | true |
bd96ba708e2de0ffb2dfedf46ca70a8bb13358f8 | Ruby | zenm/RB101 | /RB101/exercises_small_problems/easy06/e06_09_does_my_list_include_this.rb | UTF-8 | 593 | 4.28125 | 4 | [] | no_license |
# Write a method named include? that takes an Array and a search value as arguments.
# This method should return true if the search value is in the array, false if it is not.
# You may not use the Array#include? method in your solution.
def include?(array_to_check, value)
i = 0
in_array = false
while i < arra... | true |
9ea046e21b8047f5982d270a2b790e00172bc4b0 | Ruby | twrameshb/frameworks | /Selenium-Ruby-Project1/selenium/tests/spikes/datetime_helper.rb | UTF-8 | 553 | 2.640625 | 3 | [] | no_license | #require File.expand_path(File.dirname(__FILE__) + "/../lib/object_repository")
module DatetimeHelper
def getCurrentDate
return Time.zone.today.strftime('%d').to_s
end
def getCurrentMonth()
return month1 = Time.zone.today.strftime('%b').to_s
end
def getCurrentYear()
return year = ... | true |
16f0a68d24db3f3b1310d2c6d6494be8f238296f | Ruby | kangazoom/adagrams | /lib/adagrams.rb | UTF-8 | 4,202 | 3.78125 | 4 | [] | no_license | # adds csv gem
require "csv"
# initialize global variable
$words_hash = {}
# wave 1
def draw_letters
# draw letters
# letter pool
pool = ('A'*9 + 'B'*2 + 'C'*2 + 'D'*4 + 'E'*12 + 'F'*2 + 'G'*3 + 'H'*2 + 'I'*9 + 'J' + 'K' + 'L'*4 + 'M'*2 + 'N'*6 + 'O'*8 + 'P'*2 + 'Q' + 'R'*6 + 'S'*4 + 'T'*6 + 'U'*4 + 'V'*2 + 'W... | true |
dbf780821cb03586750d0e7f879282f76ec091a0 | Ruby | oorion/exercism | /ruby/kindergarten-garden/garden.rb | UTF-8 | 1,060 | 3.265625 | 3 | [] | no_license | class Garden
PLANTS = {"V" => :violets, "C" => :clover, "R" => :radishes, "G" => :grass}
STUDENTS = [
:alice,
:bob,
:charlie,
:david,
:eve,
:fred,
:ginny,
:harriet,
:ileana,
... | true |
897f5d0af99f81ea81bbe19b438df0296c8ece8f | Ruby | jamogriff/adopt_dont_shop | /spec/models/shelter_spec.rb | UTF-8 | 4,928 | 2.78125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Shelter, type: :model do
describe 'relationships' do
it { should have_many(:pets) }
end
describe 'validations' do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:city) }
it { should validate_presence_of(:rank) }
it { should va... | true |
dcd941ea22390ab6903a54b4b224200fb03f0b48 | Ruby | diogobira/mc4arm | /parametros.rb | UTF-8 | 991 | 2.765625 | 3 | [] | no_license | require 'roo'
require 'probability.rb'
require 'loader.rb'
class Parametros
#Includes
include Probability
include Loader
#Accessors para atributos derivados.
attr_accessor :participantes
attr_accessor :parametros
#Inicialização
def initialize(arquivo)
sh = Roo::Spreadsheet.open(arquivo).sheet(0)
keys... | true |
17faf5af6e2569da776eb6642c4eeda8b2285e1b | Ruby | sergio-fry/pic-pac | /app/models/picture.rb | UTF-8 | 1,454 | 2.515625 | 3 | [] | no_license | require 'RMagick'
require 'open-uri'
require 'digest/sha1'
class Picture < ActiveRecord::Base
before_destroy :erase_file
def resize(width, height=nil)
width, height = width.to_i, height.try(:to_i)
img = Magick::Image.read(src_url)[0]
img.format = "JPEG"
if height.present?
logger.debug "cro... | true |
2be5f8d51765e79a0994cf3b42fe3425224d7e08 | Ruby | Macaroni2629/Launch-School | /RB100_back_end_prep/ruby_exercises/return/breakfast_lunch_or_dinner_part3.rb | UTF-8 | 136 | 3.28125 | 3 | [] | no_license | def meal
return 'Breakfast'
'Dinner'
end
puts meal
# The meal method will return 'breakfast' because of the explicit 'return.' | true |
3be577240a28e8d45ed5a666414ad828b3cae60c | Ruby | lina5147/adagrams | /lib/adagrams.rb | UTF-8 | 3,092 | 4.21875 | 4 | [] | no_license | def draw_letters
letter_quantities = {
A: 9,
B: 2,
C: 2,
D: 4,
E: 12,
F: 2,
G: 3,
H: 2,
I: 9,
J: 1,
K: 1,
L: 4,
M: 2,
N: 6,
O: 8,
P: 2,
Q: 1,
R: 6,
S: 4,
T: 6,
U: 4,
V: 2,
W: 2,
... | true |
087297c7c59595c0d84665cc10c1ffb89bf848ab | Ruby | kimili/ui-parser-exercise | /lib/ui_parser.rb | UTF-8 | 1,292 | 3.15625 | 3 | [] | no_license | class UIParser
def initialize(data)
@data = data
end
def parse(selector)
find selector
end
private
def find(selector)
selector = selector.strip
key = case selector
when /^\./
'classNames'
when /^#/
'identifier'
else
'class... | true |
b48a142610ca340f208ee5e3c94e9245e14b92fe | Ruby | jcgq/PDOO_Ugr | /Ruby/civitas/pkg/civitas-0.0.1/lib/casilla.rb | UTF-8 | 811 | 2.6875 | 3 | [
"MIT"
] | permissive | #encoding: utf8
require_relative 'titulo_propiedad'
require_relative 'mazo_sorpresa'
require_relative 'sorpresa'
require_relative 'operaciones_juego'
module Civitas
class Casilla
attr_accessor :nombre
def initialize(_nombre)
@nombre=_nombre
end
def informe(iactual, todos)#METODO ... | true |
ae07809631439631820bbf93e13896aae284be7a | Ruby | jbarreneche/s5-e3 | /test/lib/bin/rectangle_test.rb | UTF-8 | 1,200 | 2.765625 | 3 | [] | no_license | require_relative '../../test_helper'
require 'bin/rectangle'
class RectangleTest < MiniTest::Unit::TestCase
def setup
@rectangle = Bin::Rectangle.new(5..25, 10..20)
end
def test_left
assert_equal 5, @rectangle.left
end
def test_right
assert_equal 25, @rectangle.right
end
def test_top
... | true |
84ca21e486834ee66fae1573f8a3c2b61f3f0670 | Ruby | samdalton/railsquest | /lib/railsquest/badge.rb | UTF-8 | 1,726 | 2.625 | 3 | [
"MIT"
] | permissive | require 'pathname'
module Railsquest
class Badge
attr_accessor :name
def self.for_name(name)
n = name.gsub(' ', '_')
q = new(Railsquest.badges_path.join(n + ".badge"))
q.name = n
q
end
def self.html_id(name)
name.gsub(/[^A-Za-z-]+/, '').downcase
end
def initi... | true |
4d4fd1cce747da3d16dba4b205e61b1b5422a70e | Ruby | jonsample/GreenSTEM-Server | /app/models/node_reading.rb | UTF-8 | 1,578 | 2.859375 | 3 | [] | no_license | class NodeReading < ActiveRecord::Base
attr_accessible :node_id, :created_at, :soil1, :soil2, :soil3, :temp
belongs_to :node
# default_scope order('created_at DESC')
include_root_in_json = true
def as_json(options = {})
super({methods: [:site_name, :site_id, :converted_values, :average_status_name, :s... | true |
bd1ca04dd36b056b5e1221383ae480990084f993 | Ruby | DorianCBrwn/LaunchSchoolDCB | /RB120/Lesson5/twenty_one_1.rb | UTF-8 | 1,049 | 3.515625 | 4 | [] | no_license | class Participant
attr_accessor :hand
def initialize
@hand= []
end
def hit
end
def stay
end
def busted?
end
def total
# definitely looks like we need to know about "cards" to produce some total
end
end
class Player < Participant
end
class Dealer < Participant
end
class Deck
RANKS =... | true |
0a0613c37dafc3aaad0c9361c24f422fe1b0b68e | Ruby | JonathonMA/weetbix | /spec/spec_helper.rb | UTF-8 | 3,870 | 2.59375 | 3 | [
"MIT"
] | permissive | $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "weetbix"
module Types
include Dry.Types()
Statuses = Types::Strict::String.enum("draft", "published", "archived")
class Foo < Dry::Struct
attribute :amount, Types::Strict::Decimal
attribute :timestamp, Types::Strict::Time
end
class St... | true |
4c0cf28202579c05495c33b821a18511ed1b1f7b | Ruby | CMUChimpsLab/urban_analytics | /GreenField/app/models/climate.rb | UTF-8 | 622 | 3.15625 | 3 | [] | no_license | class Climate < ActiveRecord::Base
scope :for_date, -> (date){ where(EST: date) }
scope :for_month, -> (date){ where(EST: date) }
def self.meantemp(date)
data = self.for_date(date)
data.each do |weatherdata|
temp=weatherdata.Mean_TemperatureF
return temp
end
end
def self.averagetemp(date... | true |
9da8381205a5fe9f5be806a6b931a3b54105eaf3 | Ruby | Halfino/address_parser | /main.rb | UTF-8 | 885 | 2.734375 | 3 | [] | no_license | require 'zip'
require 'csv'
require 'benchmark'
require 'json'
require 'elasticsearch'
require_relative 'address_downloader'
require_relative 'address'
require_relative 'zip_parser'
time = Benchmark.measure {
downloader = AddressDownloader.new()
downloader.download_csv_files()
file = 'csv.zip'
parser = ZipPar... | true |
469a859da36c9668db15978c6e4bbc2e01df8d4a | Ruby | premnirmal/Addressbook | /app/models/address.rb | UTF-8 | 432 | 2.546875 | 3 | [] | no_license | class Address < ActiveRecord::Base
belongs_to :entry
belongs_to :address_type
attr_accessible :city, :state, :street, :zip, :entry_id, :address_type_id
validates :zip, :address_type_id, :state, :presence => true
validates_length_of :zip, is: 5
validates_length_of :state, is: 2
def state=(val)
wr... | true |
a378d79a84900b2d66ee375227e06ae17bb6413e | Ruby | maxdanilov/subscity | /app/helpers/parser_base.rb | UTF-8 | 367 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'json'
module ParserBase
def get_first_regex_match(str, regex)
nil unless str.is_a? String
result = str.match(regex)
if result.nil?
nil
else
result[1]
end
end
def get_first_regex_match_integer(str, regex)
get_first_regex_match(str, regex).to_i
end
def parse_json(... | true |
0aac0e830498fecce3a247c9f8563c5d7d6651dd | Ruby | CreamCoderz/vinyl-guide | /app/models/release.rb | UTF-8 | 1,700 | 2.515625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../../lib/query_generator'
class Release < ActiveRecord::Base
SEARCHABLE_FIELDS = [:title, :artist, :matrix_number]
VALID_YEARS = (1940..Time.now.year).to_a.reverse
has_many :ebay_items, :order => "updated_at DESC"
belongs_to :format
belongs_to :label_entity, :class_name =... | true |
9a8aaa6625abe2b97d6943d264ad865a8adece37 | Ruby | MustafaHaddara/advent-of-code-2019 | /ruby/day13-2.rb | UTF-8 | 6,198 | 3.328125 | 3 | [] | no_license | class IntCode
def initialize(instructions)
@instructions = instructions
@ptr = 0
@in_buff = []
@out_buff = []
@rel_base = 0
@blocked = false
end
def send_input(thing)
@in_buff.push(thing)
end
def read_output()
return @out_buff.shift()... | true |
a95f4b2f90e9a1ce38adf878f498a1b5d1bf26e2 | Ruby | jpmaggs11/ruby-challenges | /blog.rb | UTF-8 | 1,515 | 3.75 | 4 | [] | no_license | class Blog
def push_it=(*args)
@all_posts_array = []
@all_posts_array.push(*args)
end
def post_counter
index = 0
index += 1
puts "You're up to #{index} posts."
end
def publish
puts "#{@all_posts_array}"
end
end
class BlogPost < Blog
def set_title=(title)
@@title = title
end
def get_tit... | true |
0076392a286dcbbbf180e5c8f64ec7942671693f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/148e05f77f614d3b8db77a6a532bd9e4.rb | UTF-8 | 407 | 3.90625 | 4 | [] | no_license | class Bob
def hey(string)
@string = string
if blank?
return "Fine. Be that way!"
elsif capitalized?
return "Woah, chill out!"
elsif question?
return "Sure."
else
"Whatever."
end
end
def blank?
@string == nil || @string.strip == ""
end
def question?
@... | true |
edc7e504a11e8657bd08b30de94c0ef6c49ecbcd | Ruby | Soumya739/ruby-enumerables-hash-practice-nyc-pigeon-organizer-lab-seattle-web-091619 | /nyc_pigeon_organizer.rb | UTF-8 | 854 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def nyc_pigeon_organizer(data)
new_hash = Hash.new
color_hash = data[:color]
color_hash.each do |key, value|
value.each do |name|
if new_hash.key?(name) == false
new_hash[name] = {:color => [], :gender => [], :lives => []}
end
new_hash[name][:color].push("#{key}")
end
end
gender_... | true |
97bf492f4aa28b3001370af8c62d4417d72b828c | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz90_sols/solutions/David Tran/grid_fill.rb | UTF-8 | 1,081 | 3.5625 | 4 | [
"MIT"
] | permissive | class PenAndPaperGame
MOVES = [[3,0], [-3,0], [0,3], [0,-3], [2,2], [2,-2], [-2,2], [-2,-2]]
def initialize(size)
@size = size
@largest = @size * @size
@board = Array.new(@size) { Array.new(@size) }
end
def to_s
return "No solution." unless @board[0][0]
digits = @largest.to_s.size
" #{'-' * (dig... | true |
585489c9124eb5c1f89bafe17afa15f7e684356a | Ruby | soveran/hart | /test/all.rb | UTF-8 | 3,088 | 2.546875 | 3 | [
"MIT"
] | permissive | scope "generic routing" do
peru = proc { |key|
case key
when :population
30_400_000
when :area
1_285_216
else
nil
end
}
@words = {
"peru" => peru,
"c" => {
"o" => {
"d" => {
define: "A husk; a pod; as, a peascod.",
"a" => {
... | true |
81f563bfc81c756d715001b6dd83b74f4fd2f08f | Ruby | VictorHAlbu/exercicios | /classes/conta_com_taxa.rb | UTF-8 | 521 | 2.9375 | 3 | [] | no_license | class ContaComTaxa < ContaBancaria
TAXA = 2 #COnstrate em ruby, valor da taxa não vai mudar e vais ser o mesmo
#reescrta de código/ herdando método transferir e usando ele com adicional de uma taxa de 2$
def transferir(outra_conta, valor) #recebendo a conta o qual vai transferir e o valor
sup... | true |
162d5a392069ff66e65ae284c6cc4eaeeec7947c | Ruby | ncanderson/markovian_music | /note_19_back_to_no_left_begin_time_based.rb | UTF-8 | 6,338 | 3.171875 | 3 | [] | no_license | require "midilib"
include MIDI
@notes = [] # all the note events from read in songs
@on_notes = [] # just the note on events and their duration
@new_notes = [] # notes for the new song
@table = {} # hash table of probabilities
@note_counts = {} # number of times each note is played
def read_song (son... | true |
5fc4dc503de37d1bdd1f495a79aa40702dbd0f41 | Ruby | embasbm/hackerrank | /implementation/utopian-tree.rb | UTF-8 | 495 | 3.265625 | 3 | [] | no_license | #!/bin/ruby
require 'pry'
require 'json'
require 'stringio'
# Complete the utopianTree function below.
def utopianTree(n)
height = []
height[0] = 1
1.upto(n) do |x|
if x.even?
height[x] = height[x-1] + 1
else
height[x] = height[x-1] * 2
end
end
p height[n]
height[n]
end
fptr = Fi... | true |
ceaa6a1f7b4e623a2af48aa897c9a11495811b9b | Ruby | wout/b_named | /lib/b_named/availability.rb | UTF-8 | 1,504 | 2.6875 | 3 | [
"MIT"
] | permissive | module BNamed
class Availability
API_URL = 'https://www2.bNamed.net/en/api.asp'
def initialize(uid, pass_key)
@uid = uid
@pass_key = pass_key
raise ArgumentError.new("Please provide a uid and pass_key") if @uid.nil? || @pass_key.nil?
end
def check(sld, tlds=nil)
@tlds... | true |
299c511d82ea1c2ab879ac3e101a78864e2f5719 | Ruby | rocknsm/rock-dashboards | /ecs-configuration/logstash/ruby/logstash-ruby-filter-merge-dict-array.rb | UTF-8 | 1,425 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | def register(params)
@source_field = params["source_field"]
@target_field = params["target_field"]
end
def filter(event)
# Tag and quit if source field isn't set
if @source_field.nil?
event.tag("array_dict_merge_source_not_set")
return [event]
end
# Tag and quit if target field isn't set
if @tar... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.