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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e4ea875c92aba2cf510cec8aad89473617d5f79b | Ruby | julsfelic/complete_me | /test/node_test.rb | UTF-8 | 1,678 | 2.90625 | 3 | [] | no_license | require 'minitest'
require 'test_helper'
require 'node'
require 'complete_me'
require 'pry'
class NodeTest < Minitest::Test
attr_accessor :node, :completion
def setup
@node = Node.new
end
def test_can_create_an_instance
assert_instance_of Node, node
end
def test_has_an_initial_value_set_to_an_em... | true |
ce3477f03666572a4808d2300966263207390551 | Ruby | AvraamMavridis/ruby-exercises | /fix_string/fix_string.rb | UTF-8 | 93 | 3.265625 | 3 | [] | no_license | def solve s
s.chars.count { |x| x == x.upcase } > (s.length/2) ? s.upcase : s.downcase
end
| true |
22c473dbec176f193d1310721c918eccfdad899d | Ruby | dallas/score-keeper | /old-app/app/models/game_play.rb | UTF-8 | 713 | 2.671875 | 3 | [] | no_license | class GamePlay < ActiveRecord::Base
belongs_to :game
has_many :game_players, :dependent => :destroy
validates :game_name, :presence => true
validate :must_have_at_least_two_players
def game_name=(name)
self.game = Game.find_or_create_by_name(name)
self.game_id = self.game.id
end
def game_name
... | true |
26bf557f8978d3e9dae8ad4163fd3bac0480553b | Ruby | rafatkatta/noon | /lib/noon/builder.rb | UTF-8 | 1,989 | 3.28125 | 3 | [
"MIT"
] | permissive | require 'ostruct'
class Noon::Builder
#build noon every noon conatine neens
attr_reader :neens, :amount, :energy, :complexity
attr_reader :difficult, :additional_value
def initialize(amount= 0, difficult= 1, additional_value= 1)
@amount = amount
@difficult = difficult
@additional_value = additi... | true |
cc7f109e30cb6c29093cc02abb3aa06aa82f6158 | Ruby | elmagrace/midterm | /YouTube Tutorials/hashesandsymbols.rb | UTF-8 | 92 | 3.078125 | 3 | [] | no_license | hash = {
Jackson: 17,
Sarah: 19,
Johnson: 25,
Mike: 75
}
names = hash.each_key {|k| puts k} | true |
7966e948d13e3100d357d9e0aae38fdc63d39daa | Ruby | mishkinf/busy-beaver-ruby | /turing_machine.rb | UTF-8 | 1,549 | 3.265625 | 3 | [] | no_license | require 'curses'
# Curses.noecho
# Curses.init_screen
class TuringMachine
include Comparable
class CardsNotDefinedError < ArgumentError
end
def initialize(cards)
raise CardsNotDefinedError unless cards
@card_position = cards.keys.first
@cards = cards
@tape = Tape.new
@steps = 0
... | true |
95eb4132753fc048d895dc7c27f4544c1f5effdc | Ruby | kaytlinrb/coin_combos | /spec/coin_combos_spec.rb | UTF-8 | 282 | 2.546875 | 3 | [] | no_license | require('rspec')
require('coin_combos')
describe('Fixnum#coin_combos') do
it("one cent will return one penny") do
expect((1).coin_combos).to (eq("[0, 0, 0, 1]"))
end
it("25 cents will return one quarter") do
expect((25).coin_combos).to(eq("[1, 0, 0, 0]"))
end
end
| true |
deacc36724f56edf249a19b14077fc43d43a9081 | Ruby | ueyuki/CPro | /atCoder/beginnerContest/067/sharingCookies.rb | UTF-8 | 197 | 3.359375 | 3 | [] | no_license | a, b = gets.chomp.split.map(&:to_i)
status = 'Impossible'
if a % 3 == 0
status = 'Possible'
elsif b % 3 == 0
status = 'Possible'
elsif (a + b) % 3 == 0
status = 'Possible'
end
puts status
| true |
f461a519d5a9b845680d287826224795f992ea4a | Ruby | coderunner-framework/veritascrmod | /lib/veritascrmod/veritas.rb | UTF-8 | 15,647 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'coderunner'
class CodeRunner
# This is a customised subclass of the CodeRunner::Run class which allows CodeRunner to run and analyse the Vlasov Maxwell solver Veritas.
#
# It generates the Veritas input file, and both analyses the results and allows easy plotting of them.
class Veritas < Run::For... | true |
5c9ec863a641f9e23eecf58a4aef318659d60131 | Ruby | Brown-University-Library/bibService | /scripts/default_batches.rb | UTF-8 | 1,140 | 2.5625 | 3 | [] | no_license | require "json"
text = File.read("tracker.json")
json = JSON.parse(text)
batches = json["batches"]
base_url = "http://localhost:9001/bibutils/marc/?bib="
# Original batches in the tracker file.
batches.each_with_index do |b, i|
start_range = "b" + b["chunk_start_bib"].to_s
end_range = "b" + b["chunk_end_bib"]... | true |
f201cf16d894626374a313fe3c4b464bcd516b1b | Ruby | eljetico/datawrangler | /lib/data_wrangler/readers/txt_reader.rb | UTF-8 | 869 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative "text_reader"
module DataWrangler
module Readers
# Reader for tab-separated text files
class TxtReader < TextReader
def field_sep
"\t"
end
def line_sep
detect_line_separator
end
def text_file_encoding
@enc... | true |
8f55fd5c1cf7c4d4d4efe165c6a70c3fbe774645 | Ruby | thomasbeckett/sparta_stuff | /week-5/oop_lab/square.rb | UTF-8 | 433 | 3.6875 | 4 | [] | no_license | class Square
attr_accessor :length, :scale
def initialize length, scale=1
self.length = length
self.scale = scale
end
def calculate_area
length ** 2
end
def calculate_perimeter
length * 4
end
def scaled_area
calculate_area * scale
end
def scaled_perimeter
calculate_peri... | true |
f1a375187bc232dbfc7a2d2fa73e49c5d825cb7e | Ruby | sankai/kinukake | /lib/kinukake.rb | SHIFT_JIS | 721 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'active_support/dependencies'
require "kinukake/version"
require "open3"
module Kinukake
def run (command, *params)
# R}h̓AvP[VfBNgSHELLz̑O
command = 'SHELL/' + command
# R}h̕ҏW
params.each do | param |
command = command + ' ' + param.to_s
end
res = nil
... | true |
c6e7471a8b6a15d09f1b666e0a93720c41487816 | Ruby | Lani1321/raleigh_events | /lib/raleigh_events/event.rb | UTF-8 | 1,186 | 2.984375 | 3 | [
"MIT"
] | permissive | class RaleighEvents::Event
attr_accessor :title, :date, :location, :url
@@all = []
def initialize(attributes = {})
@title = attributes[:title]
@date = attributes[:date]
@location = attributes[:location]
@url = attributes[:url]
@@all << self
end
def self.all
@@all
end
d... | true |
541dbadc4d0868c1e4a9efe9f0fac5c276cc0f0e | Ruby | chunyang/lc3spec | /lib/lc3spec/dsl.rb | UTF-8 | 2,519 | 2.796875 | 3 | [
"MIT"
] | permissive | module LC3Spec
module Dsl
def self.extended(base)
base.instance_eval do
@options ||= {
:output => $stdout,
:keep_score => false
}
@possible_points ||= 0
@earned_points ||= 0
@num_tests ||= 0
@num_passed ||= 0
end
end
def se... | true |
8a30e390259ef58923ab72ee3fbb888f81d725e8 | Ruby | oshinkoshinko/ruby_intoduction | /ruby-book/lib/rgb.rb | UTF-8 | 555 | 3.765625 | 4 | [] | no_license |
def to_hex(r,g,b)
# '#'+
# hex = '#'
# r.to_s(16).rjust(2, '0') +
# g.to_s(16).rjust(2, '0') +
# b.to_s(16).rjust(2, '0')
# [r,g,b].each do |n|
# hex += n.to_s(16).rjust(2, '0')
[r,g,b].inject('#') do |hex, n|
hex + n.to_s(16).rjust(2, '0')
end
# hex
end
puts to_hex(30,88,98)
def to_ints(he... | true |
daf44fb9ae662ad9b9c694ed694ad5371c5c4911 | Ruby | whatalnk/cpsubmissions | /atcoder/ruby/arc021/arc021_1/469902.rb | UTF-8 | 782 | 3.625 | 4 | [] | no_license | # Contest ID: arc021
# Problem ID: arc021_1 ( https://atcoder.jp/contests/arc021/tasks/arc021_1 )
# Title: A. DEAD END
# Language: Ruby (1.9.3)
# Submitted: 2015-08-15 07:06:11 +0000 UTC ( https://atcoder.jp/contests/arc021/submissions/469902 )
tiles = []
while line = gets
tiles << line.chomp.split(" ").map(&:to_i)... | true |
84f60fbc54334e787af2f419e46a067387262540 | Ruby | NCSU-Libraries/circa | /app/lib/general_utilities.rb | UTF-8 | 575 | 2.96875 | 3 | [
"MIT"
] | permissive | module GeneralUtilities
def nil_or_empty?(value)
if value.nil? || (value.respond_to?(:empty?) && value.empty?)
true
end
end
# Log message and output to stdout
def log_info(message)
Rails.logger.info message
# output to stdout for visibility into running background jobs
puts "#{DateTi... | true |
d56ff1b3737e81a489aa8754fb06d724b9b5ad03 | Ruby | KristenWilde/Launch-School-Ruby | /challenges/medium2/palindrome_products.rb | UTF-8 | 1,637 | 4.09375 | 4 | [] | no_license | require 'pry'
class Palindromes
attr_reader :largest, :smallest
def initialize(params)
@max_factor = params[:max_factor]
@min_factor = params[:min_factor] || 1
end
def generate
all_numbers = (@min_factor..@max_factor).to_a
all_combinations = all_numbers.combination(2).to_a
all_numbers.eac... | true |
c1c87d3d10f38d98c869ee9d625dc73246467102 | Ruby | iros/jruby-opennlp | /spec/tokenizer_spec.rb | UTF-8 | 1,597 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | require "spec_helper"
describe "OpenNLP::Tokenizer" do
context "initialisation" do
it "should initialise a new tokeniser" do
tokenizer = OpenNLP::Tokenizer.new(fixture_model)
tokenizer.should be_a(OpenNLP::Tokenizer)
end
it "should raise an argument error when no model is supplied" do
... | true |
709648d1a3db96ac2d67a1179201087c07142f80 | Ruby | cowplace/heroku-cowplace | /model/station.rb | UTF-8 | 907 | 2.671875 | 3 | [] | no_license | Sequel::Model.plugin(:schema)
class Station < Sequel::Model
unless table_exists? then
set_schema do
primary_key :id
string :name
integer :pref_id
float :lon
float :lat
end
create_table
end
def mod_pos(lat_min, lat_max, lon_min, lon_max)
delta = 800
d_lat = lat_ma... | true |
625da6cda5b13cfdad67d0f5bf1267e2b17473db | Ruby | StephenAlbertChan/ruby-10th-activity | /count-positives-sum-negatives.rb | UTF-8 | 208 | 3.390625 | 3 | [] | no_license | array = [1,2,3,4,5,6,7,8,9,10,-11,-12,-13,-14,-15]
countsum = [0,0]
for i in 0...array.length
if(array[i] > 0)
countsum[0] += 1
else
countsum[1] += array[i]
end
end
puts countsum | true |
615a8c84d79f2258f695ec9c71cadd2657620734 | Ruby | ana29/Ruby | /salary.rb | UTF-8 | 240 | 3.046875 | 3 | [] | no_license | #Ana Godoy - 03/10/17
#Salary
#1008
emp_number = gets.to_i
worked_hours = gets.to_i
amount_receive_per_hours = gets.to_f
salary = (worked_hours * amount_receive_per_hours)
puts "NUMBER = #{emp_number}"
puts "SALARY = U$ #{'%.2f' % salary}"
| true |
94ab843eb107482e482d8b02b102d5035fcba99e | Ruby | rr/rr | /spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb | UTF-8 | 5,037 | 2.78125 | 3 | [
"MIT"
] | permissive | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
module RR
module Expectations
describe ArgumentEqualityExpectation do
attr_reader :expectation
before do
@expectation = ArgumentEqualityExpectation.new([1, 2, 3], {})
end
describe "#expected_arguments" do
... | true |
5e2de448b7b4415f55c6b44bd7dd4e831f49761f | Ruby | CiscoZeus/fluent-plugin-field-flatten-json | /lib/fluent/plugin/out_field_multiregex.rb | UTF-8 | 3,624 | 2.671875 | 3 | [] | no_license | class String
def is_i?
/\A[-+]?\d+\z/ === self
end
def nan?
self !~ /^\s*[+-]?((\d+_?)*\d+(\.(\d+_?)*\d+)?|\.(\d+_?)*\d+)(\s*|([eE][+-]?(\d+_?)*\d+)\s*)$/
end
end
module Fluent
class OutputFieldMultiRegex < Fluent::Output
Fluent::Plugin.register_output('field_multiregex', self)
config_p... | true |
951b2fa3e0b5efbf28bbad488a3aa22199fc0ee3 | Ruby | chubeesah/labs | /01-05/number.rb | UTF-8 | 1,011 | 3.984375 | 4 | [] | no_license | require 'pry'
puts "Guess a Number between 1 and 100"
answer = gets.to_i
number = rand(1..100)
until number == answer do
if number > answer then puts "too low"
elsif number < answer then puts "too high"
end
answer = gets.to_i
end
puts "Correct"
#Question 1: 'cowsay', 'uptime', and 'trace'
#'cowsay' was an ent... | true |
afbd43b2922ce7b30f878fe7bbf7693db522baa9 | Ruby | tuykin/state_machine | /lib/graph.rb | UTF-8 | 583 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
class Graph
attr_reader :klass, :g
def initialize(klass)
@klass = klass
@g = GraphViz.new(:G, type: :digraph)
add_nodes
add_edges
add_start_node
end
private
def add_nodes
klass.states.each { |s| g.add_nodes(s.name.to_s) }
end
def add_edges
kl... | true |
495686546e5299a45c68bcf2e034eae61a549809 | Ruby | ahwkim/bewd_homework | /13-class-homework/dog_shelter/app/controllers/dog_controller.rb | UTF-8 | 561 | 2.625 | 3 | [] | no_license | class DogController < ApplicationController
def index
@dog = Dog.all
end
def show
@dog = Dog.find(params['id'])
end
def new
@dog = Dog.new
end
def create
puts params
@dog = Dog.new(dog_params)
if @dog.save # if the movie object saves.
redirect_to '/' # make a new request
... | true |
a6998c4f47aea12853bc7575a0b23fb754d58802 | Ruby | aaaaus/ruby-objects-has-many-lab-nyc-web-100818 | /lib/artist.rb | UTF-8 | 376 | 3.421875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Artist
attr_accessor :name, :songs
def initialize(name)
@name = name
@songs = []
end
def add_song(song)
@songs << song
song.artist = self
end
def add_song_by_name(song)
song = Song.new(song)
@songs << song
song.artist = self
end
def self.song_count
Song.all.length
end
end #cla... | true |
d767a3764fc4385f2ffa49627fceb8463c0819a7 | Ruby | alvaroriosdelgado/SemanaOnline9 | /E9CP1A1/ejercicio2.rb | UTF-8 | 250 | 3.578125 | 4 | [] | no_license | # Clase Car
class Car
attr_accessor :model, :year
def initialize(cualquiera1, cualquiera2)
@model = cualquiera1
@year = cualquiera2
end
end
car = Car.new('Camaro', 2016)
puts "Mi auto favorito es un #{car.model} del año #{car.year}!"
| true |
db364107a92c21bb0c7dac3d7f61c983ffdf030d | Ruby | McKid/hwwyncodeproj | /homework2/line.rb | UTF-8 | 56 | 2.625 | 3 | [] | no_license | def put_a_line()
puts "\n"
puts "/\\" * 40
puts "\n"
end | true |
99a032279212e6986476d70aa75adec6bcc44ac5 | Ruby | ClaudiaCode/Practice-GitHub | /homework1.rb | UTF-8 | 172 | 3.0625 | 3 | [] | no_license | # a = weight
# weight_pounds = weight_kilograms * 2
# a = "Claudia"
# a.reverse!
# puts a
# puts "Four score and seven years".length
a = 6
b = 4
puts a / b.to_i
| true |
3d7f1477b044eab5a39010c0d2b12bd27650ea8d | Ruby | timb-stud/distributed-application-architectures | /exercise2/task3/stockExchange.rb | UTF-8 | 370 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'lib/stockExchange.rb'
# Skript for starting StockExchanges
abort("Usage: #{__FILE__} ID MARKETPRICE") unless ARGV.size() == 2
HOST = 'localhost'
NAME = ARGV[0]
MARKETPRICE = ARGV[1]
puts "Initializing Stock Exchange #{NAME} with market price: #{MARKETPRICE}"
stockExchange = StockExch... | true |
52e00a332e512285cd1e255aefa390bc6f03ae8e | Ruby | jspaw/ruby-tests | /PassgenSpecs/pg3/pass3_spec.rb | UTF-8 | 359 | 2.546875 | 3 | [] | no_license | require File.join(File.dirname(__FILE__),'passgen')
describe "Passgen 3 Specs" do
it "should output 5 random 8 character passwords" do
passwordgen = Passgen.new
passwordgen.genPass(3).length.should == 3
passwordgen.genPass(25).length.should == 25
passwordgen.getPasses(3).length.should == 3
passwordgen.getP... | true |
c390bde9cc03041ebde7c1e5e635cf96fb631a79 | Ruby | fakecoinbase/MarceloSantamarcoslashRBCoin | /src/block.rb | UTF-8 | 698 | 2.96875 | 3 | [] | no_license | require 'digest'
require 'json'
class Block
attr_accessor :hash, :nonce, :id, :difficulty
def initialize(created_at, data, previous_hash, previous_id, difficulty)
@difficulty = difficulty
@id = previous_id+1
@nonce = 1
@created_at = created_at
@data = data
@pre... | true |
7ed226433f3edf801ef704613f56934dc6576992 | Ruby | yann021/thp_training | /formation/préparcour/ruby/exo_06.rb | UTF-8 | 567 | 3.203125 | 3 | [] | no_license |
number_of_hours_worked_per_day = 10
number_of_days_worked_per_week = 5
number_of_weeks_in_THP = 11
number_of_minutes_in_an_hour = 60
# si dessus la variable qui a été rajouter
puts "Travail : #{number_of_hours_worked_per_day * number_of_days_worked_per_week * number_of_weeks_in_THP}"
puts "Et en minutes ça fait : #{n... | true |
6803794a8566074ecd49ed9eadc56cfe2b02680a | Ruby | pujiepie/operators-dumbo-web-career-021819 | /lib/operations.rb | UTF-8 | 170 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def unsafe?(speed)
if speed <40
return true
elsif speed > 60
return true
else return false
end
end
def not_safe?(speed)
speed < 40 || speed > 60 ? true : false
end
| true |
0061204a9ca781081340abe2f57973e1905b181d | Ruby | yrosenberg1/Classwork_aA | /W4D4/lib/tower_hanoi.rb | UTF-8 | 378 | 3.15625 | 3 | [] | no_license | class TowersofHanoi
def initialize
@stacks = [[3, 2, 1],[], []]
end
def play
until won
puts "please enter a stack between 0 and 2 to move a disc from"
from = gets.chomp.to_i
puts "please enter a stack between 0 and 2 you want to put the disc"
... | true |
fa418bce45db1cc8006e1d8430431d9b589562f7 | Ruby | djanowski/redic-pool | /lib/redic/pool.rb | UTF-8 | 696 | 2.53125 | 3 | [
"Unlicense"
] | permissive | require "connection_pool"
require "redic"
class Redic::Pool
VERSION = "1.0.1"
attr :url
attr :pool
def initialize(url, options = {})
@url = url
@pool = ConnectionPool.new(size: options.fetch(:size, 10)) { Redic.new(url) }
@id = "redic-pool-#{object_id}"
end
def call(*args)
@pool.with do... | true |
5784ee4c36b61f9df0067f5758d8b6aecae18c1c | Ruby | Carpk/change_maker | /lib/change_maker/change.rb | UTF-8 | 765 | 3.46875 | 3 | [
"MIT"
] | permissive | class Change
def create_coins(amount, value)
coins = []
multiplier = amount / value
multiplier.times do
coins << value
end
coins
end
def break_total_with(breaking_amount, currency)
coins = []
currency.each do |break_value|
break_value = break_value.to_i
coins << cr... | true |
6308377f70af40779f314c2da68f66950e33777b | Ruby | Hameed11/Lab2 | /gameloop.rb | UTF-8 | 413 | 3.734375 | 4 | [] | no_license | count = 1
puts "randomly guess a number btw 1 and 100 :chance #{count}"
while count <= 5
guess = gets.chomp.to_i
number = rand(1..100)
if guess == number
puts "congrats u won"
puts number
elsif guess < number
puts "your guess is lower"
puts number
elsif guess > number
puts "your guess is higher"
puts number
end
cou... | true |
02c082d89e7edf83334ff53debe306ae3c5233be | Ruby | urbantumbleweed/urbantumbleweed | /w01/d02/Joshua_Lieberman/Class/bouncer.rb | UTF-8 | 191 | 3.984375 | 4 | [] | no_license | puts "How old are you?"
age = gets.chomp.to_i
if age < 18
puts "Get out!"
elsif age >= 21
puts "Welcome, you get a wristband"
else
puts "You can come in but you don't get a wristband"
end | true |
795f9d3defac10586e2357816573a6571729a3e5 | Ruby | kctiley/lrthw_exercises | /chapter_1/ex1.rb | UTF-8 | 327 | 3.53125 | 4 | [] | no_license | puts 'Hello World!'
puts 'Hello Again'
puts 'I like typing this.'
puts 'This is fun.'
puts 'Yay! Printing.'
# puts "I'd much rather you 'not'."
# Adding a "#" appears to create a comment for
# the programmer and no affect when running the program.
puts 'I "said" do not touch this.'
puts 'Making my script print another ... | true |
d81ebcc23972f94db1e55c0ae0edfdc4dde74306 | Ruby | Shilong678/bitmapeditor | /lib/bitmap_error.rb | UTF-8 | 384 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
module BitmapError
def row_error?(row, matrix_row, command)
if row > matrix_row
raise "Your command row: #{command} is greater than matrix table"
end
end
def column_error?(column, matrix_column, command)
if column > matrix_column
raise "Your command col... | true |
99591734e0ce9ed7c73ee543f1d0a871394ecc33 | Ruby | pedropreciado/algorithms | /LRUCache/firstname_lastname/lib/queue_with_max.rb | UTF-8 | 882 | 3.828125 | 4 | [] | no_license | # Implement a queue with #enqueue and #dequeue, as well as a #max API,
# a method which returns the maximum element still in the queue. This
# is trivial to do by spending O(n) time upon dequeuing.
# Can you do it in O(1) amortized? Maybe use an auxiliary storage structure?
# Use your RingBuffer to achieve optimal shi... | true |
ed3c0869a0842d54404e72daba77cfd8e4e42f34 | Ruby | ronakabhattrz/doctolib | /app/models/event.rb | UTF-8 | 2,442 | 2.90625 | 3 | [] | no_license | class Event < ApplicationRecord
before_save :complete_days_to_week_start
APPOINTMENT_INTERVAL = 30.minutes
AVAILABILITY_WINDOW = 7.days
def self.availabilities(start_date)
[].tap do |availabilities|
concerned_events = Event
.where("starts_at <= ?", start_date.end_of_day + AVAILABILITY_WINDOW)... | true |
8fa0e302cc3074e65e5ab78ae009064db697ffa8 | Ruby | ryo430000038/dorakue | /main.rb | UTF-8 | 3,073 | 3.5625 | 4 | [] | no_license | require_relative "./chara.rb"
#require_relative "./monster.rb"
#ゲーム開始
def game_start
p @yusha.cara
p @monster.cara
battle!
end
#戦い
def battle!
@count = 0
loop do
#ループ回数
@count += 1
puts "ターン#{@count}"
puts "--------------------------------------"
... | true |
2aa74db8d0740a71a2c8f087a1de78169005c622 | Ruby | svamja/project_euler | /p104-pandigital-fib.rb | UTF-8 | 1,994 | 3.40625 | 3 | [] | no_license | # PROBLEM STATEMENT
# The Fibonacci sequence is defined by the recurrence relation:
# Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
# It turns out that F541, which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all the digits 1 to 9, but not necessarily in or... | true |
ed5031b7074e1a83dfcad3adf3b9e9beb81ac8b2 | Ruby | keisuke713/original_code | /shopping_system/customer.rb | UTF-8 | 474 | 3.359375 | 3 | [] | no_license | class Customer
attr_accessor :shopping_bag
def initialize
@shopping_bag = []
end
def add_to_bag(store, products)
products.each do |product|
@shopping_bag << product
store.lineup.delete(product)
end
end
def replace_product(store, product)
@shopping_bag.delete(product)
store... | true |
04aad540a65e4ede353376db3ce0af8cc80a1146 | Ruby | department-of-veterans-affairs/caseflow | /app/services/aws_job_log_helper.rb | UTF-8 | 6,826 | 2.625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # frozen_string_literal: true
##
# Generates a pre-filtered AWS URL or AWS command to find logs for a Caseflow job
class AwsJobLogHelper
# Describes an ActiveJob.
class JobInfo
attr_reader :job_class, :msg_id, :start_time, :end_time
# @param job_class [Class, String] Name of the ActiveJob class.
# @... | true |
4b616a0f101387001d17a3627c92ae258dd6e976 | Ruby | ReserveBar1/spree_reservebar_core | /lib/spree/reservebar_core/retailer_selector_profit.rb | UTF-8 | 6,832 | 2.703125 | 3 | [] | no_license | # Class that defines the retailer selector whtih county based assignments
module Spree
module ReservebarCore
class RetailerSelectorProfit
# Base retailer selection on profits, and prefer in-state over out of state
# uses scoring mechanism to simplify the code
def self.select(order)
... | true |
81d91029cba81a31b1c12f28837eed8c8fe328a1 | Ruby | Gurjot-Sidhu/ruby-enumerables-generalized-map-and-reduce-lab-nyc04-seng-ft-012720 | /lib/my_code.rb | UTF-8 | 351 | 3.46875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Your Code Here
def map(array)
new = []
i = 0
while i < array.length do
new.push(yield(array[i]))
i+=1
end
new
end
def reduce(array,starting_value = nil)
if starting_value
sum = starting_value
i = 0
else
sum =array[0]
i = 1
end
while i < array.length
sum = yield(sum,arr... | true |
2fdee71cb9901fddbcd040cc0a6959160bb113f4 | Ruby | nonafiona/triangle-test | /nice.rb | UTF-8 | 805 | 3.96875 | 4 | [] | no_license | class Triangle
def initialize(sides)
@sides = sides
end
def valid?
if @sides.count == 3
puts "count correct"
if @sides[0] != 0 && @sides[1] != 0 && @sides[2] != 0
puts "no side = 0"
if (check_sides(@sides[0], @sides[1], @sides[2]) || c... | true |
0060a63f3b79c0f44992969c1827620f25b161ff | Ruby | vsai911/Contact-List-App | /contact.rb | UTF-8 | 1,277 | 3.25 | 3 | [] | no_license | require_relative 'contact_database'
require 'pry'
class Contact
attr_accessor :name, :email, :id, :phonenumbers
def initialize(name, email,id,phonenumbers)
@name = name
@email = email
@id = id
@phonenumbers = phonenumbers
end
def to_s
@name + @email
end
## Class Methods
clas... | true |
6a016bbd45cd3e2d83fc9af0ac43aaceb878b040 | Ruby | Pyro-tech/pyro | /lib/assets/Ruby復習問題_入門_中級/復習問題_入門編/62.rb | UTF-8 | 699 | 3.796875 | 4 | [
"MIT"
] | permissive | puts <<EOS
以下の空欄(a)~(c)を書き換えて、プログラムを完成させましょう。
---正解となる実行結果---
任意の整数を入力してください。
-4
入力された数値は負の数です。
任意の整数を入力してください。
5
入力された数値は正の数です。
任意の整数を入力してください。
0
入力された数値は0です。
---ここまで---
EOS
# puts "任意の整数を入力してください。"
# num = gets.to_i
# puts "入力された数値は負の数です。" if num (a) 0
# puts "入力された数値は0です。" if num (b) 0
# puts "入力された数値は正の数です。" ... | true |
29bb240ed26ac60b43652b90a391c868181ae9cc | Ruby | medert/test-flight | /spec/lib/airplane_refactor_spec.rb | UTF-8 | 1,719 | 3.234375 | 3 | [] | no_license | require_relative "../../lib/airplane_refactor"
require 'rspec'
#This is the refactored RSpec testing using 'let'
describe Airplane_2 do
let(:plane) { Airplane_2.new('cesna', 10, 150, 8) }
describe "#initialization" do
it "creates new Airplane" do
expect(plane.type).to eq('cesna')
expect(plane.ho... | true |
a2bf3a9e301a0d56c9bca1cce9ec366872864c27 | Ruby | xpepper/goose_game | /player.rb | UTF-8 | 1,692 | 3.625 | 4 | [] | no_license | class Player
attr_reader :name
BRIDGE_SQUARE = 12
VICTORY_SQUARE = SQUARE_COUNT = 63
def initialize(name)
@name = name
@positions = [0]
end
def move(step)
@step = step
new_position = current_position + @step
@bounced = should_bounce?(new_position)
new_position = bounces(new_posit... | true |
59b75ac1c7207af7f166639c290f6db0145a6dfc | Ruby | RBGeomaticsRob/lrthw | /ex19a.rb | UTF-8 | 460 | 3.734375 | 4 | [] | no_license | def func1(arg1,arg2)
puts "This the response of the function #{arg1} and #{arg2}"
end
#1
func1(20,30)
#2
func1(func1("a","b"),func1("c","d"))
#3
print "What is the first argument?"
apple = gets.chomp
print "What is the first argument?"
orange = gets.chomp
func1(apple,orange)
#4
func1(20%5,3*9)
#5
func1("a","#{'cool'}... | true |
64fe64cae96a71e16475550a3c8330765ce442a1 | Ruby | rcollins2867/homework | /QuestionsGame.rb | UTF-8 | 1,605 | 4.15625 | 4 | [] | no_license | #QuestionsGame!
#Set Question & Answer Variables to store the questions and answers
question1 = "Is the sky blue? [Y/N]"
question2 = "Are you as big as a beluga whale? [Y/N]"
question3 = "Is there more than one way to skin a cat? [Y/N]"
question4 = "Does a bear shit in the woods? [Y/N]"
question5 = "Is your guess as go... | true |
9c54bb314ad5f045138ad8f39920a77bb3aeb654 | Ruby | coderhs/hack_scripts | /fizz_buzz.rb | UTF-8 | 97 | 2.84375 | 3 | [] | no_license | # Ruby online for fizzbuzz problem
1.upto(100){|n|puts"#{[:Fizz][n%3]}#{[:Buzz][n%5]}"[/.+/]||n}
| true |
c1a3bd2f566d94736f040d6689b27c2a2723e6a0 | Ruby | kokamoto/paper-airplane | /lib/ellipse.rb | UTF-8 | 380 | 3.125 | 3 | [] | no_license | module PaperAirplaneGeom
class Ellipse < PaperAirplaneGeom::Shape
attr_accessor :a, :b
def initialize(centroid,a,b)
@centroid = centroid
@a = a
@b = b
@area = self.calculate_area(centroid,a,b)
end
#
# see: http://en.wikipedia.org/wiki/Ellipse#Area
#
def self.calcu... | true |
7a6f8b25c580b5e1880bb8a3aef11081c85c5271 | Ruby | rbaddam/circuit-oneops-1 | /components/cookbooks/artifact/test/unit/spec/chef_rest_spec.rb | UTF-8 | 1,348 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # Unit tests for circuit-oneops-1/components/cookbooks/artifact/libraries/chef_rest.rb
require '../../libraries/chef_rest'
require 'file_size_test'
describe Chef::REST do
lib = Chef::REST.new
#------------------- Test for calculate_parts method -------------------#
# Max file size
max_size = 1000000000000
... | true |
60333badabf2776825e22674c9242e538d7866b0 | Ruby | AustinPaley/ruby-intro-to-arrays-lab-prework | /lib/intro_to_arrays.rb | UTF-8 | 383 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
array = []
array
end
def array_with_two_elements
array = [1, 2]
array
end
def first_element(array)
array[0]
end
def third_element(array)
array[2]
end
def last_element(array)
array[-1]
end
def first_element_with_array_methods(array)
array.first
end
def last_element_with_array_methods(arra... | true |
1c2163660f392143c847cd0b51945a1118a62a0d | Ruby | arturhoo/alien | /lib/alien/alienreader.rb | UTF-8 | 5,030 | 3.28125 | 3 | [
"BSD-2-Clause"
] | permissive | =begin rdoc
=Alien Ruby RFID Library
==alienreader.rb
AlienReader is a fairly lightweight class that inherits from AlienConnection. It provides methods that map attributes to reader functions like readername, readertype, etc, and exposes the execute method to send/receive an arbitrary command to the reader.
This clas... | true |
1149214a94ec82ceac6ede8524f18582ad8549b2 | Ruby | mixassio/movies_OOP | /spec/movie_spec.rb | UTF-8 | 1,136 | 3.03125 | 3 | [] | no_license | require_relative '../movie.rb'
require_relative '../movie_collection.rb'
describe Movie do
let(:movie_data) { ['http://imdb.com/title/tt0111161/?ref_=chttp_tt_1', 'The Shawshank Redemption', '1994', 'USA', '1994-10-14', 'Crime,Drama', '142 min', '9.3', 'Frank Darabont', 'Tim Robbins,Morgan Freeman,Bob Gunton'] }
l... | true |
c725548147c13b3f024c22da8431e00918490992 | Ruby | JonMaia/Replicables | /src/Branch.rb | UTF-8 | 275 | 3.015625 | 3 | [
"MIT"
] | permissive | class Branch
attr_accessor :branch_name
def initialize(branch_name,obj)
@branch_name = branch_name
@obj = obj
end
def method_missing(msg, *args, &block)
if @obj.respond_to? msg
@obj.send(msg, *args, &block)
else
super
end
end
end
| true |
6644d8f5c1a0a09c6857313996b11e089b2ec8a9 | Ruby | rterrabh/rdf | /dataset/sass/lib/sass/media.rb | UTF-8 | 3,111 | 2.78125 | 3 | [
"MIT"
] | permissive | module Sass::Media
class QueryList
attr_accessor :queries
def initialize(queries)
@queries = queries
end
def merge(other)
new_queries = queries.map {|q1| other.queries.map {|q2| q1.merge(q2)}}.flatten.compact
return if new_queries.empty?
QueryList.new(new_queries)
end
... | true |
8fee5f82e4a171b2a3a05454057f1c39ae4e6d43 | Ruby | mtahoppe/MTBuild | /lib/mtbuild/dsl.rb | UTF-8 | 2,078 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | module MTBuild
module DSL
# Defines a Workspace
def workspace(workspace_name, workspace_folder, &configuration_block)
MTBuild::Workspace.new(workspace_name, workspace_folder, &configuration_block)
end
# Defines an ApplicationProject
def application_project(application_name, project_folder... | true |
4244fd25ecc1af9b6de1c84c2a69d80fa905c821 | Ruby | luong-komorebi/dotfiles-2 | /bin/git-up | UTF-8 | 975 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
#
# Usage: git-up
# git-reup
#
# Like git-pull but show a short and sexy log of changes
# immediately after merging (git-up) or rebasing (git-reup).
#
# Inspired by Kyle Neath's `git up' alias:
# http://gist.github.com/249223
#
# Stolen from Ryan Tomayko
# http://github.com/rtomayko/dotfiles/... | true |
39a3a8ebcd852874c29270cf9a57552ebadc2766 | Ruby | avalanche123/mastermind | /spec/mastermind/codemaker_spec.rb | UTF-8 | 374 | 2.9375 | 3 | [] | no_license | describe Codemaker do
let(:length) { [2, rand(10)].max }
let(:max) { [2, rand(10)].max }
let(:codemaker) { Codemaker.new(length, max) }
it "makes code of a pre-defind length" do
codemaker.make.size.should eq(length)
end
it "makes code with each number less than the max" do
codemaker.make.split('')... | true |
f4975d0a56bdb1045670518f4ca30cbc4d3a39fa | Ruby | JArthurJohnston/Timekeeper_API | /test/models/activity_test.rb | UTF-8 | 4,822 | 2.90625 | 3 | [] | no_license | require_relative 'model_test_case'
class ActivityTest < ModelTestCase
test 'activity initializes with start and end' do
expectedStart = DateTime.new(2015, 1, 1, 2, 2, 2)
expectedEnd = DateTime.new(2015, 1, 1, 3, 3, 3)
activity = Activity.new(start_time: expectedStart, end_time: expectedEnd)
assert... | true |
6ec600112ab938e09df3ddc5f0d32853c641d707 | Ruby | filip373/design-patterns | /22_visitor/xml_export_visitor.rb | UTF-8 | 343 | 2.84375 | 3 | [] | no_license | # this is a concrete visitor implementation
require_relative "./visitor"
class XmlExportVisitor < Visitor
def visit_dot(dot)
puts("Exporting dot: #{dot}...")
end
def visit_circle(circle)
puts("Exporting circle: #{circle}...")
end
def visit_rectangle(rectangle)
puts("Exporting rectangle: #{rec... | true |
3e79d239d78a18fd7eb32e71a55c8ffb9c3f47aa | Ruby | kendradaren/ruby-include | /tests/test_user.rb | UTF-8 | 1,880 | 2.8125 | 3 | [
"MIT"
] | permissive | require "colorize"
require "digest"
# require all files in modules and classes
Dir.glob(File.join(".", "{modules,classes}", "**", "*.rb"), &method(:require))
require "test/unit"
class TestUser < Test::Unit::TestCase
def test_initialize
assert_not_nil(User.new("TestPerson"))
end
def test_name_accessor
... | true |
48fbc0053d9af3a690482467d8cda919b0d436fa | Ruby | LrdVnz/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 238 | 3.4375 | 3 | [] | no_license | #write your code here
def add(a, b)
a + b
end
def subtract(a, b)
a - b
end
def sum(array)
total = 0
i = 0
while i < array.length
total = total + array[i]
i = i + 1
end
total
end
def multiply (a, b)
a * b
end
| true |
dce1f3e34a58a4c350bab1bd4124699dc7a0e922 | Ruby | shaiguitar/patchmaster | /lib/patchmaster/trigger.rb | UTF-8 | 729 | 3.03125 | 3 | [] | no_license | module PM
# A Trigger performs an action when it sees a particular array of bytes.
# Instruments have zero or more triggers. The action is a symbol that gets
# sent to PM::PatchMaster.
#
# Since we want to save them to files, we store the text representation as
# well.
class Trigger
attr_accessor :bytes, :block, :t... | true |
5cf8ea1f6fa77073ba7cb46677137685a2c38084 | Ruby | eric-an/square_array-v-000 | /square_array.rb | UTF-8 | 231 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
squared_array = []
array.each do |element|
squared_array << element ** 2
end
squared_array
end
# def square_array(array)
# array.collect! do |element|
# element ** 2
# end
# end | true |
63da0bd2d962da8e8f45f996ae7eff40eccce7ed | Ruby | abowler2/foundations | /easy6/cute_angle.rb | UTF-8 | 590 | 3.34375 | 3 | [] | no_license | DEGREE = "\xC2\xB0"
MIN_PER_DEGREE = 60
SECONDS_PER_MIN = 60
SECONDS_PER_DEGREE = MIN_PER_DEGREE * SECONDS_PER_MIN
def dms(float)
total_seconds = (float * SECONDS_PER_DEGREE).round
degrees, remaining_seconds = (total_seconds.divmod(SECONDS_PER_DEGREE))
minutes, seconds = remaining_seconds.divmod(SECONDS_PER_MIN)... | true |
bd3efafcbb171b93a69d5a2fa07236a352e4dc65 | Ruby | DeidaraC/echo | /test.rb | UTF-8 | 1,656 | 2.75 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require "open3"
class TestEcho < Minitest::Test
CFLAGS = "-std=c99 -Wall"
`cc #{CFLAGS} echo.c -o echo.out`
def test_basic_usage
stdout_str, stderr_str, status = Open3.capture3("./echo.out hello, world!")
assert_equal "hello, world!\n", stdout_str
assert_equal 0, status.ex... | true |
a3151657ef2786332651b244c69c6e0ac563b3b8 | Ruby | jeanlazarou/calco | /lib/calco/engines/calculator_builtin_functions.rb | UTF-8 | 374 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'date'
require 'time'
require 'calco'
module Calco
module CalculatorBuiltinFunctions
def YEAR date
date.year
end
def TODAY
Date.today
end
def DATEVALUE text
Date.parse(text)
end
def TIMEVALUE text
Time.parse(text)
end
def ... | true |
3af0e55328e709722da7d07e5e6d509e474e87c1 | Ruby | wwq0327/ruby-code | /rubyprog/bigger_smaller.rb | UTF-8 | 164 | 3.71875 | 4 | [] | no_license | a = 20
if a >= 10 then
print("bigger\n")
end
if a <=9 then
print("smaller\n")
end
10.times {
puts "hello, world!"
}
def hello
puts "Hello, Ruby."
end
hello() | true |
556ea8f6c52cf4511204b3245180ca32af62d855 | Ruby | Jake0Miller/potluck | /test/potluck_test.rb | UTF-8 | 2,200 | 3.09375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/dish'
require './lib/potluck'
class CardTest < Minitest::Test
def setup
@potluck = Potluck.new("7-13-18")
@salad = Dish.new("Couscous Salad", :appetizer)
@pizza = Dish.new("Summer Pizza", :appetizer)
@meatballs = Dish.new("Cocktail Me... | true |
487c75fff10ee6fb1e8ddaaeaa2b4237d8cb7295 | Ruby | alethiaQ/oo-tic-tac-toe-online-web-ft-071519 | /lib/tic_tac_toe.rb | UTF-8 | 1,855 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class TicTacToe
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 initialize
@board = Array.new(9, " ")
end
def display_board
puts " #{@board[0]} | #{@board[1]} | #{@board[2]} "
puts "-----------"
puts " #{@board[3]} | #{@board[4]... | true |
f4764c6ba8de07916dd6ec7867ab10cd69041793 | Ruby | Lenocam/ad_board | /lib/tasks/reprocess_images.rake | UTF-8 | 410 | 2.546875 | 3 | [] | no_license | desc "Reprocesses images after adding new versions in file uploader for CarrierWave"
task reprocess_images: :environment do
puts "Reprocessing Images. Chill out for a couple minutes. ¯\_(ツ)_/¯"
i = 0
Image.all.each do |image|
image.file.recreate_versions!
image.save!
i = i + 1
puts "#{i} Images R... | true |
0b55568a6f0a1a12a2eb8df552a095597450b59c | Ruby | Zarthus/rtables | /lib/rtables/tablebuilder.rb | UTF-8 | 1,295 | 3.15625 | 3 | [
"MIT"
] | permissive | module RTables
class TableBuilder
def initialize
@table_header = []
@table_content = []
@columns = 0
@rows = 0
end
attr_reader :table_header, :table_content, :columns, :rows
def add_column(name)
return false if column_exist?(name)
fail TableFormatError, 'Cannot a... | true |
86d1e4665ed325c34cb328b789fe42cdb2426639 | Ruby | adamyanalunas/danger-swiftlint | /lib/danger_plugin.rb | UTF-8 | 4,665 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'json'
module Danger
# Surface your SwiftLint JSON report in pull requests.
# If no report exists, one will be created using the existing SwiftLint install.
# Results are displayed in a markdown table.
#
# @example Run report
#
# # Runs SwiftLint if necessary and processes the report usi... | true |
503a1c01108c73f842eff05f43e59ba77c281509 | Ruby | cheungth25/deli-counter-web-060517 | /deli_counter.rb | UTF-8 | 615 | 4.09375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def line(array)
if array.size == 0
return puts "The line is currently empty."
end
string = "The line is currently:"
array.each_with_index do |customer, spot_in_line|
string.concat(" #{spot_in_line+1}. #{customer}")
end
return puts string
end
def take_a_number(curr_line, pers... | true |
a089496d98625a2e6ff0de72aee1c669f6abdea6 | Ruby | ianmcknnn/programming-univbasics-3-build-a-calculator-lab-wdc01-seng-ft-060120 | /lib/math.rb | UTF-8 | 324 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def addition(num1, num2)
num1.to_i + num2.to_i
end
def subtraction(num1, num2)
num1.to_i - num2.to_i
end
def division(num1, num2)
num1.to_i / num2.to_i
end
def multiplication(num1, num2)
num1.to_i * num2.to_i
end
def modulo(num1, num2)
num1.to_i % num2.to_i
end
def square_root(num)
Math.sqrt(num.to_i)
... | true |
acf6f426d7a12428fa79dc5aced127c9fd37e1bc | Ruby | pepetox/pillacosas | /app/models/dataset.rb | UTF-8 | 1,101 | 2.546875 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
class Dataset < ActiveRecord::Base
def to_csv(options = {})
arana(self)
end
end
def arana (miDataset)
require 'rubygems'
require 'nokogiri'
require 'open-uri'
#Si hay html araño el html sino mira la url
html_doc = Nokogiri::HTML(miDataset.html)
html_doc = Nokogiri::HTML(... | true |
e563457396fed477665f8a34365580b191a4203e | Ruby | sarabrandao21/betsy | /app/models/order_item.rb | UTF-8 | 833 | 2.75 | 3 | [] | no_license | class OrderItem < ApplicationRecord
belongs_to :product
belongs_to :order
validates :quantity, presence: true,
numericality: { greater_than: 0 }
def increment_quantity(qty) #product show page
self.quantity += qty.to_i
self.save
end
def set_quantity(qty) #inside of cart
... | true |
b089b8f4f34b7d93d0f9d4c7ab865c4c5f0d5289 | Ruby | dnlserrano/codename-m | /lib/segments/options.rb | UTF-8 | 691 | 3.203125 | 3 | [
"MIT"
] | permissive | require_relative "segment"
require_relative "../display"
module Segments
class Options < Segment
attr_accessor :options
def initialize(title:, description:, options:, final: false)
super(title: title, description: description, final: final)
@options = options
end
def next_segment_id
... | true |
b670864ab710b71c5afb53f6bbbca9fda354a73f | Ruby | tayasu/FizzBuzzTestCode | /fizz_buzz_test.rb | UTF-8 | 480 | 2.953125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'test/unit'
require './fizz_buzz'
class FizzBuzzTest < Test::Unit::TestCase
def setup
@fizz_buzz = FizzBuzz.new
end
def test_at1
r = @fizz_buzz.at 1
assert_equal(1, r)
end
def test_at3
r = @fizz_buzz.at 3
assert_equal('fizz', r)
end
def test_at5
... | true |
42f7ddc6841518bc80e1d63f1e92c42ac25f8ce3 | Ruby | kevniu/phase-0 | /week-4/errors.rb | UTF-8 | 7,380 | 4.4375 | 4 | [
"MIT"
] | permissive | # Analyze the Errors
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# --- error -------------------------------------------------------
=begin
"Screw you guys " + "I'm going home." = cartmans_phrase
=end
# This error was analyzed in the README file.
# --- error --------------... | true |
d4c89fab60a0412d0848f7d0af2a428c6a366589 | Ruby | markus851/eddy | /lib/eddy/models/loop/repeat.rb | UTF-8 | 1,651 | 2.9375 | 3 | [
"MIT"
] | permissive | module Eddy
module Models
module Loop
# Data form a single loop iteration.
class Repeat
# An array of Segments and/or other Loops.
# This is used as a template to populate `content`.
# @return [Array<Eddy::Models::Segment, Eddy::Models::Loop::Base>]
attr_reader :compon... | true |
9bea097e2ec68929fd3b9ac2f6735c374c11c100 | Ruby | trevorwood/Diversions | /worthy_snippets/exception.rb | UTF-8 | 809 | 3.515625 | 4 | [] | no_license | def bunkmethod
mystring = "Chew on this!"
garbage #garbage doesn't exist
mystring.callitman
rescue NoMethodError => e:
puts "Problem: "+e.to_s
rescue Exception:
puts "you got problems in bunkmethod, son"
end
bunkmethod
#more specific exceptions help diagnose issues without tissues
def dance_a_jig
"I'm a dancin... | true |
7a0dd2629d5488aa31966282f85a7347d007a84f | Ruby | dlt/SVD-Recommender | /vendor/plugins/streamlined/lib/streamlined/helpers/header_helper.rb | UTF-8 | 1,132 | 2.890625 | 3 | [
"MIT"
] | permissive | # By default, headers are based on the class name (e.g. 'Edit Person')
# If your model class implements a name method,
# you will get that instead (e.g. 'Edit John Doe')
module Streamlined::Helpers::HeaderHelper
def render_show_header
render_header
end
def render_edit_header
render_header("Ed... | true |
1eb9e60f7047bf420e0eb7a8d9ee4923aa403db0 | Ruby | Kingkunta1/meal-choice-dumbo-web-career-042219 | /meal_choice.rb | UTF-8 | 103 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def meal_choice(meal_choice = "meat")
return meal_choice
end
# passed into it and defaults to meat.
| true |
7f86a6c0eed154a7dcf8402333bb03454b81f16c | Ruby | akimochi/test-ruby | /Recipe1.rb | UTF-8 | 1,033 | 2.609375 | 3 | [] | no_license | require 'open-uri'
require 'httpclient'
require 'net/ftp'
#2017年6月10日 Ruby勉強会
class Recipe1
def urlTest
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}
end
def httpTest
client = HTTPClient.new
client.debug_dev = $stderr # デバッグ情報を標準エラー出力に
query = {'q' => 'goo... | true |
31cc61e4c3e2622c06bbe09ddfdfc6415b6a77dc | Ruby | thekindofme/death_to_lcs | /death_to_lcs.rb | UTF-8 | 2,904 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'dotenv'
require 'slop'
require 'pry'
require 'aws-sdk'
class DeathToLcs
VERSION='0.1'
def self.run
load_env
opts = parse_args
puts '-------------------------------------'
puts 'Launch Configurations deleted'
puts '-------------------------------------'
puts lc_deleter.delete_unus... | true |
e46a0a0aff545425a19538abfa6fd0ba774a9159 | Ruby | rotblauer/openbound | /lib/whoami.rb | UTF-8 | 89 | 2.546875 | 3 | [] | no_license | module Debug
def whoAmI?
"#{self.type.name} (\##{self.id}): #{self.to_s}"
end
end | true |
3aa4d4146d32a0f82929ded6d74014ff2d030040 | Ruby | chrisbrickey/useful_code | /recursion.rb | UTF-8 | 2,503 | 3.734375 | 4 | [] | no_license | def factorial(n)
return n if n == 1
n * factorial(n - 1)
end
# p factorial(4)
def reverse(str)
return str if str.length <= 1
str[-1] + reverse(str[0...-1])
end
# p reverse("hello")
def nth_row_of_pascal(n)
current_row = [1]
return [1] if n == 0
prev_row = nth_row_of_pascal(n - 1)
(prev_row.length... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.