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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9d3a61cd70f3f5e87064a1f49709c5d3e8f592e7 | Ruby | DEFRA/waste-carriers-back-office | /lib/tasks/summary_stats.rake | UTF-8 | 6,477 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"OGL-UK-3.0"
] | permissive | # frozen_string_literal: true
# rubocop:disable Metrics/BlockLength
namespace :summary_stats do
desc "Generate simple summary stats for use in quarterly DEFRA reports"
task :stats_for_date_range, %i[start_date end_date] => :environment do |_t, args|
include ActionView::Helpers::NumberHelper
unless args[... | true |
2bcf65a72e8096c6f95d0e27470cd03666a222ab | Ruby | stupeters187/lh-cohort2 | /week1/wed/countingcharacters.rb | UTF-8 | 669 | 4.03125 | 4 | [] | no_license | require 'pry'
def count_letters(string)
container = Hash.new(0)
words = string.split(" ")
words.each do |word|
letters = word.split("")
letters.each do |letter|
# Does the hash contain this letter?
if container[letter]
# If it does you want to set the value for key (letter) to increm... | true |
53fbf89b543245555d7efc9e2c9ccd399f77e878 | Ruby | superiorlu/unicorn_metrics | /lib/unicorn_metrics/request_counter.rb | UTF-8 | 1,261 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | module UnicornMetrics
# Counter defined to keep count of method types of http requests
# Requires the UnicornMetrics::Middleware
class RequestCounter < Counter
attr_reader :path, :method_name
# @param name [String] user-defined name
# @param method_name [String] name of the HTTP method
# @param p... | true |
55b99bdd419a9e3ee670ffda5f483f4b76ee2246 | Ruby | isabella232/identity-monitor | /bin/circleci-run | UTF-8 | 1,306 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
def run_and_retry_tests(environment, retries)
cmd = ['HEADLESS_BROWSER=true', "LOWER_ENV=#{environment}", 'bundle', 'exec',
'rspec']
retry_flags = ['--only-failure']
retries.times do
return if system cmd.join(' ')
puts "Smoke tests failed in #{environmen... | true |
c50b36aefeaafab01b480ddceb2ad6522686bdbe | Ruby | ilairevillegas81/sexy_numerics | /lib/sexy_numerics.rb | UTF-8 | 2,166 | 3.171875 | 3 | [
"MIT"
] | permissive | module SexyNumerics
module ClassMethods
# Allows a column to accept commas from users for numeric fields.
# The commas are removed when the new value is assigned.
#
# Example:
# class City < ActiveRecord::Base
# allow_commas :population, :foo, :bar
def allow_commas(*args)
add_equ... | true |
a33f747d20a9bbe1f57afa617f0a70f804fc5070 | Ruby | Renestl/AAO | /3 Ruby/1 Enumerables_Debugging/Projects/Enumerable/enumerables.rb | UTF-8 | 1,799 | 4.59375 | 5 | [] | no_license | class Array
# My Each
# Extend the Array class to include a method named my_each that takes a block, calls the block on every element of the array, and returns the original array.
def my_each(&prc)
idx = 0
while idx < self.length
prc.call(self[idx])
idx += 1
end
self
end
# My Select
# Now exten... | true |
0116b499d3d0be37798a56b061299e40d351456b | Ruby | Gizmokid2005/swissircbot | /old.plugins/worldweather.rb | UTF-8 | 2,915 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'net/http'
require 'json'
class Worldweather
include Cinch::Plugin
include CustomHelpers
set :help, <<-HELP
weather <location>
This will return weather results for location from WorldWeather.
HELP
match /weather (.+)$/i
def execute(m, location)
if !is_blacklisted?(m.channel, m.user.nick)
... | true |
b58cb3aa1f38f8b1084778cd9ca4ee49e6b43343 | Ruby | davidpatrick/audioprint | /app/models/order_item.rb | UTF-8 | 582 | 2.578125 | 3 | [] | no_license | class OrderItem < ActiveRecord::Base
attr_accessible :order_id, :product_id, :product_type, :quantity
belongs_to :order
belongs_to :product, polymorphic: true
validates_presence_of :order_id, :product_id, :product_type, :quantity
validate :validate_quantity, :if => Proc.new{|item| item.product_type == 'Album'... | true |
72bc63f6ae01168b02f3d7c2f02859dde3cfdd45 | Ruby | Andrelton/kor-league | /app/models/owner.rb | UTF-8 | 1,440 | 2.796875 | 3 | [] | no_license | class Owner < ActiveRecord::Base
has_many :owner_clubs
has_many :clubs, through: :owner_clubs, source: :club
attr_accessor :head_rank, :goal_rank
# --- CLASS METHODS ---
def self.ranked_by_heads
ranked_owners = Owner.all.sort_by { |owner| owner.heads.count }.reverse!
previous_owner_head_count = nil... | true |
90572884249d787bef7ece6216a0b5691ed8dab9 | Ruby | MAI-302/sandbox-2015 | /Rodnin/Ruby/Path/path.rb | UTF-8 | 815 | 3.109375 | 3 | [] | no_license | input = File.open("input.txt") {|file| file.read}
i = 0
input_array = []
input.split("\n").each do |str|
input_array[i] = str.split(' ').map! {|ch| ch.to_i}
i += 1
end
i = j = input_array.count - 1
while i != 0 || j != 0 do
input_array[i-1][j-1] = input_array[i-1][j-1] + [input_array[i][j], input_array[i][j-1]]... | true |
0f250f364e8f03e1036bd19082beadb667c9a841 | Ruby | jacknguyen/projects-ruby-building-blocks | /03_substrings/substrings.rb | UTF-8 | 330 | 3.109375 | 3 | [] | no_license | def substrings strs, dict_arr
words = strs.downcase.split(' ')
output = Hash.new
words.each do |word|
dict_arr.each do |dic_def|
if (word.include? dic_def) && output[dic_def] != nil
output[dic_def] += 1
elsif word.include? dic_def
output[dic_def] = 1
end
end
end
ou... | true |
f62c739c713a374e053eeb0ce7db0964bf712149 | Ruby | DaddyWozBucks/ironhack | /shoppingcart.rb | UTF-8 | 359 | 2.546875 | 3 | [] | no_license | Items = [ "Banana", "Orange Juice", "Vacuum Cleaner", "Anchovies", "Rice" ]
class Item
def intialize(name, price)
@name = name
super(name)
@price = price
end
end
class ShoppingCart
@@total = 0
def intialize(discount)
@discount = array1.discount
def discount(Item)
if == "... | true |
6fc9a95dc8388190034058d18dd1c801b1ce5dbd | Ruby | takkkun/peeek | /spec/peeek/hook/instance_spec.rb | UTF-8 | 2,559 | 3 | 3 | [
"MIT"
] | permissive | require 'peeek/hook/instance'
def sample_instance_linker(method_name = :%)
Peeek::Hook::Instance.new(String, method_name)
end
describe Peeek::Hook::Instance, '#method_prefix' do
it 'returns "#"' do
linker = sample_instance_linker
linker.method_prefix.should == '#'
end
end
describe Peeek::Hook::Instance... | true |
b5a83c810cf52b67bac88347fac7f52d62c71ae3 | Ruby | ducngtuan/euler | /problem67/problem67.rb | UTF-8 | 328 | 3.3125 | 3 | [] | no_license | @triangle = []
File.open("triangle.txt") do |f|
while line = f.gets
@triangle << line.split.map!{|x| x.to_i}
end
end
(@triangle.size - 2).downto(0) do |row|
0.upto(@triangle[row].size - 1) do |col|
@triangle[row][col] += [@triangle[row + 1][col + 1], @triangle[row + 1][col]].max
end
end
puts @triang... | true |
f5d99aeda9797d184c5eaeae3d61b8526bc51115 | Ruby | strickinato/app-academy-blob-repo | /app-academy-work/week1/day4/make_change.rb | UTF-8 | 602 | 3.421875 | 3 | [] | no_license | def make_change_american(amount, coins = [25, 10, 5, 1])
return [] if amount == 0
if amount >= coins.first
make_change(amount - coins.first, coins) << coins.first
else
make_change(amount, coins.drop(1))
end
end
def make_change(amount, coins = [25, 10, 5, 1])
current_best = make_change_american(amo... | true |
99d7a95fc7bdddf34938a5bd42b23e1054aba282 | Ruby | koriroys/struct | /lib/my_struct.rb | UTF-8 | 270 | 3.203125 | 3 | [] | no_license | # MyStruct = Struct
# delete the above and create your own:
class MyStruct
def self.new(*args)
raise ArgumentError, "wrong number of arguments (0 for 1+)" if args.empty?
raise TypeError unless args.all? { |arg| arg.kind_of?(Symbol) }
Class.new
end
end
| true |
be5763816b4dc77a3367559a1a1f163b6cea8b06 | Ruby | toreserter/coinmarketcal | /lib/coinmarketcal/coin.rb | UTF-8 | 353 | 2.84375 | 3 | [
"MIT"
] | permissive | module Coinmarketcal
class Coin
attr_reader :id, :name, :symbol
def initialize(attrs = {})
@id = attrs['id']
@name = attrs['name']
@symbol = attrs['symbol']
end
def self.all
client.get('v1/coins').map{|data| new(data) }
end
private
def self.client
@client ||= Coinma... | true |
5226b480466448e5ee113f8285dd3cde1c0fa21f | Ruby | darmou/pig_latin | /pig_latin.rb | UTF-8 | 1,519 | 3.625 | 4 | [] | no_license | class PigLatin
@@found_dict = {} #for memoization
#Translate a text string into pig latin from English
def translate text
split_arr = text.split(" ")
split_arr_trans = split_arr.map { |word|
(@@found_dict.key? word) ? @@found_dict[word] : (@@found_dict[word]=process_word(word); @@found_dict[w... | true |
aa65b8a4fddda137f52cac58ffb80d86b0e0cb68 | Ruby | ffsommers/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 2,411 | 4.09375 | 4 | [] | no_license | # RELEASE 0
# write method for creating a spy name
#
# 1. swap thefirst and last name
# 2.change all vowels to next vowel aieou
# 3. increment all consonants by one letter
def alias_creator (str)
# downcase all characters incase the name had initial caps.
str = str.downcase
# create vowel string for cross che... | true |
5e618df9699d9393acbd268bc191e14385897fd2 | Ruby | andyvesel/Codility-ruby-solution | /app.rb | UTF-8 | 191 | 3.28125 | 3 | [
"MIT"
] | permissive | a = [-1, 3, -4, 5, 1, -6, 2, 1]
left_sum = 0
right_sum = a.inject(:+)
a.each_with_index do |el, i|
left_sum += a[i - 1] if i > 0
right_sum -= el
puts el if left_sum == right_sum
end
| true |
a4b35c48ec6d16b31e49912ffb03a612309604b0 | Ruby | anclist/04---Collections-and-Iteration-Roll-of-the-Die | /lowest_and_highest.rb | UTF-8 | 371 | 4.1875 | 4 | [] | no_license | #Rolls the dice ten times and display each result
def roll_the_dice()
1 + Random.rand(6)
end
dice_array = []
5.times do
dice_array << "The result of your roll is #{roll_the_dice()}"
end
dice_array.sort!
dice_array.each do|result|
puts "#{result}"
end
puts "The lowest number is #{dice_array.first[-1]}."
pu... | true |
7c840340b04851840ad856b914b9c70898584478 | Ruby | joel/hoster | /spec/app/lib/redis_proxy_spec.rb | UTF-8 | 3,425 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
describe RedisProxy do
let(:instance) { described_class.new }
describe '#list' do
it 'should give the entirely list' do
expect(instance.list).to eql(['Alexandra', 'Joel', 'Krzysztof', 'Lukasz', 'Steve'])
end
end
describe '#add' do
it 'blacklist person added' do
e... | true |
28482ecbdad7f9112f7d501aae5ecad53fb14f68 | Ruby | itzedu/ruby_practice | /Ruby_monk/problem7.rb | UTF-8 | 214 | 3.8125 | 4 | [] | no_license | # Given a sentence, return true if the sentence is a palindrome.
def palindrome?(sentence)
string = sentence.downcase.delete(" ")
if string == string.reverse
return true
else
return false
end
end
| true |
c9255f20b652cc3213d5e911ffbe2cd23ee3754f | Ruby | mhjort/IndianPokerTournament | /src/main/ruby/console.rb | UTF-8 | 895 | 3.34375 | 3 | [] | no_license | class Console
def initialize(output=$stdout, input=$stdin)
@output = output
@input = input
end
def print(message)
@output.print message
end
def read
@input.readline
end
def prompt_for_string(question, default_value=nil)
prompt(question, default_value) { |value| value.strip != "" }
... | true |
07d650e05ae088c9ab0131da69b890977d0894fc | Ruby | chrisdetmering/knight_path_finder | /knight.rb | UTF-8 | 2,120 | 3.1875 | 3 | [] | no_license | require_relative "tree"
require 'byebug'
class KnightPathFinder
attr_reader :start_pos
MOVES = [
[-1, -1],
[-1, 0],
[-1, 1],
[ 0, -1],
[ 0, 1],
[ 1, -1],
[ 1, 0],
[ 1, 1]
]
def initialize(start_pos)
@start_pos = start_pos
@considered_positions = [start_... | true |
d33fb82c6346c7d9d8d37684b5d495b78f2987f2 | Ruby | mforoni/ruby-launch-plan | /quickstart/examples/mutating-methods/concat.rb | UTF-8 | 461 | 3.328125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: false
def change_str(str)
puts 'begin change_str(str)'
puts ' str = ' + str + ', object_id = ' + str.object_id.to_s
str.concat('bar')
puts ' str.concat(\'bar\')'
puts ' str = ' + str + ', object_id = ' + str.object_id.to_s
puts 'end change_str(str)'
end
s = 'foo'
puts 's = ' + ... | true |
acf5d8609e5959069b68cf694dbc73bebafcc5b7 | Ruby | oshoma/graticule | /lib/graticule/distance/vincenty.rb | UTF-8 | 3,103 | 2.9375 | 3 | [
"BSD-2-Clause"
] | permissive | module Graticule
module Distance
#
# The Vincenty Formula uses an ellipsoidal model of the earth, which is very accurate.
#
# Thanks to Chris Veness (http://www.movable-type.co.uk/scripts/LatLongVincenty.html)
# for distance formulas.
#
class Vincenty < DistanceFormula
# Calculate ... | true |
5efd2e7fb7b613ea2074e29863c73c69250f95da | Ruby | scottmillion/launch_school_exercises | /rb_small_problems/easy_4/ex2.rb | UTF-8 | 627 | 3.765625 | 4 | [] | no_license | def numeric_order(number)
ending = number.to_s.split('')
last_two = ending[-2] + ending[-1] if ending.length > 1
return number.to_s + 'th' if last_two.to_i > 10 && last_two.to_i < 20
case ending.last
when '1'
number.to_s + 'st'
when '2'
number.to_s + 'nd'
when '3'
number.to_s + ... | true |
6b0376320bc5dd702d8acb5900b054111aa2a28a | Ruby | SawaiTakahiro/tools | /library.rb | UTF-8 | 2,595 | 3.546875 | 4 | [] | no_license | #! ruby -Ku
=begin
2016/03/31
よくつかうやつまとめ
=end
#共通の部分
#使うライブラリ
require "fileutils"
require "CSV"
require "json"
##########################################################################################
#CSVファイルを読み込んで、配列で返すやつ
#文字コードも変換しちゃう
def read_csv(file_path_csv)
data_csv = CSV.read(file_path_csv, encoding: "S... | true |
870c22d25907efb30e6428c3f4579ca0ca9e4595 | Ruby | miushock/ascii_viewer | /tools/config_loader.rb | UTF-8 | 943 | 2.640625 | 3 | [] | no_license | require 'json'
module ConfigLoader
@binding
@hash
class BindingFactory
def initialize (hash)
hash.each do |key, value|
instance_variable_set("@#{key}", value)
end
instance_variable_set("@env", hash)
end
def get_binding
return binding()
end
end
def self.load_... | true |
17829aa9eb5a3d5358c869ec0b4c71bb146db43e | Ruby | rvachon1/rb101 | /exercises/medium2/bubble.rb | UTF-8 | 568 | 3.734375 | 4 | [] | no_license | def bubble_sort!(array)
swap_count = ''
counter = 0
while swap_count != 0
swap_count = 0
counter = 0
while counter < (array.length - 1)
if array[counter] > array[counter + 1]
array[counter], array[counter + 1] = array[counter + 1], array[counter]
swap_count += 1
end
... | true |
bb158122cb06cc9c3f874856d1482c58d99d6a86 | Ruby | kiytang/Learn-to-Program | /Factorial_number.rb | UTF-8 | 186 | 3.65625 | 4 | [] | no_license | def factorial num
if num < 0
"You can'take the factorial of a negative number!"
end
if num <= 1
1
else
num * factorial(num-1)
end
end
puts factorial(10)
puts factorial(-10) | true |
29c31d34e79d4f3cfed97c12125f4e72ba58270f | Ruby | alanwillms/defender | /lib/defender/screen/menu_item.rb | UTF-8 | 1,323 | 2.828125 | 3 | [] | no_license | class MenuItem
HOVER_OFFSET = 3
attr_reader :defense_type, :main_image
attr_accessor :selected, :active_image
def initialize(defense_type, x, y, z, callback)
@defense_type = defense_type
@main_image = SpriteHelper.image(defense_type)
@hover_image = @main_image
@active_image = @main_image
@... | true |
a4c76950481793a374abf67b86040ea55f7ed6ab | Ruby | NancyKo/learn_ruby_the_hard_way | /ex15.rb | UTF-8 | 1,428 | 4.875 | 5 | [] | no_license | # IN CL you must type the filename as an ARGV otherwise this wouldn't work
# This takes the argument you typed in CL and takes the first argument sets it
# to the variable filename
filename = ARGV.first
# command open takes an argument which we pass filename and sets that
# to the variable txt
txt = open(filename)
#... | true |
f2d02d23ba73a8f25d3b891121649d74c1d377de | Ruby | DFE-Digital/get-help-with-tech-prototype | /scripts/update-schools.rb | UTF-8 | 3,412 | 2.953125 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | #!/usr/bin/env ruby
# Run './scripts/update-schools.rb'
require 'csv'
require 'JSON'
class UpdateSchoolsList
def run
responsible_body = 'ACADEMIES ENTERPRISE TRUST'
is_trust = true
trust_column_header = 'Column1'
rows = CSV.read(csv_file_location, { headers: true })
grouped_by_responsible_body =... | true |
e9c5bfcf69657f78f6a187079998d81335a121cc | Ruby | LasseSviland/phase_0_unit_3 | /week_7/7_gps3.1/our_solution.rb | UTF-8 | 2,227 | 4.40625 | 4 | [] | no_license | # U3.W7: Build an Electronic Grocery List!
# Your full names:
# 1. Lasse Sviland
# 2.Anup Pradhan
# User Stories (As many as you want. Delete the statements you don't need)
# As a user, I want to add a item to the Grocery list.
# As a user, I want to delete an item from the Grocery list
# As a user, I want to displ... | true |
c506baf9c9d599a08f6935f497471f585388c05a | Ruby | hackternoon/hackternoon | /app/models/photo_url.rb | UTF-8 | 1,147 | 2.53125 | 3 | [] | no_license | class PhotoUrl < ActiveRecord::Base
# Callback before I save so I truncate large strings.
before_save :trunc_em
before_save :white_list
# Associations come after callbacks.
# http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
belongs_to :user
attr_accessible :the_url
# I want each photo_... | true |
981af3a982b47d8158fffb92033cf53d68328cd8 | Ruby | leandrofiorenzo/cifrador-ruby-untref | /cifrador_app.rb | UTF-8 | 356 | 2.734375 | 3 | [] | no_license | Dir[File.join(__dir__, 'model', '*.rb')].each { |file| require file }
desplazamiento = ARGV[0]
texto_a_cifrar = ARGV[1]
cifrador = Cifrador.new(desplazamiento, texto_a_cifrar)
texto_cifrado = cifrador.cifrar
puts "f(#{desplazamiento},#{texto_a_cifrar}) = #{texto_cifrado}"
# walking skeleton:
# 1. leer input
# 2. del... | true |
ecfa3b3a5a7effe439149772fcd41c24e55c17b0 | Ruby | katiekeel/black_thursday | /lib/merchant_repository.rb | UTF-8 | 1,223 | 3.078125 | 3 | [] | no_license | require_relative 'merchant'
require_relative 'csv_opener'
require_relative 'sales_items'
class MerchantRepository
include SalesItems
attr_reader :collection, :sales_engine
def initialize(csv_file, sales_engine)
@sales_engine = sales_engine
@collection = []
populate_merchant_repo(csv_file, "merchan... | true |
41dba0d37b25f94cb2aec48e941d039a803be39a | Ruby | aniasobo/romannumerals | /spec/roman_numerals_spec.rb | UTF-8 | 860 | 3.171875 | 3 | [] | no_license | require 'roman_numerals'
describe RomanNumerals do
it 'converts 1 to I' do
expect(RomanNumerals.convert(1)).to eq ("I")
end
it 'converts 5 to V' do
expect(RomanNumerals.convert(5)).to eq ("V")
end
it 'converts 10 to X' do
expect(RomanNumerals.convert(10)).to eq ("X")
end
it 'converts 35 t... | true |
ea238e622b30b80c7da557c91e4175ca4dcdd609 | Ruby | Get-Pet/GetPet | /features/step_definitions/Cliente.rb | UTF-8 | 1,421 | 2.765625 | 3 | [] | no_license | # novo cliente
Given('Eu estou na pagina de clientes') do
visit 'clientes/'
end
Given('Eu clico no botao new Cliente') do
click_link 'New Cliente'
end
When('Eu preencho o campo nome com {string} o campo endereco com {string} e o campo telefone com {string}') do |nome, endereco, telefone|
fill_in 'cliente[nome]... | true |
d4f5b3cafbff1b26ca0b357b2fd9bae1e8302547 | Ruby | BasdeBruyn/Ruby_Guessing_Game | /app/services/guess_service.rb | UTF-8 | 2,152 | 3.3125 | 3 | [] | no_license | class GuessService
HIGHER = 'higher'
LOWER = 'lower'
def self.retrieve_guesses
Guess.order(created_at: :desc)
end
def self.create_guess_page(guess, name)
current_guess = Guess.create_guess(name: name, guess: guess)
winning_streak = 0
initial = initial_game? guess
if initial
init... | true |
1949b58a0a64619b4398a3e8b37a464d4257751f | Ruby | anton164/swen30006-Project3 | /WeatherPredictions/app/predictors/predictor_factory.rb | UTF-8 | 355 | 2.625 | 3 | [] | no_license | class PredictorFactory
attr_accessor :weather_feature
def self.create feature
case feature
when :rainfall
return RainfallPredictor.new
when :temperature
return TemperaturePredictor.new
when :wind_direction
return WindDirectionPredictor.new
when :wind_speed
return WindSpe... | true |
3fe82a8ca0c97be4d9ea12e66907004cbfdbf9c5 | Ruby | mau5atron/ruby-advanced | /super_special.rb | UTF-8 | 312 | 3.875 | 4 | [] | no_license | pets = ["Scooby", "Soco", "Summer", "Pixie", "Wilson", "Mason","Baron", "Brinkley", "Bella"]
def method(pets)
if pets.include? "S"
puts "My name starts with an S for super!"
else
puts "I'm still pretty special too!"
end
end
method(pets[0])
method(pets[1])
method(pets[2])
method(pets[3])
method(pets[4]) | true |
a8db2cea9970e02771c0a62f740eccc89df02c78 | Ruby | CocoJu/rbstudy | /src/screencasts/16_everything_is_object.rb | UTF-8 | 117 | 2.890625 | 3 | [] | no_license | puts "ruby".capitalize
puts 10.next
names = { :family_name => "Bond", :first_name => "James" }
puts names.length | true |
86a3e8c7bd4d81b24e043d5d2ca2f0f8a00b1b40 | Ruby | mariovisic/declarative_cucumber | /db/seeds.rb | UTF-8 | 262 | 2.65625 | 3 | [] | no_license | if User.count == 0
email = 'user@example.com'
password = 'password'
User.create!(:email => email, :password => password)
puts "==============\n"
puts "User created with the following details:"
puts "Email: #{email}"
puts "Password: #{password}"
end
| true |
88cc9df6577ac4baa291026f9dbdd53102c8a6e3 | Ruby | jefflunt/mini-counter | /lib/counter.rb | UTF-8 | 135 | 3.015625 | 3 | [
"MIT"
] | permissive | class Counter
def initialize
@counts = {}
end
def count(e)
@counts[e.name] ||= 0
@counts[e.name] += e.num
end
end
| true |
40a376a544ebf93fd47cf8de7d48e4ec0f9e20af | Ruby | v-yarotsky/humble_rubyist | /lib/humble_rubyist/decorators/etag.rb | UTF-8 | 566 | 2.703125 | 3 | [] | no_license | require "delegate"
module HumbleRubyist
module Decorators
#
# Wraps a Sequel::Model or an enumerable of Sequel::Models
# adds #etag
#
class Etag < SimpleDelegator
class InappropriateEtagSubjectError < StandardError; end
def etag
if __getobj__.kind_of?(Enumerable)
_... | true |
c56e986a8908b4024d22d14110109b86a6009b57 | Ruby | chitreshgoyal1/assignments | /hackerrankrspec-master/save_princess/lib/saverbot.rb | UTF-8 | 837 | 3.65625 | 4 | [] | no_license | # Saverbot class to get moves
class Saverbot
attr_reader :num, :grid
def initialize(num, grid)
@num = num
@grid = grid
end
def display_path_to_princess
peach_xy = []
saverbot_xy = []
grid.each_with_index do |line, index|
if line.include?('p')
peach_xy.push(line.chars.i... | true |
a8d84325fc6edc48d093c8f03d6ff8692fdd3318 | Ruby | marscms/mars-diacria | /lib/mars/diacria/base_repository.rb | UTF-8 | 1,374 | 2.65625 | 3 | [
"MIT"
] | permissive | module Mars
module Diacria
module BaseRepository
def adapter
@adapter
end
def adapter=(adapter)
@adapter = adapter
end
def entity(entity_class)
@entity_class = entity_class
end
def all
ensure_adapter_method_exists(:all)
with_ent... | true |
927fe73d55ac0d2f52fab088288a867218c6c482 | Ruby | caward12/acme_sensors | /lib/sensor_repo.rb | UTF-8 | 1,392 | 3.359375 | 3 | [] | no_license | require './lib/sensor'
class SensorRepo
attr_reader :all
def initialize(file)
@all = []
create_sensors(file)
end
def create_sensors(file)
file.map do |row|
all << Sensor.new(row)
end
end
def hygrometers
all.select do |sensor|
sensor.type == "hygrometer"
end
end
... | true |
69c0b733ef76db9644313e7c60891308b085b608 | Ruby | ta1kt0me/AOJ | /0032/0032.rb | UTF-8 | 676 | 3.109375 | 3 | [] | no_license | # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0032
require 'minitest/autorun'
def calc
rectangle = 0
rhombus = 0
while gets
x, y, z = $_.split(',').map(&:to_i)
rhombus += 1 if x == y
rectangle += 1 if x ** 2 + y ** 2 == z ** 2
end
puts rectangle
puts rhombus
end
calc
class Test <... | true |
b7aa8ef25a404f1082a8735f956a90f761894562 | Ruby | c0ze/Chipmunk-Examples | /02_slides.rb | UTF-8 | 3,641 | 3.015625 | 3 | [] | no_license | # I wrote this to help understand the basics of Chipmunk 2D physics
# If you find anything wrong or disagree with something, please let me know.
# Me, Phil Cooper-King
# Email: <phil@cooperking.net>
# Website: http://www.mootgames.com
# Gosu:
# Homepage: http://libgosu.org/
# Google Code: http://code.... | true |
beacbeb9cc15c2d13d2ec9859fbb41378a967095 | Ruby | Elenadinca25/ruby-enumerables-array-count-lab-lon01-seng-ft-042020 | /lib/array_count.rb | UTF-8 | 291 | 2.9375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def count_strings(array)
array.grep(String).count
end
# Return the total number of strings in the provided array using the count enumerable
def count_empty_strings(array)
array.count("")
end
# Return the total number of EMPTY strings in the provided array using the count enumerable
| true |
5e327924e10a688b7c721f278c4cd3c9da7a366c | Ruby | Muriel-Salvan/PBS | /lib/pbs/Model/Shortcut.rb | UTF-8 | 3,390 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | #--
# Copyright (c) 2009 - 2012 Muriel Salvan (muriel@x-aeon.com)
# Licensed under the terms specified in LICENSE file. No warranty is provided.
#++
module PBS
# Shortcut
class Shortcut
# The type
# Object
attr_reader :Type
# The set of tags this Shortcut belongs to
# map< Tag, nil >
... | true |
b3b3e7026e3bc6ae0952f924ac46bb43fb30ec75 | Ruby | trebek1/poker_project | /spec/views/index_spec.rb | UTF-8 | 316 | 2.671875 | 3 | [] | no_license | require "rails_helper"
RSpec.describe 'views/simulations/index.html.erb' do
it "expects wins in increment given a win (player 1)" do
@best_hand_value_1 = [10]
@best_hand_value_2 = [5]
@wins_1 = 0
if @best_hand_value_1[0] > @best_hand_value_2[0]
@wins_1+=1
end
expect(@wins_1).to eql 1
end
end | true |
6c0057a7334300cbdd4d03d58e9599b3ea78723e | Ruby | 9livesarmory/numberReverser | /numberReverser.rb | UTF-8 | 379 | 3.84375 | 4 | [] | no_license | #numberReverser - Convert number to reversed array of digits
def digitize(n)
converted=[]
stringy=n.to_s #convert number to string
new=stringy.split(//) #split numberstring into array
new.each do |stringnum|
convert = stringnum.to_i
converted.push(convert)
end
reversed = converted.rev... | true |
c88b77eeb63c1045c5a8476e71abe5bd74d8d03b | Ruby | yasslab/railsguides.jp-contributors | /config/initializers/core_extensions.rb | UTF-8 | 280 | 2.78125 | 3 | [
"MIT"
] | permissive | UNF_NORMALIZER = UNF::Normalizer.new
class String
def parameterize_with_special_cases
gsub('ß', 'ss').gsub('ø', 'o').parameterize_without_special_cases
end
alias_method_chain :parameterize, :special_cases
def nfc
UNF_NORMALIZER.normalize(self, :nfc)
end
end
| true |
d1aded8f779948998a2a5b84619fbd20d1e3c821 | Ruby | mdo5004/sinatra-mvc-lab-v-000 | /models/piglatinizer.rb | UTF-8 | 556 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require'pry'
class PigLatinizer
def to_pig_latin(phrase)
phrase.split.collect do |word|
if word.downcase[0].match(/[aeiou]/)
pig_word = word + "way"
else
vowel_delimited = word.split(/([aeiou]{1})/)
pig_word ... | true |
9daa14172cc9b1f80a1d9f03ee476265ac5ff28a | Ruby | MatheusRich/kintama | /test/usage/01_basic_usage_test.rb | UTF-8 | 3,147 | 2.625 | 3 | [] | no_license | require 'test_helper'
class BasicUsageTest < KintamaIntegrationTest
def test_should_pass_when_all_tests_pass
context "Given a test that passes" do
should "pass this test" do
assert true
end
should "pass this test too" do
assert true
end
end.
should_output(%{
... | true |
98f5e910a297240a1e9574d9d4752f4b2e989f66 | Ruby | mbadilla86/Desafio_herencia_y_UML | /one_time_appointment.rb | UTF-8 | 463 | 3.234375 | 3 | [] | no_license | require_relative 'appointment'
class OneTimeAppointment < Appointment
attr_reader :day, :month, :year
def initialize(location, purpose, hour, min, day, month, year)
@day = day
@month = month
@year = year
super(location, purpose, hour, min)
end
def occurs_on?(day, month, year)
@day == day an... | true |
7615b6d99c10c2d7bfa3915a4539a975134f86e4 | Ruby | pixelblend/weeknoteabot | /spec/lib/weeknote_zipper_spec.rb | UTF-8 | 1,633 | 2.578125 | 3 | [] | no_license | require_relative '../spec_helper'
require 'weeknote_zipper'
describe WeeknoteZipper do
it 'compresses a set of files' do
files = [
{:name => 'test_file_1', :file => Tempfile.new('test')},
{:name => 'test_file_2', :file => Tempfile.new('test2')}
]
zipper = WeeknoteZipper.new(files)
zip_f... | true |
e3190f561cc7e1890dc2b9614494307158cd8092 | Ruby | dannyradden/http_yeah | /lib/game.rb | UTF-8 | 769 | 3.546875 | 4 | [] | no_license | class Game
attr_reader :game_number,
:guess,
:high_low,
:guess_count
def initialize
@game_number = rand(101)
@guess_count = 0
end
def guess_checker(guess, game_number = @game_number)
if guess > game_number
@high_low = "too high."
elsif guess < g... | true |
d3ce8070397931f96e2a05b3ae6a485681237d41 | Ruby | mushishi78/fn_space | /spec/utils_spec.rb | UTF-8 | 916 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'fn_space/utils'
describe FnSpace::Utils do
describe 'mod' do
it 'creates a object with assign function' do
res = FnSpace::Utils.mod.().assign(:q){50}.assign(:w){93}
expect(res.q).to eql(50)
expect(res.w).to eql(93)
end
end
describe 'struct' do
it 'creates a struct from a h... | true |
5b9d17a295b20026f472955dba88e2b234b1f29d | Ruby | DoggettCK/exercism | /ruby/triangle/triangle.rb | UTF-8 | 472 | 3.453125 | 3 | [] | no_license | # Triangle
class Triangle
def initialize(a, b, c)
@a = a
@b = b
@c = c
fail TriangleError if [a, b, c].any? { |x| x <= 0 }
fail TriangleError if (@a + @b) <= @c
fail TriangleError if (@b + @c) <= @a
fail TriangleError if (@a + @c) <= @b
end
def kind
return :equilateral if @a == @... | true |
83b50f83a88d381076a4c3d8f0ff9b4cf857a9ea | Ruby | omarkhan2270/takeaway-challenge-1 | /lib/order.rb | UTF-8 | 195 | 2.703125 | 3 | [] | no_license | relative_require 'menu'
class Order
attr_reader :order_made
def initialize
@menu = Menu.new
@order_made = []
end
def order(user_order)
@order_made = user_order
end
end | true |
d328914a1053c1b6160a5c1f6346cd7862a11b92 | Ruby | ScStew/github-api | /git_octo.rb | UTF-8 | 2,306 | 2.75 | 3 | [] | no_license | require 'octokit'
require 'json'
require 'time'
class Git_api_class
def initialize(username,password)
@username = username
@password = password
end
def get_api_data(date)
client = Octokit::Client.new(:login => @username, :password => @password)
p client.user
p ... | true |
6d63c3027f4bae0583b4e7cd9ac5a4ec5d2e9ccb | Ruby | JoriPeterson/jungle_beats | /test/node_test.rb | UTF-8 | 331 | 2.765625 | 3 | [] | no_license | require 'minitest/autorun'
require 'pry'
require './lib/node'
class NodeTest < Minitest::Test
def setup
@node = Node.new("plop")
end
def test_it_exists
assert_instance_of Node, @node
end
def test_it_has_attributes
assert "plop", @node.data
end
def test_next_node_returns_nil
assert_nil @node.next_nod... | true |
28febff839bff642d37bae5d8e3d61b533ba5976 | Ruby | randrews/groundwork | /commands/install.rb | UTF-8 | 991 | 2.734375 | 3 | [] | no_license | module Groundwork
module Commands
def self.install args
cmd_opts = Trollop::options(args) do
banner <<-STR
Usage:
groundwork install [options] filename.recipe
Installs a recipe into ~/.groundwork
Options are:
STR
opt :force, "Overwrite recipe if it already exists", :default=>false
... | true |
3052158a46273c0393a119df6d9c89b10d1af25c | Ruby | r3h4n/Intro_to_Programming_LS | /code_academy/crud.rb | UTF-8 | 962 | 3.8125 | 4 | [] | no_license | # CRUD, Create, Read, Update and Deleting a HASH
#
movies = {
movie1: "4",
movie2: "3",
movie3: "1"
}
puts "Inputs:"
choice = gets.chomp
case choice
when "add"
puts "Ok. Enter movie title:"
title = gets.chomp
puts "Rating:"
rating = gets.chomp
if movies[title.to_sym].nil?
movies[title.to_sy... | true |
b19b27f61421cd06416869f0b1a65391d740d10d | Ruby | jvargas98/tango-exercises | /ruby/pickaxe/song.rb | UTF-8 | 192 | 3.28125 | 3 | [] | no_license | class Song
def initialize name
@name = name
end
def play
puts "playing... #{@name}"
end
end
song1 = Song.new('Song 1')
song2 = Song.new('Song 2')
song1.play
song2.play
| true |
8b909213c2577b3b2b0952507952b303c111fd8c | Ruby | sigus/solutions | /cf/1005A.rb | UTF-8 | 131 | 3.078125 | 3 | [] | no_license | gets
t = []
t << gets.split.map{|x| x.to_i}.inject(0) do |s, x|
t << s if x == 1 && s > 0
x
end
puts(t.size, t.join(' '))
| true |
341ea63bc2e2994246f91555c3029539676a753c | Ruby | kvanderd/dren | /app/models/card.rb | UTF-8 | 149 | 2.546875 | 3 | [] | no_license | class Card < ActiveRecord::Base
belongs_to :deck
has_many :guesses
def correct?(guess)
self.answer.downcase == guess.downcase
end
end
| true |
798eabfc94c1ee7ae4796556c4abcb171c09ffc0 | Ruby | dalspok/exercises | /small_problems/easy_7/3.rb | UTF-8 | 482 | 3.765625 | 4 | [] | no_license | =begin
(1)
split
map - return upcased
join
(2)
each_word
traverse + upcase << new str
=end
# def word_cap(str)
# str.split.map {|word| word.capitalize}.join(" ")
# end
def word_cap(str)
str.split.map {|word| word[0].upcase + word[1..-1].downcase}.join(" ")
end
p word_cap('four score and seven... | true |
ed5e8119698aa6f512ad6273ac8d8c9102a02a5b | Ruby | viniciuspc/ruby-freecodecamp | /calculator.rb | UTF-8 | 120 | 3.703125 | 4 | [] | no_license | puts "Enter a Number: "
num1 = gets.chomp.to_f
puts "Enter a another number"
num2 = gets.chomp.to_f
puts (num1 + num2)
| true |
ecc72fe6c4c19e2b421cbf30bfa1eaecb1e975ab | Ruby | JamieFlournoy/avanticonveniences | /test/test_hash_extensions.rb | UTF-8 | 1,302 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require File.dirname(__FILE__) + '/../lib/hash_extensions'
class TestHashExtensions < Test::Unit::TestCase
def test_map_keys
expected = {10 => :a, 20 => :b}
actual = {1 => :a, 2 => :b}.map_keys{|k| k * 10}
assert_equal expected, actual
end
def test_map_array_keys
expect... | true |
f56c44c2221d497e5e42706d561d339d0e9bf151 | Ruby | Pauloparakleto/ruby_gem | /lib/algorithymsolver.rb | UTF-8 | 2,408 | 3.53125 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative "algorithymsolver/version"
module Algorithymsolver
class Error < StandardError; end
# Linear search
# Performs a search starting at the first index, evaluate to second and so on
# until find the number returning it or -1 as not found.
class LinearSearch
de... | true |
e2bd9561fb5d883de253de65da9617af305e3960 | Ruby | karthik25/todo-list | /lib/core/tasks/mark_task.rb | UTF-8 | 499 | 2.84375 | 3 | [] | no_license | require 'Date'
require './core/tasks/task_base.rb'
require './core/listmanager/text_list_manager.rb'
class MarkTask < TaskBase
attr_reader :manager
def initialize(list_manager)
@manager = list_manager
end
def has_valid_params
@props != nil && @props.length == 1
end
def execute
id = @props[0]... | true |
2b4cb57155a14981cce0054373513d20b9739b97 | Ruby | phi2dao/Kaiseki | /lib/mod_object.rb | UTF-8 | 131 | 3.125 | 3 | [] | no_license | class Object
def must_be item
raise TypeError, "can't convert #{self.class} into #{item}" unless self.is_a? item
true
end
end | true |
fd5a71767fb52fbe812e144c4ef5b4771c2cf1af | Ruby | Dipress/crmifc_frequency | /app/models/user/billing_authenticator.rb | UTF-8 | 419 | 2.578125 | 3 | [] | no_license | class User < ActiveRecord::Base
class BillingAuthenticator
attr_reader :username, :password
def initialize(username, password)
@username = username
@password = Digest::MD5.hexdigest(password).upcase
end
def authenticate
return nil if user.nil?
user.pswd.eql?(password) ? user... | true |
12271d1f52c4b8a0aafe0f99a3d7e4ebcc042e9a | Ruby | siakaramalegos/assignment_rspec_ruby_tdd | /lib/stock.rb | UTF-8 | 783 | 3.9375 | 4 | [] | no_license | def stock(price_array)
raise "Oops, need an array" unless price_array.is_a? Array
raise "Oops, need more days" unless price_array.size >= 2
if price_array.size == 2
[0, 1]
else
best_buy_day = 0
best_sell_day = 1
max_return = 0
# Loop through buy days
price_array.each_with_index do |buy... | true |
17aa15fd575cece57906d4c71ceee1fcc18f6325 | Ruby | EricaThompson/classwork-aA | /w4/W4D3/Chess (Part One)/board.rb | UTF-8 | 1,912 | 3.46875 | 3 | [] | no_license | require_relative "null_piece"
require_relative "rook"
require_relative "queen"
require_relative "bishop"
require_relative "king"
require_relative "knight"
#! hey
# TODO
class Board
attr_reader :board
def self.valid_pos?(pos) #[1,0]
return false if !pos[0].between?(0,7) || !pos[1].b... | true |
ffa73493e75744590aa064ea117201c7a08e769d | Ruby | andrewmcdonough/deliveroolette | /lib/menu.rb | UTF-8 | 664 | 2.6875 | 3 | [] | no_license | class Menu
attr_accessor :url
def initialize(url:)
@url = url
end
def menu_groups
@menu_groups ||=
doc.css(".results-group").map do |details|
MenuGroup.new(
name: details.css("h3").text.strip,
menu_items:
details.css(".menu-item").map do
Menu... | true |
df5b84935348d8427097f7d29999c3c028839501 | Ruby | nkmty/sinatra_kadai | /app.rb | UTF-8 | 2,072 | 2.75 | 3 | [] | no_license | require 'sinatra'
require 'json'
class MemoApp < Sinatra::Base
enable :method_override
json_file_path = './list.json'
# root ルートはメモ一覧へリダイレクトします
get '/' do
redirect to('/memos')
end
# index メモ一覧
get '/memos' do
File.open(json_file_path, 'r') do |file|
@memo_list = JSON.load(file)
end
... | true |
adedf3348bea66f7acf7bcbfef2552f4440e5573 | Ruby | averysmith65/launch_school | /subscription_course/rb101_rb109_small_problems/easy_8/sum_of_sums.rb | UTF-8 | 515 | 3.9375 | 4 | [] | no_license | def sum_of_sums(arr)
count = 0
total = 0
arr1 = []
until count == arr.size
arr1 << arr[0..count]
count += 1
end
arr1.flatten.each do |num|
total += num
end
total
end
p sum_of_sums([3, 5, 2])
p sum_of_sums([1, 5, 7, 3])
p sum_of_sums([4])
p sum_of_sums([1, 2, 3, 4, 5])
# sum_of_sums([3, ... | true |
3c40b4309228218057f9c1ac872a73e0386e04f1 | Ruby | mlainezb/G7-GuiaRuby | /Ejercicio6.rb | UTF-8 | 206 | 3.5 | 4 | [] | no_license | #Ejercicio 6: Manipulación de múltiples arrays
a = [1,2,3,0,1,2,2,1,2,1,2,0,3]
b = [:azul, :verde, :amarillo]
#Ejercicio 1
a.each_with_index do |i|
puts "#{i} :#{b.reverse[i - 1]}, #{c[i - 1]}"
end
| true |
190c342984cbe7ac34ef9ba5d7b0b4709d637dc2 | Ruby | spudfkc/FixTheTreeTDD | /lib/tree.rb | UTF-8 | 2,628 | 4.1875 | 4 | [] | no_license | class NoApplesError < StandardError; end
class DeadTreeError < StandardError; end
class Tree
attr_reader :height, :age, :apples
attr_accessor :alive
def initialize(height: 0, age: 0, apples: [], alive: true, rand_seed: nil)
@height = height
@age = age
@apples = apples
@alive = alive
@prng =... | true |
ccd4f2a3df1e2a3ab5e9fdea38a6374694cdca18 | Ruby | kohrVid/supermarket | /spec/supermarket_spec.rb | UTF-8 | 5,032 | 2.71875 | 3 | [] | no_license | require_relative '../supermarket.rb'
RSpec.describe Supermarket, type: :model do
let(:pricing_rule) { FactoryBot.create(:pricing_rule, :line_items) }
let(:item_a) { FactoryBot.create(:item, :a) }
let(:item_b) { FactoryBot.create(:item, :b) }
let(:supermarket) { Supermarket.new }
context "#init" do
it "s... | true |
f8b0e4c605fe6f19a8757e302b30f2afce85c97f | Ruby | imurchie/projecteuler | /problem50.rb | UTF-8 | 707 | 4.03125 | 4 | [] | no_license | require "mathn"
# The prime 41, can be written as the sum of six consecutive primes:
# 41 = 2 + 3 + 5 + 7 + 11 + 13
#
# This is the longest sum of consecutive primes that adds to a prime below one-hundred.
#
# The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is equ... | true |
b97e2d0cd859cca8b8c6bb56dc69d1664893a563 | Ruby | NatClamp/London_LAL | /server.rb | UTF-8 | 952 | 2.90625 | 3 | [] | no_license | require 'sinatra'
require 'net/http'
require 'open-uri'
require 'nori'
require 'json'
# function to create api request URL
def endpointBuilder(location, keywords)
return "http://api.eventful.com/rest/events/search?app_key=" + ENV['APP_KEY'] + "&location=" + location + ",UK&keywords=" + keywords
end
# Home route - u... | true |
76cc94760586539c6e012e21ff228b5510bb972c | Ruby | S-Oktay-Bicici/RUBY-PROGRAMMING | /6-Metodlar-(Fonksiyonlar)/fonksiyonklar.rb | UTF-8 | 1,964 | 3.78125 | 4 | [] | no_license |
def çizgi_çiz
puts "-" * 20
end
çizgi_çiz
######################################################
def çizgi_çiz uzunluk
puts "-" * uzunluk
end
çizgi_çiz 10
######################################################
def çizgi_çiz(uzunluk)
puts "-" * uzunluk
end
çizgi_çiz(50)
##############################... | true |
4c5e72f7e0634673a1dfd42e929532db9ef9667b | Ruby | RobinBailey84/codeclan_work | /wk_3/day_1/shop_lab/specs/customer_spec.rb | UTF-8 | 747 | 3.140625 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../customer.rb')
require_relative('../shop.rb')
class CustomerTest < MiniTest::Test
def setup()
@customer = Customer.new("Mike", 20)
end
def test_customer_has_name()
assert_equal("Mike", @customer.name)
end
def test_customer_has_... | true |
a853076f14d4c025dc171310bc2f50a0d23c1910 | Ruby | ConnorChristie/twit-stocks | /spec/boost_spec.rb | UTF-8 | 5,698 | 2.625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Boost do
let(:boost) { Boost.new(14) }
let(:twitter) { TwitterEngine.new }
let(:stock) { :AAPL }
let(:search_term) { "Apple" }
let(:search_term_2) { "iphone" }
let(:search_term_3) { "ipad" }
let(:search_term_4) { "macbook" }
let(:stock_2) { :GOOG }
let(:search_term_5)... | true |
b2ade36295746eda972b0e0f83f5d3388ae0d040 | Ruby | Valentin-cruz/Ruby_On_Rails | /ruby/fundamentals/guess_number.rb | UTF-8 | 194 | 3.265625 | 3 | [] | no_license | def guess_number guess
number = 25
# your code here
unless guess == 25
puts "your number #{guess} is wrong"
else
puts "your number #{guess} is right"
end
end | true |
c6a0ab8d7e62742365a9dc69a7274d3e93f49d10 | Ruby | vladyio/volatile-wtf-rb | /lib/volatile_wtf/cache.rb | UTF-8 | 244 | 2.671875 | 3 | [
"MIT"
] | permissive | module Volatile
class Cache
attr_reader :storage
def initialize
@storage = {}
end
def save(key, value)
@storage[key] = value
end
def fetch(key, &block)
@storage.fetch(key, &block)
end
end
end | true |
e6e20b4a17233d5f7b5e849ac6ee1019b0fdbb94 | Ruby | sandagolcea/tryRuby | /codeacademy/hashes.rb | UTF-8 | 246 | 3.171875 | 3 | [] | no_license | pets = Hash.new
pets["Felix"] = "cat"
puts pets["Felix"]
dictionary = { "calle" => "street",
"mesa" => "table",
"puerta" => "door",
"ventana" => "window",
"casa" => "house"}
dictionary.each do |key, val|
puts "#{key} = #{val}"
end
| true |
c08acb71819792f7441bc2533126c7be106d4bb6 | Ruby | jarhoads/sevenlangs | /ruby/day2.rb | UTF-8 | 259 | 3.828125 | 4 | [] | no_license | a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
puts "a : #{a}"
puts " "
puts "each slice"
a.each_slice(4) {|i| puts "#{i[0]}, #{i[1]}, #{i[2]}, #{i[3]}"}
puts " "
puts "each"
(1..16).each {|i| puts "#{a[i-4]}, #{a[i-3]}, #{a[i-2]}, #{a[i-1]}" if i % 4 == 0} | true |
331298c856fbc7f17621dad425dcb10b6555159d | Ruby | Drowze/quake_parser | /tests/game_test.rb | UTF-8 | 1,798 | 3.046875 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../game.rb'
class GameTests < Minitest::Test
def setup
@new_game = Game.new
end
def test_types
assert @new_game.data.is_a?(Hash)
assert @new_game.data['total_kills'].is_a?(Integer)
assert @new_game.data['players'].is_a?(Array)
assert @new_game.dat... | true |
f2ad62c6c744f1fe9279b4ff2aeb22834e9ee7e6 | Ruby | taw/etwng | /esfxml/run_tests_abca | UTF-8 | 1,497 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
# This doesn't test esf->xml->esf (esf == esf)
# It tests esf->xml->esf->xml (xml == xml)
# which is a weaker condition
require "fileutils"
class SampleTest
def initialize(filename)
@filename = filename
end
def source
"samples/#{@filename}"
end
def xmldir
"tmp/" + @filename.... | true |
e07b55001c571905baea4663814622a46109075b | Ruby | gi1betoo/RubyTutorials | /model2.rb | UTF-8 | 323 | 3.15625 | 3 | [] | no_license | module Info
def get_owner
puts @ownerC
end
def set_owner(owner)
@ownerC=owner
end
end
class Car
include Info
end
class Bmw
include Info
end
def main
owner1=Car.new
owner1.set_owner("jena alrubaye")
owner1.get_owner
owner2=Car.new
owner2.set_owner("Laya alrubaye")
owner2.get_owne... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.