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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d02602a5729fd6e5f94558ac7ddc9ab6f3de3920 | Ruby | dcaba/hashcode-2016 | /lib/order.rb | UTF-8 | 2,212 | 2.75 | 3 | [] | no_license | LineStatus = Struct.new(:requested,:ongoing,:delivered)
class Order
attr_reader :id,:delivery_address,:closed_turn
def initialize(id, delivery_address)
@id = id
@delivery_address = delivery_address
@items = Hash.new {|hash, key| hash[key] = LineStatus.new(0,0,0)}
@closed_turn = nil
end
def status
return ... | true |
c07b21ea4fff08fce4f75c1a80f2bb947475c603 | Ruby | jnskender/Knights-Travails | /Graph.rb | UTF-8 | 1,667 | 3.65625 | 4 | [] | no_license | require './Node.rb'
require './Game_Board'
class Graph
attr_accessor :root
def initialize
@root = nil
@board = Game_Board.new
end
def piece_move(start, finish, piece)
@root = Node.new(start)
queue = [@root]
found_node = nil
until queue.empty? || !foun... | true |
0e4e1a2f9520887ab730cbc0c7c3f7adf3e5a50d | Ruby | CristianRenzoChuraPacsi/ruby | /hashes.rb | UTF-8 | 837 | 3.9375 | 4 | [] | no_license | # es una estructura que alamacena datos como un diccionario lo haria
# arreglos asociativos
# la diferencia es com acceder a los datos de un array
# en un hash se busca con su tipo
# hash para un tutor
# tienen dos partes una clave y un valor
# tutor = {"nombre" => "Renzo", "edad" => 23, 20 => "Veinte", [] => "Arre... | true |
f7da08b93145051a291d3812c1216753dcb30c9c | Ruby | tamu222i/ruby01 | /tech-book/7/m-49.rb | UTF-8 | 262 | 3.203125 | 3 | [] | no_license | # 以下の実行結果になるようにxに記述するコード
t = Time.local(2000,1,1)
x
# 実行結果
# 2000/01/01
# 1.printf(("%Y/%m/%d),t.year,t.mon,t.day)
# 2.printf(("%Y/%m/%d") % t)
# 3.print(t.format("%Y/%m/%d"))
# 4.print(t.strftime("%Y/%m/%d"))
| true |
7824b54b7721b8e514d800147672a061d38b2d18 | Ruby | t6d/guard-python-unittest | /lib/guard/python_unittest/test_runner.rb | UTF-8 | 734 | 2.75 | 3 | [
"MIT"
] | permissive | require 'pathname'
class Guard::PythonUnittest::TestRunner
attr_reader :directory
def initialize(directory)
@directory = directory
end
def run(path = nil)
if path
execute(convert_path_to_module_name(path))
else
execute
end
end
private
def command
"python"
end
... | true |
81afc06a02414f387e0742c16e1aefb90c3a8991 | Ruby | RanSolo/cal | /formattingII.rb | UTF-8 | 2,676 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env ruby
def conditionals(m,y)
if m < 1 || m > 12
raise ArgumentError, "that's not a month dummy"
else
# calendar_body(m,y)
print_header(m, y)
end
#
# def year( y)
# one_year = (1..12).to_a
# years = (1800..2250)
# print years
# # if y
# end
# endprint
def month_arg_to_s(... | true |
90bcf4e5a9d42eee4ca741e2d3e5fada9ecca1e3 | Ruby | alexRai98/c2-module2 | /week-1/day-4/find_class.rb | UTF-8 | 288 | 3.09375 | 3 | [] | no_license | class Celphone
def initialize(color, marca)
@color = color
@marca= marca
@broke = false
end
def marca
@marca
end
def color
@color
end
end
celphone = Celphone.new("back","Lg")
puts celphone.marca
puts celphone.colo | true |
6d3c106a250d6186c4d12ada35ef694d7206f704 | Ruby | gabrielclouud/Jogo-da-advinhacao | /teste5.rb | UTF-8 | 233 | 3.046875 | 3 | [] | no_license | treze = 13
cinco = 5
puts treze / cinco
puts treze % cinco
puts treze + cinco
puts treze - cinco
puts treze * cinco
numero = 5
numero += 1
numero -= 2
numero *= 2
numero /= 4
numero *= 13
numero %= 10
puts numero | true |
a6fb025971523e911dd608cb1df330675767bca1 | Ruby | alex-j-g/rb_101 | /lesson_3/medium_1/q02.rb | UTF-8 | 369 | 4.5625 | 5 | [] | no_license | #The result of the following statement will be an error:
puts "the value of 40 + 2 is " + (40 + 2)
#Why is this and what are two possible ways to fix this?
#answer: Intergers need to be converted to a string before it can be concatenated to another string.
puts "the value of 40 + 2 is " + (40 + 2).to_s
#or
puts "the... | true |
179c8deb1c3f2ff79f4d64389ea17cc1da49d188 | Ruby | Anikram/social_skills | /spec/test_spec.rb | UTF-8 | 1,002 | 2.8125 | 3 | [] | no_license | require 'rspec'
require 'test.rb'
describe 'logic of evaluate_result' do
before :each do
@test = Test.new(__dir__ + '/fixtures/questions.txt', __dir__ + '/fixtures/results.txt')
end
context 'when test just started' do
it 'returns 6th element of result array' do
expect(@test.evaluate_result).to incl... | true |
4349490fce611fa309b1dd84131e21b533df68e3 | Ruby | BastianErler/Blueliner_Tippspiel | /app/models/tip.rb | UTF-8 | 861 | 3.046875 | 3 | [] | no_license | class Tip < ApplicationRecord
belongs_to :user
belongs_to :game
validates :game_id, presence: true
validates :user_id, presence: true
def evaluate
if goals_nil
self.price = 1
elsif tip_correct
self.price = 0
elsif tendency_correct
diff = calculate_diff
self.price = [diff * ... | true |
a63ded78130a275f4523adc5e83b6b71e105d3d0 | Ruby | 7digital/Mint | /src/SevenDigital.Tools.DependencyManager.RakeTasks/test/integration.tests/dependency_conflict_tests.rb | UTF-8 | 1,636 | 2.640625 | 3 | [] | no_license | require "test/unit"
require File.dirname(__FILE__) + '/../../src/lib/chubby_rain'
class DependencyConflictTests < Test::Unit::TestCase
def test_that_a_conflict_is_returned
instance = ChubbyRain.new(EXE_PATH, WORKING_DIR)
conflict = instance.run(COMMAND_REPORT, ASS_NAME)
assert_equal(0, conflict.exit_status, ... | true |
dd6570eb23d15c6eb3792e7056c27a6ecdfecf73 | Ruby | yuping-xiao/practice-ruby | /the8th-chapterF.rb | UTF-8 | 604 | 4.03125 | 4 | [] | no_license | puts "計算を始めます"
puts "二つの値を入力してください"
a=gets.to_i
b=gets.to_i
puts "計算結果を出力します"
puts "a*b=#{a*b}"
puts "計算を終了します"
puts "続いての計算です"
puts "何回繰り返しますか?"
input = gets.to_i
i = 1
while i <= input do
puts "#{i}回目の計算"
puts "二つ目の値を入力してください"
a = gets.to_i
b = gets.to_i
puts "a=#{a}"
puts "b=#{b}"
puts "計算結果を出力します"
puts "... | true |
7408cbeb2b41c618466c292789b405bd2f820916 | Ruby | rubenpazch/ruby-algorithms | /books/large_number.rb | UTF-8 | 133 | 3 | 3 | [] | no_license | rice_on_square = 1
1024.times do |square|
puts "On square #{square + 1} are #{rice_on_square} grain(s)"
rice_on_square *= 2
end
| true |
b9110ed4a32729ffc9158ba63267202352244578 | Ruby | richgong/midi-warp | /_archive/shitty_tranpose_ruby/slow_and_shitty.rb | UTF-8 | 1,287 | 3.15625 | 3 | [
"MIT"
] | permissive | require 'unimidi'
NOTE_ON = 144
NOTE_OFF = 128
puts "Inputs:"
UniMIDI::Input.list
puts "Outputs:"
UniMIDI::Output.list
notes = [36, 40, 43, 48, 52, 55, 60, 64, 67] # C E G arpeggios
duration = 0.1
output = UniMIDI::Output.use(0)
puts "Writing to: #{output.pretty_name}"
input = UniMIDI::Input.use(1)
TRANSFORM_KE... | true |
7f87f12830b6e5f9c36b3628dd7c6510c36f7274 | Ruby | MattHeard/Five-Hundred | /app/commands/pass_bid.rb | UTF-8 | 307 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class PassBid
def initialize(game)
@game = game
end
def call
game.with_lock { game.events << new_event }
end
private
attr_reader :game
def new_event
BidPassed.new(player_seat: game_state.current_player_seat)
end
def game_state
CreateGameState.new(game).call
end
end
| true |
9f4fa7ae102e1d35605243c61d48157b0ea70e7c | Ruby | anthonynavarre/GildedRose | /lib/gilded_rose/item/event_specific_item.rb | UTF-8 | 402 | 2.890625 | 3 | [] | no_license | class EventSpecificItem < Item
def age
super
if expired?
@quality = 0
else
appreciate
end
end
private
def appreciate
unless @quality >= MAXIMUM_QUALITY
@quality = @quality + appreciation_amount
end
@quality
end
def appreciation_amount
case
when @sell... | true |
2e1248af39282c9f1613860b94628751e4ac90dc | Ruby | shawn42/ludum_dare_22 | /src/hunger_meter.rb | UTF-8 | 794 | 2.90625 | 3 | [] | no_license | class HungerMeterView < ActorView
#COLOR = [250,250,255,200]
def draw(target,x_off,y_off,z)
@screen ||= @stage.resource_manager.load_image 'clock_bg.png'
x = @actor.x
y = @actor.y
@screen.draw x, y, z
end
end
class HungerMeter < Actor
has_behavior :layered => {:layer => ZOrder::HudBackground}
... | true |
3ab38f05bb9673696b597fbf01e7f09628ffe143 | Ruby | sogapalag/contest | /yukicoder/3060.rb | UTF-8 | 403 | 3.03125 | 3 | [] | no_license | # coding: utf-8
s=gets.chomp
if s=="0"
puts 'Nothing'
exit
elsif s=='3.14159265'
puts 'pi'
exit
elsif s=="1112345678999+X"
y="19m19p19s東南西北白發中+Y"
if gets.chomp==y
puts "九蓮宝燈\nThirteen Orphans"
end
exit
end
if s=='All your base are belong to us.'
puts [3,4,4,3,6,2,2]
exit
end
if s=='くぁwせdrftgyふじこ... | true |
0431d3b50dc85a92aea55d1880bb08a75f5ed0c2 | Ruby | kbronstein/rubytrail | /metaprogramming/flat_scope.rb | UTF-8 | 387 | 4.03125 | 4 | [] | no_license | # How to access the variable door_key in:
# - the class scope
# - the method scope
#
#
#door_key = "Key"
#
#class FlatScope
# Print door_key here
# def method
# Print door_key here
# end
#end
door_key = "sesame"
FlatScope = Class.new do
puts "In the class: #{door_key}"
define_method :method do
... | true |
5eb000c0b1e5cd207aadd67bcf578a761c7ffbab | Ruby | ab/dotfiles | /pryrc | UTF-8 | 587 | 2.75 | 3 | [] | no_license | # don't use less
Pry.config.pager = false
# my terminal may resize, damn it
Pry.auto_resize!
# alias ll => exec ls -l --color
def ll
_pry_
end
# local_methods shows methods that are only available for a given object
class Object
def local_methods
self.methods.sort - self.class.superclass.methods
end
end
P... | true |
3d0aeeea1c65c5dafdf92a9102322ef0807aaf42 | Ruby | JelF/dynvar | /lib/dynvar/container.rb | UTF-8 | 738 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
class DynVar
# @api private
# Container for DynVar values, acts as stack
class Container
# @param default_value generic value
def initialize(default_value)
self.stack = [default_value]
end
# pushes new value to use
# @param x new value to be used
def pu... | true |
3202183a0c048e3d9ca233d8f96503184beef951 | Ruby | sydneyJ17/calculatorlabproject | /calculator_lab.rb | UTF-8 | 1,911 | 4.03125 | 4 | [] | no_license | require 'colorize'
# puts "Enter your first number."
# number1 = gets.chomp.to_i
# puts "Enter your second number."
# number2 = gets.chomp.to_i
# puts "Enter your function(addition,subtraction,multiplication, or division)."
# function1 = gets.chomp
# def addition(num_1, num_2)
# num_1 + num_2
# end
# if function1 ==... | true |
9778318c68e02b8f8606a2763debf0aa373a9f6c | Ruby | mdodd8299/calculatorlab | /unit.rb | UTF-8 | 715 | 4.375 | 4 | [] | no_license | #input
puts "Hello"
while true
puts "What would you like to convert to: Fahrenheit or Celsius?"
input = gets.chomp
#F
if input == "Fahrenheit" or input == "fahrenheit" or input == "f" or input == "F"
puts "What is your tempurture in Cesius?"
c = gets.to_f
answer = c*9/5+32
puts "Your conversion is:"
put... | true |
6c06f5843c39605dcdb8a4d6ace253fbc609e28e | Ruby | cha63506/typebeast | /vendor/cache/ruby/2.2.0/gems/time-lord-1.0.1/lib/time-lord/period.rb | UTF-8 | 847 | 3.28125 | 3 | [
"MIT"
] | permissive | module TimeLord
class Period
attr_writer :beginning, :ending
def initialize(beginning, ending)
self.beginning = beginning
self.ending = ending
end
def to_words
"#{value} #{unit} #{tense}"
end
alias_method :in_words, :to_words
def difference
beginning - ending
... | true |
a1f6928bf689ad43f84b315a254904db9b480ce4 | Ruby | anishaetienne/QuestionMe | /db/seeds.rb | UTF-8 | 498 | 2.78125 | 3 | [] | no_license | require 'faker'
#Create Questions
#5.times do
# Question.create!(
# questions: Faker::Lorem.sentence,
# status: Faker::Lorem.word)
#end
questions = Question.all
#Create Answers
20.times do
Answer.create!(
question: questions.sample,
answers: Faker::Lorem.paragraph)
end
#30.times do
# Tag.create!... | true |
df8ce4242e78501e463720990c56aae3c0c31a13 | Ruby | ferbaco86/Random-Movie-Twitter-Bot | /spec/genres_spec.rb | UTF-8 | 599 | 2.75 | 3 | [
"MIT"
] | permissive | require_relative '../lib/genres.rb'
describe Genres do
let(:genres) { Genres.new(%w[I Want To Watch A Comedy]) }
let(:words_array_test) { %w[Comedy] }
let(:movies_genre_selected) { Tmdb::Genre.find('Comedy') }
describe '#genre' do
it 'Returns an array with the elements that are included in words_array and... | true |
c23a09ea77cd2e8c956d944a304a11e151fbd350 | Ruby | dfwheeler394/algorithms-practice | /word_problems/uber/valid_sudoku.rb | UTF-8 | 1,498 | 3.90625 | 4 | [] | no_license | # @param {Character[][]} board
# @return {Boolean}
def is_valid_sudoku(board)
SudokuBoard.new(board).valid?
end
class SudokuBoard
def initialize(board)
@board = board
@size = board.length
end
def valid?
rows_valid? && cols_valid? && squares_valid?
end
private
def rows_valid?
@board.eac... | true |
7d42d883417880cfbec849be25aa7b8ca92d3149 | Ruby | vigneshrajkumar/computation | /DFA/farule.rb | UTF-8 | 342 | 3.203125 | 3 | [] | no_license | class FARule < Struct.new(:state, :character, :next_state)
# Checks if the given character is applicable to the current state
def applies_to?(state, character)
self.state == state && self.character == character
end
def follow
next_state
end
def inspect
"#<FARule #{state.inspect}--#{character}-->#{next_sta... | true |
a50902770c11b12d2ab46ed11a03fc15ff82cd21 | Ruby | andrewtodd/tbfinancesv1 | /app/models/transaction.rb | UTF-8 | 2,398 | 2.84375 | 3 | [] | no_license | class Transaction < ActiveRecord::Base
include Filterable
belongs_to :tennants
belongs_to :owners
validates_uniqueness_of :name, :scope => [:date, :amount]
## START OF UI FILTER SCOPES
scope :category, -> (category) { where category: category }
# I'm not sure these notes will be that much help in the futur... | true |
e8688f2018993fb15b877fd287df2e1d5a01e580 | Ruby | BigBadBlue/badges-and-schedules-001-prework-web | /conference_badges.rb | UTF-8 | 555 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
badges = []
attendees.each do |name|
badges.push badge_maker(name)
end
badges
end
def assign_rooms(ass)
rooms = []
ass.each_with_index do |name, rnum|
rooms.p... | true |
fa75d46420325356b20981c5bf16128bad8f2504 | Ruby | jennifer-yoo/ruby-oo-practice-flatiron-zoo-exercise-nyc01-seng-ft-071320 | /lib/Animal.rb | UTF-8 | 500 | 3.390625 | 3 | [] | no_license | class Animal
attr_accessor :zoo, :species, :nickname
attr_reader :weight
@@all = []
def initialize(zoo, species, weight, nickname)
@zoo = zoo
@species = species
@weight = weight
@nickname = nickname
@@all << self
end
def self.all
@@all
end
... | true |
e41e158be0b6bc7f800e3c187a0ed1664cdff309 | Ruby | TerranceDWilliams1976/debugging-with-pry-v-000 | /lib/pry_debugging.rb | UTF-8 | 58 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | num = 3
def plus_two(num)
numbers = num + 2
numbers
end
| true |
2828aa73e877a49e0b4688e71c45d2724b857bef | Ruby | callenb/workpattern | /lib/workpattern/workpattern.rb | UTF-8 | 8,454 | 3.296875 | 3 | [
"MIT"
] | permissive | module Workpattern
require 'set'
require 'tzinfo'
# Represents the working and resting periods across a given number of whole
# years. Each <tt>Workpattern</tt>has a unique name so it can be easily
# identified amongst all the other <tt>Workpattern</tt> objects.
#
# This and the <tt>Clock</tt> class are... | true |
03ac83818d5f790203bb238223a0c9f22681ae83 | Ruby | emars/gumroad-sdk | /lib/gumroad/user.rb | UTF-8 | 471 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'faraday'
require 'json'
API_ROOT = 'https://api.gumroad.com/v2/user'
module Gumroad
class User
attr_reader :name, :id, :bio, :email
def initialize(attrs)
@name = attrs['name']
@id = attrs['id']
@bio = attrs['bio']
@email = attrs['email']
end
def self.get
resp... | true |
f9019591e1da3d96bb409a68db5de055cf8d1eaa | Ruby | hasulica/learn_to_program | /ch14-blocks-and-procs/program_logger.rb | UTF-8 | 323 | 3.109375 | 3 | [] | no_license | def program_log desc, &block
puts 'Beginning "' + desc + '"...'
result = block.call
puts '..."' + desc + '" finished, returning: ' + result.to_s
end
program_log 'outer block' do
program_log 'some little block' do
5
end
program_log 'yet another block' do
'!doof iahT ekil I'.reverse
end
false
e... | true |
539f8d0d31f8979260c7242ec9544eb97e6f0f22 | Ruby | cowboy-cod3r/sandbox | /ivv-grid/perf-drb.rb | UTF-8 | 2,001 | 2.5625 | 3 | [] | no_license | #!/opt/apps/ruby/ruby/bin/ruby
require 'ivv-drb-client'
require 'date'
require 'json'
# How many tests to execute per machine
range = 1..1
threads = []
# How many times the test should execute
max = 1
max_range = 1..max
# Set the hosts file
hosts_yml = "humbarger-daily-int-hosts.yml"
hosts_yml_loc = Fi... | true |
bacccce0239158047007acdc75666d1c56496e7f | Ruby | lenadevoto/W1D5 | /skeleton/lib/00_tree_node.rb | UTF-8 | 783 | 3.578125 | 4 | [] | no_license | class PolyTreeNode
attr_accessor :value
attr_reader :parent, :children
def initialize(value = nil)
@value = value
@parent = nil
@children = []
end
# def children
# @children.dup
# end
def parent=(new_parent)
return if self.parent == new_parent
@parent.children.delete(self) unle... | true |
7979fe03dbee16604fbb8b49a010c5723198f20d | Ruby | webclinic017/stock_trend_finder | /lib/market_data_utilities/file_utilities.rb | UTF-8 | 294 | 2.609375 | 3 | [] | no_license | require 'open-uri'
module FileUtilities
def download_file(url, local_path, print: true)
puts "Downloading #{url} > #{local_path}" if print
open(local_path, 'w') do |file|
file << open(url).read
end
end
def downloads_folder
File.join(Dir.pwd, 'downloads')
end
end | true |
34e7976b33228972499ef2f907c10b90523b92c7 | Ruby | chikoski/sqsapi | /lib/sqs/api.rb | UTF-8 | 1,211 | 2.578125 | 3 | [] | no_license | require 'sqs'
require 'find'
class SQS::API
@@logger = nil
class << self
def setup(config_file)
load_config(config_file)
init_logger
load_jar_files
end
def init_logger
@@logger = Logger.new(STDERR)
if config.loglevel == "debug"
@@logger.level= Logger::DEB... | true |
605585fe8c94f1a29155afdd2e1aaabd14c4b9d0 | Ruby | Elliot-Cho/interview-assessment-1 | /warehouse/app/interactions/customers/quote_pricing.rb | UTF-8 | 492 | 2.640625 | 3 | [] | no_license | require 'active_interaction'
module Customers
# Interaction to quote customers on the pricing of storing their items
class QuotePricing < ActiveInteraction::Base
object :customer, class: Customer
validate :customer_has_items
def execute
::CustomerHelper::PriceQuoter.quote_pricing(customer, cust... | true |
4e8c54ec47b9df3b2673afe40a55e49a4f46b2c8 | Ruby | lelesrc/rails-marionet | /lib/marionet/slot.rb | UTF-8 | 519 | 2.65625 | 3 | [] | no_license | class Marionet::Slot
require 'open-uri'
require 'hpricot'
attr_accessor :url, :html, :name, :header, :body
def initialize(url,name)
@url = url
@name = name
begin
f = open(url)
rescue
return false
else
f.rewind
@html = f.readlines.join("\n")
doc = Hpricot(@htm... | true |
3361a6a104c7b178fa12f35ad23f63b40f16c5b9 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex0541.rb | UTF-8 | 106 | 2.6875 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 307
3.times do
print 'hello'.object_id, " "
end
puts
| true |
54ba1b2d820597dfcb1326022622a471e8488794 | Ruby | haibaer76/st0nk | /config/initializers/load_stonk_config.rb | UTF-8 | 1,035 | 3.28125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require 'ostruct'
# creates a new OpenStruct from the given hash
# converts all values which are hashes to OpenStruct recursively
# converts all values which are arrays recursively
def create_ostruct_from_hash(hash)
ret = OpenStruct.new(hash)
hash.each do |key, value|
if value.is_a?(Hash)
ret.send("#{key... | true |
b567df12fc32639f68ad522e5fc0dbce744a141e | Ruby | arnabs542/Programming-Interview-Questions | /Problems/Ruby/longest_common_subsequence.rb | UTF-8 | 2,552 | 4.34375 | 4 | [
"MIT"
] | permissive | # Given two sequences, find the length of the longest subsequence present in both of them.
# A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous.
# For example, “abc”, “abg”, “bdf”, “aeg”, ‘”acefg”, .. etc are subsequences of “abcdefg”.
# SOLUTION:
# Pseudocode
# I)
# We... | true |
8b400971e63fdb10d66ddf464cb7a565aaf99272 | Ruby | avivrosenberg/dotfiles | /bin.symlink/brew-updated.rb | UTF-8 | 621 | 3.046875 | 3 | [] | no_license | # require the Homebrew commands needed
require 'cmd/update'
require 'cmd/outdated'
###
# Just a helper to print bold output
def bold(str)
console_bold="\e[1m"
console_reset="\e[0m"
"#{console_bold}#{str}#{console_reset}"
end
###
# Main function
def brew_updated
# Update homebrew
puts bold "==> Updating home... | true |
4a3b6b1f294aabc62b343aed03c066868f8ec23f | Ruby | TimurM/aa_academy | /week2/w2d5 2/arrays_with_rspec/spec/towers_of_hanoi_spec.rb | UTF-8 | 1,410 | 3.84375 | 4 | [] | no_license | require 'rspec'
require 'towers_of_hanoi.rb'
describe Towers do
it "creates three arrays representing piles of disks" do
expect(Towers.generate_discs.count).to eq(3)
end
it "create an array where three disks in the first stack" do
expect(Towers.generate_stacks.count).to eq(3)
end
describe 'a tower... | true |
670a252056a90ab7c0b4dc18a552b8784ce91360 | Ruby | learn-co-students/atl-web-042219 | /11-activerecord-associations/app/app_cli.rb | UTF-8 | 594 | 3.546875 | 4 | [] | no_license | class AppCLI
def run
puts "Welcome to the zoo browser"
puts "what would you like to do today?"
main_menu
end
def main_menu
puts "1 - List our zoos"
puts "2 - List our animals"
puts "3 - quit"
choice = gets.chomp.to_i
until choice == 3
case choice
when 1
lis... | true |
4a09d4568e5c9d76a3a54c56e1785bafc5d73036 | Ruby | matipacheco/i-dont-know-shit | /models/battle.rb | UTF-8 | 1,315 | 3.75 | 4 | [] | no_license | require_relative 'character'
require_relative '../mongo_connection'
# Game class. It represents the fight between two Character's
# The fight logic isnt 100% correct, but you get the idea of it :smirk:
class Battle
attr_accessor :fighter1, :fighter2, :game_over, :winner
def initialize(fighters_json = nil)
fig... | true |
838822c1cabd8d8907e2c2034ecd210de0de74b8 | Ruby | AhmedAliIbrahim/fawry | /lib/fawry/utils.rb | UTF-8 | 1,009 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Fawry
module Utils
TRUTH_VALUES = [true, 'true', '1', 't'].freeze
# Adds keys from fawry API response as methods
# on object instance that return the value
# of each key
#
# type => type
# referenceNumber => reference_number
# merchantRefNumber =>... | true |
7143d3cd19ceac5cd7ca5184a1e92635354451b4 | Ruby | AndreySereda/gotoinc-school | /lesson1_ex3.rb | UTF-8 | 270 | 3.703125 | 4 | [] | no_license | puts "Введите 3 значения для вычесления среднего арифметического"
a = gets.chomp.to_f
b = gets.chomp.to_f
c = gets.chomp.to_f
d = (a + b + c) / 3
puts "Cреднее арифметическое чисел:" + d.to_s
| true |
3c1fa61c93372fdd3f372c01982e7846ddc9aa70 | Ruby | bradq/rubysh | /lib/rubysh/subprocess/pipe_wrapper.rb | UTF-8 | 2,091 | 2.765625 | 3 | [
"MIT"
] | permissive | class Rubysh::Subprocess
class PipeWrapper
begin
require 'json'
SERIALIZER = JSON
rescue LoadError => e
if ENV['RUBYSH_ENABLE_YAML']
require 'yaml'
SERIALIZER = YAML
else
raise LoadError.new("Could not import JSON (#{e}). You should either run in an environment ... | true |
76ef7ab712267c604addc3ba053d73c07315ab5c | Ruby | CDL-Dryad/dryad-app | /lib/stash/repo/submission_result.rb | UTF-8 | 2,052 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'logger'
module Stash
module Repo
# Encapsulates a submission result
class SubmissionResult
attr_reader :resource_id, :request_desc, :message, :error
attr_accessor :deferred
# @param resource_id [Integer] the ID of the submitted resource
# @param request_desc [String, nil] a ... | true |
b1e47c510e6890616388be415dbb0a99816b866b | Ruby | JeremyVe/project_tdd_minesweeper | /lib/board.rb | UTF-8 | 4,989 | 3.40625 | 3 | [] | no_license | require_relative 'cell'
class Board
attr_accessor :board, :board_size, :bombs, :count
attr_reader :game_over
def initialize (board_size = 10, bombs = 9)
@count = (board_size ** 2) - bombs
@board = {}
@board_size = board_size
@bombs = bombs
@flags_nb = bombs
@game_over = false
create_... | true |
60dc797f1e860428215aa0b66744030792dbd3c3 | Ruby | russenoire/LS_core | /rb101/exercises/small_problems/easy_2/008_sum_or_product_extra.rb | UTF-8 | 291 | 4.1875 | 4 | [] | no_license | puts ">> Please enter an integer greater than 0:"
int_input = gets.chomp.to_i
puts ">> Enter 's' to compute the sum, 'p' to compute the product."
exp_input = gets.chomp
case exp_input
when 's'
puts (1..int_input).sum
when 'p'
puts (1..int_input).reduce { |product, n| product * n }
end
| true |
a711a32e8d4d46229cf6b3f934df37d89e339f54 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/ec1d43f13d054e49b577b0b3c9df7ada.rb | UTF-8 | 407 | 3.8125 | 4 | [] | no_license | class Bob
def hey(phrase)
case
when is_silent?(phrase)
'Fine. Be that way.'
when is_shouting?(phrase)
"Woah, chill out!"
when is_question?(phrase)
'Sure.'
else
"Whatever."
end
end
def is_silent?(phrase)
phrase.empty?
end
def is_shouting?(phrase)
phrase ... | true |
81573bbab38098e5ad44cfbe65643dfc5e028d44 | Ruby | Aalto-LeTech/stops | /script/list_course_prereqs.rb | UTF-8 | 580 | 2.75 | 3 | [] | no_license |
# lists all
# scoped courses
# with their abstract course code
# and their prereq course names
#
ScopedCourse.all.each do |scoped_course|
puts "Scoped: #{scoped_course.localized_description.name}"
if scoped_course.abstract_course
puts "Abstract: #{scoped_course.abstract_course.code}"
else
pu... | true |
5091d4c568bfc2d033bac2a8a8522a08970855d3 | Ruby | MeZKaL/adyen | /lib/adyen/rest/payout.rb | UTF-8 | 3,251 | 2.6875 | 3 | [
"MIT"
] | permissive | module Adyen
module REST
# This module implements the <b>Payout</b>
# API calls, and includes a custom response class to make handling the response easier.
# https://docs.adyen.com/developers/payout-manual
module Payout
class Request < Adyen::REST::Request
protected
def base_pat... | true |
a5c97fb09ac36016756ca86566d3d5c2a5a4b185 | Ruby | svencu/ruby | /age.rb | UTF-8 | 449 | 4 | 4 | [] | no_license | puts "What is your name?"
name = gets.chomp
puts "What is your age?"
age = gets.chomp.to_i
puts "What is your gender (m/f)?"
gender = gets.chomp
if gender == "m"
salutation = "Sir"
else
if gender == "f"
salutation = "Madam"
else
salutation = "genderless"
end
end
dat... | true |
bae4f7124853714cd8cc1a93dcb8d78053841090 | Ruby | andrewpurcell/lost-cities | /test/lost_cities_test.rb | UTF-8 | 1,209 | 2.9375 | 3 | [] | no_license | require_relative 'test_helper'
describe LostCities do
describe LostCities::DeckBuilder do
before do
@cards = LostCities::DeckBuilder.build_cards(LostCities::Suit.all, 2..10, 3)
end
it 'includes the right stuff' do
assert_equal 5*12, @cards.count
assert_equal 5*3, @cards.count(&:investo... | true |
61ff90db517df8306bab59e0c09fcef6e09ed4e9 | Ruby | HomeBusProjects/homebus-wunderground | /vendor/ruby-homebus/lib/homebus.rb | UTF-8 | 1,115 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'pp'
class HomeBus
# in order to provision, we contact
# HomeBus.local/provision
# and POST a json payload of { provision: { mac_address: 'xx:xx:xx:xx:xx:xx' } }
# you get back another JSON object
# uuid, mqtt_hostname, mqtt_port, mqtt_username, mqtt_password
# save this in .env.... | true |
5f69efdfc673b85b839fcdb2189b30ef4e1d3262 | Ruby | fivesenses/cropster | /lib/cropster/response/location.rb | UTF-8 | 502 | 2.71875 | 3 | [
"MIT"
] | permissive | ##
# Converts a Hash object into a Cropster::Response::Location object
#
module Cropster::Response
class Location < Cropster::Response::FormattedResponseItem
attr_accessor :name, :street, :zip, :city, :country
# @param attributes [Hash]
def load_attributes(attributes)
return if attributes.nil?
... | true |
6b520fc28cd9f37dbbe4a2238be7b0dc1db6f784 | Ruby | oya3/ruby_tools | /common_modules/signature_stamper.rb | SHIFT_JIS | 24,107 | 2.578125 | 3 | [] | no_license | # coding: cp932
require 'cairo'
require 'pango'
require 'stringio'
require 'win32/clipboard'
Encoding.default_external = 'cp932'
Encoding.default_internal = 'cp932' # ȂƕiR[h\jɂȂB
class SignatureStamper
#NX萔
#PI2 = Math::PI*2 # 360xp
DEFAULT_SIZE = 200
def initialize( param = nil)
@inparam = c... | true |
003577b63890a5b40e15ebed3e0f38b8a9c0659d | Ruby | kat-onyx/W2D3 | /tdd/lib/tdd.rb | UTF-8 | 785 | 3.5625 | 4 | [] | no_license | def remove_dups(array)
array.uniq
end
def two_sum(array)
result = []
(0..array.length - 1).each do |left|
(left + 1..array.length - 1).each do |right|
result << [left, right] if array[left] + array[right] == 0
end
end
result
end
def my_transpose(array)
result = Array.new(3) { Array.new [] }... | true |
ee4ffed1524d2de97e93f671a9a888f4a2df70c0 | Ruby | JeanJoeris/battleship | /lib/game_cell.rb | UTF-8 | 222 | 2.71875 | 3 | [] | no_license | class GameCell
attr_reader :content
def initialize
@content = nil
@hit = false
end
def hit?
@hit
end
def hit
@hit = true
end
def add(data)
@content = data unless @content
end
end
| true |
bb94a17ea7f38d3da318eb98bf6b7bcae60f7d1e | Ruby | cmeiklejohn/wine_dot_com_api_request | /lib/wine_dot_com_api_request.rb | UTF-8 | 4,189 | 2.953125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
# WineDotComApiRequest class.
#
# Provides an interface to access the Wine.com API.
#
# Author:: Christopher Meiklejohn (cmeik@me.com)
# Copyright:: Copyright (c) 2010 Christopher Meiklejohn
# License:: Distributes under the terms specified in the MIT-LICENSE file.
#
# Usage example:
#w = WineDotCo... | true |
293534637e5cc297de27b3513156980209d66332 | Ruby | michaelciletti/refactored_projects | /code.rb | UTF-8 | 345 | 3.78125 | 4 | [] | no_license | def fizzkata(my_array)
my_array.count
end
def minedminds(my_array)
array = []
my_array.each do |num|
if num % 15 == 0
array.push("minedminds")
elsif num % 3 == 0
array.push("mined")
elsif num % 5 == 0
array.push("minds")
else
array.push(num)
end
end
array.inspect
end
my_array = [*1..100]
p... | true |
3be8836987dfa6dad0b14a178e66c1c2f327fd04 | Ruby | timsully/learn_ruby_the_hard_way | /ex40.rb | UTF-8 | 1,726 | 4.96875 | 5 | [] | no_license | # Creating the class Song
class Song
# When we call a function down below the initialize
# function grabs the values being passed in and
# assigns it equal to the variable lyrics
def initialize(lyrics)
@lyrics = lyrics
end
# sing_me_a_song then gets the lyrics variable
# and iterates through each el... | true |
dc9fc7a4073562eb2a66b876f65fb633a2e13a78 | Ruby | guineveresaenger/Word-Guess | /flower.rb | UTF-8 | 941 | 3.875 | 4 | [] | no_license | require 'colorize'
class Flower
def initialize(buds)
@buds = buds
end
def flower
puts
case @buds
when 7
puts " (@) (@)".colorize(:red)
puts "(@)(@)(@)(@)(@)".colorize(:red)
when 6
puts " (@)".colorize(:red)
puts "(@)(@)(@)(@)(@)".colorize(:red)
when 5
... | true |
38ba99533cdc2b7c8a855a873aabbdabf4e4f631 | Ruby | NativeScript/webkit | /Tools/iExploder/iexploder-1.7.2/tools/lasthit.rb | UTF-8 | 2,238 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# Copyright 2010 Thomas Stromberg - All Rights Reserved.
#
# 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 req... | true |
f5a68496c2bb3da77a5c99c1f825040ea9c7c51a | Ruby | Kishanpa3/OakCreekDB | /app/datatables/animal_datatable.rb | UTF-8 | 885 | 2.703125 | 3 | [
"MIT"
] | permissive | class AnimalDatatable < ApplicationDatatable
private
def data
animals.map do |animal|
[].tap do |column|
column << animal.id
column << animal.tag
column << animal.name
column << animal.common_name
column << animal.habitat_num
end
end
end
def count
... | true |
1f048cf10d4c6721fbe60869051e1da23bd47032 | Ruby | albertbahia/wdi_june_2014 | /w03/d03/gadi_gottlieb/classwork/fibonacci/lib/fibonacci.rb | UTF-8 | 399 | 3.453125 | 3 | [] | no_license | require 'pry'
def sum_of_even_fibonaccis(limit)
holder = [1, 2]
while (holder[-1] + holder[-2]) < limit
holder << holder[-1] + holder[-2] # only concerned with the last one, and the second to last one.
end # we then add those two numbers together in order to get our Fibonacci... | true |
306997de6060081ad88f1d69998e0737c693ac0f | Ruby | ntmbayfield/DevBootcamp-1 | /week1/sudoku.rb | UTF-8 | 4,525 | 3.875 | 4 | [] | no_license | class Sudoku
def initialize(board_string)
board_string = board_string.split("")
@board = []
9.times do |row|
@board << board_string.shift(9)
@board[row].map! do |item|
item.to_i
end
end
end
def return_row(row)
row_arr = []
board[row].each do |item|
if item.... | true |
d2898ae5b5e6e5e419d6a6e6bbe445d086adf81f | Ruby | fameoflight/hirehub | /lib/compile_job.rb | UTF-8 | 2,811 | 2.5625 | 3 | [] | no_license | class CompileJob
attr_accessor :submission, :solution_dir, :code_path, :exe_path, :compiler_output, :success, :lang
def self.perform( submission_id )
job = new submission_id
job.prepare_dir submission_id
job.compile
return job
end
def initialize( submission_id )
@submission = Submission.find( su... | true |
d9e60b0e59b6b32059da2e4d369207c4bc331db0 | Ruby | Dale-R-Harrison/RB101 | /small_problems/easy4/leap_years.rb | UTF-8 | 498 | 4 | 4 | [] | no_license | # orgiginal solution
def leap_year?(year)
leap_year = false
if year % 100 == 0
if year % 400 == 0
leap_year = true
end
else leap_year = true
end
end
leap_year
end
puts leap_year?(2016)
puts leap_year?(2015)
puts leap_year?(2100)
puts leap_year?(2400)
puts leap_year?(240000)
pu... | true |
762f29a574d685f425c6ff9ca9707dac016be7d4 | Ruby | acanshul/racing_on_rails | /test/models/events/competitions/dirty_circles_overall_test.rb | UTF-8 | 1,859 | 2.53125 | 3 | [
"Ruby",
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
module Competitions
# :stopdoc:
class DirtyCirclesOverallTest < ActiveSupport::TestCase
test "calculate" do
series = Series.create!(name: "Dirty Circles")
series.children.create!(date: Date.new(2016, 3, 8), name: "Dirty Circles 1")
series.... | true |
ca0a9172e3f442b96f3773a12d812fcf6de8063b | Ruby | LauraNgy/Day_2_Lab | /lab_testing_functions_start/ruby_functions_practice.rb | UTF-8 | 1,286 | 3.984375 | 4 | [] | no_license | def return_10()
return 10
end
def add(num1, num2)
return num1 + num2
end
def subtract(num1, num2)
return num1 - num2
end
def multiply(num1, num2)
return num1 * num2
end
def divide(num1, num2)
return num1 / num2
end
def length_of_string(string)
return string.length()
end
def join_string( string_1, st... | true |
abfc70bd055722cefca1dec148dd71453347f010 | Ruby | SteveVallay/ruby-practice | /chapter3/var1.rb | UTF-8 | 136 | 2.9375 | 3 | [] | no_license | person = "Good luck"
puts "person's classname is #{person.class}"
puts "person 's id is #{person.object_id}"
puts "person is : #{person}"
| true |
4794b559ed7dc7ee178f2e4502bbf4e53250fb0a | Ruby | rheimbuch/rtunesu | /lib/rtunesu/entities/track.rb | UTF-8 | 1,008 | 2.578125 | 3 | [
"MIT"
] | permissive | module RTunesU
# A Track in iTunes U.
# == Attributes
# Name
# Handle
# Kind
# TrackNumber
# DiscNumber
# DurationMilliseconds
# AlbumName
# ArtistName
# GenreName
# DownloadURL
# Comment
class Track < Entity
# Tracks can only be found from within their Course. There is currently no way ... | true |
e646c6f364082170de67cc9e6356dc08b6a49143 | Ruby | profmaad/catmother | /lib/catmother/bytecode_parser.rb | UTF-8 | 875 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | module CatMother
class BytecodeParser
def initialize
@opcodes = []
CatMother::Opcode::constants.reject { |c| !(CatMother::Opcode.const_get(c).class == Class) }.map { |c| CatMother::Opcode.const_get(c) }.each do |c|
@opcodes[c::OPCODE] = c
end
end
def parse(io, length)
dis... | true |
f98578ad38f87a341065d89a452b750ff035acfb | Ruby | MAshrafM/The_Odin_Project | /11_Data_Structure/KnightMoves/lib/bfs.rb | UTF-8 | 436 | 3.109375 | 3 | [] | no_license | # lib/bfs
class BFS
attr_accessor :way
def initialize(source, target)
@b = Board.new
@way = {}
solve(source, target)
end
def solve(source, target)
q = [source]
visited = []
until q.empty?
pos = q.shift
visited << pos
jump = @b.cells[pos[0]][pos[1]].link
jump.each do |j|
q.unshift(j... | true |
cae3f2f6d66823b0d68278d5139644d372924c1d | Ruby | lebaongoc/Solar-System | /lib/solar_system.rb | UTF-8 | 1,180 | 3.71875 | 4 | [] | no_license |
class SolarSystem
attr_reader :star_name, :planet
def initialize(star_name)
@star_name = star_name
@planets = []
end
def add_planet(planet_instance)
@planets << planet_instance
end
def list_planets
conclusion_statement = "Planets orbiting #{star_name}:\n"
i = 1
planet_list = ""
... | true |
78630b476e2a6affecc850fb238e2fcdbecbe3fd | Ruby | MalconMouraLima/RubyGame | /nomes.rb | UTF-8 | 297 | 3.78125 | 4 | [] | no_license | def le_nome
nome = gets.strip
puts "Lido #{nome}"
nome
end
def pede_nome
puts "Digite seu nome"
nome_lido = le_nome
puts "Pedido!"
nome_lido
end
def inicio
nome = pede_nome
puts "Bem vindo #{nome}"
puts "Quero conhecer mais alguém"
nome2 = pede_nome
puts "Olá #{nome2}"
end
inicio | true |
5890342e226bc439e5bf2177b9e61416903925f8 | Ruby | malev/efemerides-culturales | /event.rb | UTF-8 | 825 | 2.734375 | 3 | [] | no_license | class Event
include Mongoid::Document
field :month, :type => Integer
field :day, :type => Integer
field :year, :type => Integer
field :content, :type => String
def self.search(month, day)
if where(:month => month, :day => day).count == 0
parse_and_store(month, day)
else
gener... | true |
59468ff55684c2d7b11d898bebe6c94e7397df16 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex1021.rb | UTF-8 | 132 | 2.84375 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 494
f = File.new("testfile")
c = f.getc
f.ungetc(c)
f.getc
| true |
a13ca6e1c446a5f586174de4ebb719993d468697 | Ruby | exctzo/socks | /create_droplet.rb | UTF-8 | 2,227 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'droplet_kit'
require 'timeout'
puts ""
puts "-----------------------------------Server creation-----------------------------------"
puts ""
puts "Enter the Personal access tokens: "
token = gets
puts ""
puts "-------------------------------------------------------------------------------... | true |
2f3d84c5ab4cb8fab50eade6d379b1939dcbb966 | Ruby | s-steel/monster_shop_2005 | /app/models/order.rb | UTF-8 | 1,416 | 2.625 | 3 | [] | no_license | class Order < ApplicationRecord
validates_presence_of :name, :address, :city, :state, :zip
has_many :item_orders
has_many :items, through: :item_orders
belongs_to :user
enum status: %w[pending packaged shipped cancelled]
def status_update
if (status == 'pending') && item_orders.where('status = 0 OR s... | true |
16d89933bbc0ba872b9e2bf4e677741c85588138 | Ruby | RumikoAcopa/activerecord-tvshow-onl01-seng-pt-052620 | /app/models/show.rb | UTF-8 | 1,175 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Show < ActiveRecord::Base
def Show::highest_rating
Show.maximum(:rating)
end
def Show::most_popular_show
Show.find_by rating: Show.highest_rating
#highest_rating: SELECT "shows".* FROM "shows" WHERE (highest_rating = 1) LIMIT ?
#highest_rating method as a helper... | true |
7d9ed7f0799fd2510ef5b495f4b1e2ddcf3c1cc8 | Ruby | smkopp92/UtiliTrak | /spec/features/07user_edits_deletes_bills_spec.rb | UTF-8 | 1,564 | 2.53125 | 3 | [] | no_license | # As an authenticated user
# I want to edit my utility bills
# So that I can update any incorrect information
# Acceptance Criteria
# [x]I must fill out all the information correctly
# [x]I should be redirected to show page after submitting form
# [x]Incorrect information should raise an error and refresh page
#
# As a... | true |
358a3d3bed176e45b22e8dea28a67dfc75d953f7 | Ruby | neurodynamic/p1_rspec_and_regex_breakout | /spec/phone_numbers_spec.rb | UTF-8 | 849 | 2.875 | 3 | [] | no_license | require 'rspec'
require_relative '../phone_numbers'
describe '#standardize_phone_number' do
let(:basic_phone_number) { "(555) 555-5555" }
let(:invalid_number) { "fjhdskhfdjkshjkdsf" }
let(:dash_separated_number) { "555-555-5555" }
it "doesn't change an already standardized phone number" do
output = stan... | true |
6bc38654bf1ceae379290d696131bfbf2fa1e0f7 | Ruby | jvidalba1/jvidalba_site | /app/models/user.rb | UTF-8 | 962 | 2.671875 | 3 | [] | no_license | # == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# content :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class User < ActiveRecord::Base
attr_accessible :c... | true |
6a17ffce190d266503b0dbb708d9abc5fa5b054d | Ruby | ALucking1/recipe_app | /models/recipes.rb | UTF-8 | 1,670 | 2.609375 | 3 | [] | no_license | class Recipes
attr_reader :rand_rec
def brrr_days
@rand_rec = [["http://www.bbcgoodfood.com/recipes/3444/saras-chilli-con-carne", "Chilli Con Carne"], ["https://deliciouslyella.com/potato-peanut-curry/", "Potato Peanut Curry"], ["http://www.bbcgoodfood.com/recipes/4807/chunky-minestrone-soup", "Minestrone Sou... | true |
a52ab11721383263851b2e1e1cad89d7a2d01096 | Ruby | kylehenson/salesengine | /test/merchant_repository_test.rb | UTF-8 | 4,093 | 2.984375 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/merchant_repository'
require_relative '../lib/sales_engine'
class MerchantRepositoryTest < Minitest::Test
def test_it_exists
assert MerchantRepository
end
def test_it_holds_seven_merchant_instances
merchant_repo = MerchantRepository.new('./test/su... | true |
fb3e1b65b07dc607ad4e1f1ef6827c90fcbc3472 | Ruby | piotrekkopanski/ads | /app/services/read_notifications_service.rb | UTF-8 | 643 | 2.671875 | 3 | [] | no_license | class ReadNotificationsService
def self.valid_keys(options)
expected_keys_string = ["email", "category", "cost"]
expected_keys_symbol = [:email, :category, :cost]
if (options.keys - expected_keys_string).empty? or (options.keys - expected_keys_symbol).empty?
return true
end
end
public
d... | true |
49152c4d9578ab92240cf77b5358892309d73e7d | Ruby | nullobject/mache | /lib/mache/node.rb | UTF-8 | 1,353 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'mache/dsl'
module Mache
# The {Node} class represents a wrapped HTML page, or fragment. It exposes all
# methods from the Mache DSL, and forwards any Capybara API methods to the
# {#node} object.
#
# @abstract
class Node
include DSL
# The underlying Capybara node object wrapped by this in... | true |
7a08062d3080e1232000339c3058e8a425ec464d | Ruby | JamManolo/api-dev | /transform-groups.rb | UTF-8 | 1,576 | 2.625 | 3 | [] | no_license | #
# simple 'include' file for transform tools
#
def create_group_map(options={})
league_id = options[:league_id]
fixtures_xml = options[:xml]
group_hash = Hash.new
fixtures_xml.xpath("//Match").each do |node|
if [16, 17].include? league_id
home_team_id = node.xpath("HomeTeam_Id").text
away_team_... | true |
f044224c6d19ef3191e097ca5ae4a5b1d93a5c7a | Ruby | guilhermepalmeira/linuxfi-loja | /app/models/pedido.rb | UTF-8 | 1,699 | 2.765625 | 3 | [] | no_license | class Pedido < ActiveRecord::Base
has_many :itens, :dependent => :destroy #um pedido tem vários itens, o :dependent, destroy o item se ele for zero
accepts_nested_attributes_for :itens #vai aceitar receber os atributos de forma aninhada
#vai atumaticamente criar no seu objeto um metodo "itens_attributes", criadn... | true |
19a0df3782a3de0fbccdd42201eed261bd421ccf | Ruby | randyjap/project-euler | /15.rb | UTF-8 | 414 | 3.515625 | 4 | [] | no_license | # Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
# How many such routes are there through a 20×20 grid?
# Answer: 137846528820
grid_size = 20
paths = 1
grid_size.times do |idx|
paths *= (2 * grid_size) - idx
... | true |
4f2838b0a2ef697fbf4ddf5a66c8c8dcb92d64ee | Ruby | kurochan/gaspe-bot | /job/keyword_fav.rb | UTF-8 | 531 | 2.625 | 3 | [] | no_license | class KeywordFavJob
def call(status)
return unless status.text
data = [
'がすぺ', 'ガスペ', '清楚', 'せいそ',
'クソネミ', 'くそねみ', 'ラブライブ',
'スクフェス', 'にっこにっこにー', 'じぇい',
'ジェイ', 'サイゼ', 'ぱんだ', 'パンダ',
'ばし', 'くろ'
]
data.each do |str|
if status.text.include? str
puts "Keyword favo... | true |
9abd13c813722f3ba4f4cfd415c749b64f107b13 | Ruby | Finble/learn_to_program | /ch11-reading-and-writing/build_your_own_playlist.rb | UTF-8 | 319 | 2.671875 | 3 | [] | no_license | # my incomplete solution below, but got timed out... no rspec tests
def music_shuffle filenames
File.open 'filenames.m3u', 'w' do |f|
all_mp3.each do |mp3|
f.write mp3.sort_by{rand} + '\n' #write method returns a string?
end
end
end
puts 'Done!'
#included shuffle method from earlier exercise
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.