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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f74546f402c4830c934e2929bea1fcc99827c584 | Ruby | albertbahia/wdi_june_2014 | /w03/d04/michael_ross/morningex/luhn_ex.rb | UTF-8 | 579 | 3.28125 | 3 | [] | no_license | # def valid_card?(num)
# new_num = num.to_s.split(" ")
# new_string = new_num.each { |number| number % 2 == 0 }
# new_string.even
# end
#
def valid_card?(card_number)
holder = []
split_numbers = card_number.to_s.split('').reverse
split_numbers.each_with_index do |num, index|
index % 2 == 0 ? holder ... | true |
affdadb4ff9d9b0c431296e4f6f3fa2886a89c96 | Ruby | ddouangkesone/Udemy-Ruby | /Section-5/62/If-elseif.rb | UTF-8 | 393 | 3.984375 | 4 | [] | no_license | # color = "Yellow"
# if color == "red"
# puts "Red is rad"
# elsif color == "Green"
# puts "Green is great!"
# elsif color == "Yellow"
# puts "Yay for yellow!"
# end
# if color == "Green"
# puts "Green is great"
# end
number = 55
if number < 25
puts "Thats a low number!"
elsif number < 50
puts "Thats a ... | true |
612b190851c48ee4c81b1927990cc10cbdb404b9 | Ruby | fission-mailed/building_blocks_ruby | /cipher.rb | UTF-8 | 729 | 3.75 | 4 | [] | no_license | def caesar_cipher(phrase, shift = 1)
alphabet = ("a".."z").to_a
coded_phrase = ""
phrase_array = phrase.split("")
phrase_array.each do |letter|
if alphabet.include?(letter)
new_index = alphabet.index(letter) + shift
coded_phrase += alphabet[new_index % alphabet.length]
elsif alphabet.include?(letter... | true |
bc302d5d848a6ce2c42ad99222c6f56068c379a1 | Ruby | seanyeh/seanyeh.com | /helpers/util.rb | UTF-8 | 1,540 | 2.921875 | 3 | [] | no_license | require "open3"
def gen_icon_item(icon, url, subtitle, desc = "")
desc_html = desc == "" ? "" : "<p>#{desc}</p>"
return %{
<a class='list-item #{icon}' href='#{url}'>
<div>
<div class='icon'></div>
<div class='right'>
<div class='subtitle'>#{subtitle}</div>
... | true |
7fa025f486f14a8e09dfd9e482fd1ac85ef11a09 | Ruby | onyi/W4D4 | /spec/models/user_spec.rb | UTF-8 | 1,498 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
subject(:uesr) do
FactoryBot.build(:user,
email: "hi@hello.world",
password: "123456",
user_name: "helloworld")
end
describe "Validations" do
it { should validate_presence_of(:email) }
it { should validate_presence_of(:... | true |
bf7cc1790b2c60187494d3bddab37126352cae33 | Ruby | TJQKAs/battle_ships_september | /lib/battleships_web.rb | UTF-8 | 1,522 | 2.59375 | 3 | [] | no_license | require 'sinatra/base'
require_relative 'game'
require_relative 'board'
require_relative '../game_setup'
class BattleshipsWeb < Sinatra::Base
set :views, proc {File.join(root, '..', 'views')}
$game = Game.new
$player = Player.new
get '/' do
erb :index
end
post '/player_registered' do
@player_1_n... | true |
d4c4c894425f33f75624d6da93c033ba0f98a7b8 | Ruby | lukyans/scheduling | /spec/helpers/events_helper_spec.rb | UTF-8 | 511 | 2.625 | 3 | [] | no_license | require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the EventsHelper. For example:
#
# describe EventsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
... | true |
898318e1007694892011fd05b6cfdb08e313fe83 | Ruby | vimtaku/perfect_ruby | /15/hoge.rb | UTF-8 | 207 | 2.8125 | 3 | [] | no_license | require "bundler"
Bundler.require
sample_value = 'sample value'
class Poke
def hoge
moge = "mogemoge"
binding.pry
p "hogehoge"
moga = "mogamoga"
binding.pry
end
end
Poke.new.hoge
| true |
4d3128e39c921bf4f9c357d826b500d4ac1d2478 | Ruby | jake08bennett/methods-quiz2 | /methods_quiz2_test.rb | UTF-8 | 1,099 | 2.53125 | 3 | [] | no_license | require 'minitest/autorun'
require "minitest/reporters"
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative 'methods_quiz2'
class MethodsQuizTest < MiniTest::Test
def setup
@m = Class.new do
include MethodsQuiz2
end.new
end
def test_without_doubles
assert_equal 9, @m.witho... | true |
21dc8cf55d47468fdc150d5f1e5191feeb7be64c | Ruby | beccapearce/till_tech_test | /spec/till_spec.rb | UTF-8 | 617 | 2.984375 | 3 | [] | no_license | require_relative '../lib/till.rb'
require_relative 'spec_helper.rb'
describe Till do
let (:till) {Till.new}
describe '#initialize' do
it 'is created with an empty basket' do
expect(till.basket).to eq([])
end
end
describe "#add_to_basket" do
it 'finds an item and adds it to basket' do
... | true |
b57a447d38fdd71c7bd6340f744b01d9619e2aeb | Ruby | abebinder/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,476 | 3.953125 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
total = 0
arr.each do |val|
total += val
end
return total
end
def max_2_sum arr
if arr.length == 0
return 0
elsif arr.length == 1
return arr[0]
else
arr.sort!{ |x,y| y <=> x }
return arr[0] + arr[1]
end
e... | true |
e24c040e506f9f9a9bae78ccb4f26563843807db | Ruby | brucew/homecca | /lib/utility.rb | UTF-8 | 982 | 2.984375 | 3 | [] | no_license | module Utility
# class Skills
# attr_accessor :a
#
# STOP_WORDS = ['an', 'the', 'or', 'and', 'service']
#
# def initialize(skills)
# self.a = skills.to_s.gsub(',', ' ').gsub(/[^[:alpha:]|[:space:]]/, '').split(%r{\s+})
# self.a.delete_if {|s| s.length < 2}
# self.a = self.a - STOP_WORDS
# en... | true |
556c7ad62d3ef2ec0ace3dcd2d6abbdd0731e652 | Ruby | joelbarton-io/rb130_139 | /lesson_1/reduce.rb | UTF-8 | 3,547 | 4.59375 | 5 | [] | no_license | =begin
Implement a method mirroring the behavior of Enumerable#reduce
Method should take at least 1 argument, the array we need to reduce
Method should take an optional second argument representing default value for the accumulator
Enumerable#reduce:
- alias for #inject
- "fold" or "accumulate" a collection into 1 obj... | true |
fe43110d177598261cd19bae64313bd9364603b3 | Ruby | ykz1/LS_101_foundations | /4_ruby_collections/5_selection_transformation.rb | UTF-8 | 1,583 | 4 | 4 | [] | no_license | # ---
puts
puts '---'
produce = {
'apple' => 'Fruit',
'carrot' => 'Vegetable',
'pear' => 'Fruit',
'broccoli' => 'Vegetable'
}
def select_fruit(hsh)
counter = 0
arr = hsh.to_a
output = []
loop do
if arr[counter][1] == 'Fruit'
output << arr[counter]
end
counter += 1
break if coun... | true |
8cee15f858faf587ff8d5be2762f7f29c752c363 | Ruby | spencerdavis2000/GCD | /natural_logarithm.rb | UTF-8 | 847 | 3.59375 | 4 | [] | no_license | =begin
Spencer Davis
A program that generates thes e^x sequence.
From calculus the number e = 2.71828...
The number secquence is like this:
2, (3/2)^2, (4/3)^3, (5/4)^4, (6/5)^5, ...., (1 + 1/n)^n, ....,
as the limit approaches infinity, the resulting number becomes e
=end
require 'pry'
#NOTE: this 1/n.to_r meth... | true |
adb720602afb4a0c033e25ee09e61a3d46a38b1c | Ruby | attack/weather_object | /spec/attributes/zone_spec.rb | UTF-8 | 978 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative '../spec_helper'
require 'virtus'
module WeatherObject
class TestClass
include Virtus.model
attribute :timezone, Attribute::Zone
end
RSpec.describe Attribute::Zone do
context 'when setting to nil' do
it 'initializes a Data::NullZone' do
model = TestClass.new(timezone: ... | true |
03d0df6b7ec4da4603f982505da71cb8cd7a6046 | Ruby | iamdanielglover/oo-relationships-practice-london-web-career-012819 | /app/models/crowdfunding/user.rb | UTF-8 | 668 | 2.90625 | 3 | [] | no_license | class User
attr_accessor :username
@@all = []
def initialize(username)
@username = username
@@all << self
end
def self.all
@@all
end
def user_projects
Project.all.select { |project| project.user == self }
end
def pledges
Pledge.all.select { |pledge| pledge.pledger == self }
... | true |
a355b96dda722595300bba7d69bd3207d983bbe0 | Ruby | ewen-lbh/fsorg | /lib/fsorg.rb | UTF-8 | 13,542 | 2.78125 | 3 | [
"Unlicense"
] | permissive | require "colorize"
require "set"
require "shellwords"
require "yaml"
PERMISSIONS_PATTERN = /[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+/
def d(thing)
p thing
return thing
end
class Fsorg
attr_accessor :data, :document, :document_path, :root_directory
def initialize(root_directory, data, document, absolute... | true |
a072bd147765292df0653633ce2b645d5438314a | Ruby | JMZV/desafioruby2 | /patron/patron2.rb | UTF-8 | 220 | 3.28125 | 3 | [] | no_license | # Escribe patron **.. hasta n caracteres
num = ARGV[0].to_i
num -= 1
pat = ""
for i in (0..num)
if (i%4 == 0) || (i%4 == 1)
pat += '*'
else
pat += '.'
end
end
puts "#{pat}" | true |
e338cb8428b077e1b2a80bdbce3fc0159e1e379b | Ruby | syedatique/w2_weekend_hotel | /hotel.rb | UTF-8 | 747 | 3.1875 | 3 | [] | no_license | class Hotel
attr_reader :name, :postcode, :number_of_room, :guest, :available_room
def initialize(options={})
@name = options[:name]
@postcode = options[:postcode]
@number_of_room = options[:number_of_room] | 3
# @rooms = options[:number_of_room].times.map { Room.new }
@available_room=option... | true |
27519998d3998076072afcfedcf05a7686d1f712 | Ruby | Xaiana/101_Programming_Foundations | /lesson_5/Practice_Problems9_16.rb | UTF-8 | 1,785 | 3.4375 | 3 | [] | no_license | arr = [['b', 'c', 'a'], [2, 1, 3], ['blue', 'black', 'green']]
arr.map do |array|
array.sort!{|a, b| b <=> a}
end
p arr
new_hahs = [{a: 1}, {b: 2, c: 3}, {d: 4, e: 5, f: 6}].map do |hash|
incremented_hash = {}
hash.each do |key, integer|
incremented_hash[key] = integer +1
end
incremented_hash
end
p new_... | true |
b33d7dd6200d37e9ee6ef20eac707fc5296dbbb4 | Ruby | traciechang/algorithm-problems | /remove_linked_list_elements.rb | UTF-8 | 1,353 | 3.765625 | 4 | [] | no_license | # Remove all elements from a linked list of integers that have value val.
# Example:
# Input: 1->2->6->3->4->5->6, val = 6
# Output: 1->2->3->4->5
# Definition for singly-linked list.
# class ListNode
# attr_accessor :val, :next
# def initialize(val)
# @val = val
# @next = nil
# end
# en... | true |
9e185194b3c05768f949f03e52eef0d368d7de06 | Ruby | stifitman/getova | /getova/data_extraction/lib/data_extraction/data_extractors/complus/led/gate_xml_to_rdf.rb | UTF-8 | 9,315 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'json'
require 'nokogiri'
require 'open-uri'
require 'rdf'
require 'rdf/ntriples'
require 'sparql'
require 'pathname'
require 'elasticsearch'
class CompanyExtractor
def cleanHtml(html)
if html.respond_to? ('text') #is a nokogiri node
html.text.chomp.gsub(/\s+/, " ")
else
html.gsub(%r{</?... | true |
8d41881c2aea9a5f63460676bcfd20662644b913 | Ruby | Chew/HQTriviaRB | /lib/hqtrivia/badges.rb | UTF-8 | 4,293 | 2.875 | 3 | [] | no_license | # The Badges Class. A User, but their badges.
class HQTrivia::Badges
# Initialize a new user. Get all their stats. Relax.
# @param id [Integer] the ID of the user.
# @param key [String] an API key, to get info.
# @raise [HQTrivia::Errors::InvalidKey] if the api key is invalid
# @raise [HQTrivia::Errors::Inval... | true |
be6f7c990e7bd11bca9a7279a1d501aed4d006e7 | Ruby | hhemanth/search-implementation | /spec/attribute_index_spec.rb | UTF-8 | 1,706 | 2.671875 | 3 | [] | no_license | require 'rspec'
require 'attribute_index'
RSpec.describe AttributeIndex do
let(:attribute_index) { AttributeIndex.new(index_name, attribute_name)}
let(:index_name) { 'Organisation' }
let(:attribute_name) { 'name' }
context "#index_name" do
it 'returns index_name' do
expect(attribute_index.index_name... | true |
44bb70c9896b098279549c30df436fb0c63ccde5 | Ruby | jlblcc/mdTranslator | /lib/adiwg/mdtranslator/writers/iso19110/classes/class_telephone.rb | UTF-8 | 3,887 | 2.609375 | 3 | [
"Unlicense"
] | permissive | # ISO <<Class>> CI_Telephone
# writer output in XML
# History:
# Stan Smith 2013-08-12 original script.
# Stan Smith 2014-05-14 reorganized for JSON schema 0.4.0
# Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
# Stan Smith 2015-06-22 replace global ($response) with passed in object ... | true |
9838e04feb62327754c90985fa37ea5c42b2d8e7 | Ruby | haifeng/freemium | /lib/freemium/credit_card.rb | UTF-8 | 7,085 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'active_merchant/billing/expiry_date'
# stores the credit card information locally (card type, expiration, display number, zip_code)
module Freemium
module CreditCard
DB_FIELDS=[:zip_code, :address1, :address2, :city, :state, :card_type, :name]
VIRTUAL_FIELDS=[
# Essential attributes for a val... | true |
5d8843d1eb1e3f76d027ac19996ee88fcc61771a | Ruby | jtlai0921/PG20249_example | /PG20249_sample/Ruby268-SampleProgram-UTF8/Ch2/sample056-02.rb | UTF-8 | 86 | 2.53125 | 3 | [] | no_license | p "\t 哈哈 \r\n".lstrip #=> "哈哈 \r\n"
p "\t 哈哈 \r\n".rstrip #=> "\t 哈哈"
| true |
3630e1b6074f4a546aba741f6877959d118b46ac | Ruby | iskodirajga/retrodot | /lib/chat_ops/commands/add_timeline_entry_command.rb | UTF-8 | 1,454 | 2.703125 | 3 | [
"ISC"
] | permissive | module ChatOps::Commands
class AddTimelineEntryCommand < ChatOps::Command
setup do
# This regex is a little tricky. We want to match these:
#
# timeline hello world
# timeline 20 hello world
#
# but not this:
#
# timeline 20
#
# because the latter... | true |
6295a902fd850881e05f342e875362892d9d389a | Ruby | santosh-1987/RubyScripts | /visitor.rb | UTF-8 | 1,095 | 3.765625 | 4 | [] | no_license | class CarElement
def accept(visitor)
raise NotImpelementedError.new
end
end
module Visitable
def accept(visitor)
visitor.visit(self)
end
end
class Wheel < CarElement
include Visitable
attr_reader :name
def initialize(name)
@name = name
end
end
class Engine < CarElement
include Visitabl... | true |
9d813776720355468f1fc2676fecd37764984d70 | Ruby | Intro-to-CS-Bootcamp/HW | /ch09/ask.rb | UTF-8 | 178 | 3.328125 | 3 | [] | no_license | # Use `return` to exit from the loop
# Three cases for an answer: yes, no, or anything else
def ask(question)
while true
### Fill in with your code ###
end
end | true |
31060cb9a0085164c8704108f2387b13b11a7c88 | Ruby | connoroffutt/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 145 | 3.46875 | 3 | [] | no_license | def add(x, y)
return x + y
end
def subtract(x, y)
return x - y
end
def sum(array)
sum = 0
array.each { |x| sum += x }
return sum
end
| true |
1a4bcd34ab671253067e310cba65942f6da21e28 | Ruby | OmarAlSughayer/ProgrammingLanguages | /08/hw8tests.rb | UTF-8 | 1,361 | 3.34375 | 3 | [] | no_license | # University of Washington, Programming Languages, Homework 8
# Omar Adel AlSughayer, 1337255
require 'minitest/autorun'
require_relative './hw8assignment'
# unit tests for Polynomial
class TestPoly < Minitest::Test
def test_all
@x = "x".asPolynomial
@y = "y".asPolynomial
# basic to_s
assert_equal("Po... | true |
a4a47ffdecfc951873b3273e211d89ade1bfb37b | Ruby | wuhlcom/autotest | /experiment/class_method_metaclass/class_superclass.rb | UTF-8 | 398 | 3.109375 | 3 | [] | no_license | module TM
R1 = "1"
def meth1
R1
end
end
class M2
include TM
end
require 'pp'
M2.new.meth1
# pp Class.instance_methods.sort
p Class.class
p Object.class
p Module.class
p Array.class
p M2.class
p TM.class
p TM.class.class
p "="*30
p Object.superclass
p Class.superclass
p Module.superclass
p "="*30
p Array.sup... | true |
0a3bb89d08028f0730ba3ee0b7df8fb6b489711a | Ruby | AnkDos/Ruby-files | /split.rb | UTF-8 | 286 | 3.90625 | 4 | [] | no_license | puts "WELCOME"
puts "Enter a Paragraph"
=begin
sentence=gets.chomp
words=sentence.split(" ")
length=words.length
puts "The Number of words in given phrase is #{length}"
=end
def wordcount(sentence)
words=sentence.split(" ")
return words.length
end
input=gets
puts "#{wordcount(input)}" | true |
0da3f337eb82ced58411e2126aa69bebba1f3e3f | Ruby | Homies886/ruby-intro-to-arrays-lab-online-web-prework | /lib/intro_to_arrays.rb | UTF-8 | 810 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
[]
end
def array_with_two_elements
["meat", "potatoes"]
end
def first_element(first_element)
["Welcome to New York", "Blank Space", "Style", "Out of The Woods"][0]
end
def third_element(third_element)
["Welcome to New York", "Blank Space", "Style", "Out of The Woods"][2]
end
def la... | true |
691231223b18bd463d0f5104c0a98b5c7fae8b6a | Ruby | BendeBoissieu/Custom-Bicycle | /db/seeds.rb | UTF-8 | 927 | 2.609375 | 3 | [] | no_license | Order.all.destroy_all
Bicycle.all.destroy_all
Wheel.all.destroy_all
Rim.all.destroy_all
Color.all.destroy_all
puts "empty"
black = Color.create(name: "black")
blue = Color.create(name: "blue", hexadecimal: "#134984")
green = Color.create(name: "green", hexadecimal: "#40904c")
rim_black = Rim.create(color_id: black.id)... | true |
312dc92bdb5f6215c61003e221d846f11e21ed05 | Ruby | dpmontooth/pre_ruby_exercises | /loops_iterators/useful_loop.rb | UTF-8 | 91 | 3.265625 | 3 | [] | no_license | # useful loop with break keyword for loop exit
i = 0
loop do
i += 1
puts i
break
end | true |
b8a52686a1b2223f5d92d6fc0cdafef9c546ad34 | Ruby | rhys117/rails-reminders-callnotes | /app/helpers/reminders_helper.rb | UTF-8 | 967 | 2.75 | 3 | [
"MIT"
] | permissive | module RemindersHelper
def sort_by_completed(reminders)
complete_reminders, incomplete_reminders = reminders.partition { |r| r.complete }
incomplete_reminders + complete_reminders
end
def inverse_complete_value(reminder)
return 'incomplete' if reminder.complete
return 'complete' if !reminder.co... | true |
66f6dea471dfac63ce1f78a22ba1e98efd3da4d1 | Ruby | sa2taka/rootine | /vendor/bundle/ruby/2.6.0/gems/ruby-graphviz-1.2.4/examples/theory/tests.rb | UTF-8 | 2,003 | 3.171875 | 3 | [
"MIT",
"GPL-2.0-only",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later"
] | permissive | $:.unshift( "../../lib" )
require 'graphviz'
require 'graphviz/theory'
g = GraphViz.digraph( "G", :path => "/usr/local/bin" ) do |g|
g.a[:label => "1"]
g.b[:label => "2"]
g.c[:label => "3"]
g.d[:label => "4"]
g.e[:label => "5"]
g.f[:label => "6"]
# g.a << g.a
g.a << g.b
g.a << g.d
(g.a << g.f)[:we... | true |
2ae82a6e8e2fa0b6d2acd928ff21c1d652050704 | Ruby | littlecourage/W4D3 | /Chess/knight-king.rb | UTF-8 | 1,246 | 3.359375 | 3 | [] | no_license | require_relative 'pieces'
module Stepable
def moves
diffs = self.move_diffs
legal_moves = []
current_pos = self.position
diffs.each do |diff|
check_pos = [current_pos[0] + diff[0], current_pos[1] + diff[1]]
if self.board.valid_pos?(check_pos)
... | true |
a65e96952e05347b76c99520b60a05944675d10e | Ruby | taskrabbit/smyte | /lib/smyte/util.rb | UTF-8 | 613 | 2.8125 | 3 | [
"MIT"
] | permissive | module Smyte
class Util
class << self
def label_interesting?(name, options)
return true unless options
return true unless options[:labels]
return true if options[:labels].empty?
pieces = name.split(":")
options[:labels].each do |check|
if check.is_a?(Strin... | true |
317217ff6a71aa4526efe4fe88875f5c14c83867 | Ruby | giroma/ruby_fundamentals1 | /exercise5.rb | UTF-8 | 318 | 3.921875 | 4 | [] | no_license | distance = 0 #declare 0 value outside of the loop
while true
puts "Do you want to walk or run?"
walk_or_run = gets.chomp
if walk_or_run == "walk" || walk_or_run == "w"
distance += 1
elsif walk_or_run == "run" || walk_or_run == "r"
distance += 5
end
puts "Distance from home is #{distance} km"
end
| true |
78a41d99dec984da83b56a4a738a3d4a408c1385 | Ruby | ub/euler6_counterexample_search | /lib/hypothesis.rb | UTF-8 | 1,790 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'active_record'
class Hypothesis < ActiveRecord::Base
belongs_to :parent, class_name: 'Hypothesis'
has_many :subgoals, inverse_of: :parent, class_name: 'Hypothesis', foreign_key: 'parent_id'
has_one :refutation, dependent: :destroy
scope :unrefuted, -> { left_outer_joins(:refutation).where('refutati... | true |
6658e94a00d319404740a0e5309578ed38997fa6 | Ruby | Alien-AV/hoplite-solver | /WithoutTDD/moving_object.rb | UTF-8 | 279 | 2.78125 | 3 | [] | no_license | class MovingObject
attr_accessor :type, :containing_hex
def initialize(type)
@type = type
end
def to_s
"object: #{@type} in #{@containing_hex}"
end
WARRIOR_TYPE = 4
ARCHER_TYPE = 5
BOMBER_TYPE = 6
WIZARD_TYPE = 7
BOMB_TYPE = 8
PLAYER_TYPE = 9
end | true |
acfcf6ec5f3cc8adce441b9ab943a1a1229ee9f1 | Ruby | nigohiroki/mybandit | /bandit.rb | UTF-8 | 4,334 | 2.84375 | 3 | [] | no_license | require './arm.rb'
class Bandit
#初期値
CPC = 1.5
INITIAL_CTR = { "arm0" => 0.7, "arm1" => 0.8, "arm2" => 0.6, "arm3" => 0.5 }
#INITIAL_CTR = { "arm0" => 0.5, "arm1" => 0.5, "arm2" => 0.5, "arm3" => 0.5 }
ARM_NUM = 4
MAX_IMP = 10_000_000
STEP_IMP = 100_000
def epsilon_greedy
eps... | true |
2f8efb25750a05b848f2757a9978f9f6fa00985a | Ruby | dkam/cacofonix | /lib/cacofonix/core/code.rb | UTF-8 | 2,649 | 3.265625 | 3 | [
"MIT"
] | permissive | # coding: utf-8
module Cacofonix
class Code
attr_reader :key, :value, :list, :list_number
# Note re: key type. For backwards compatibility, code keys that are
# all-digits are passed around in this gem as Integers.
#
# The actual code list hashes have string-based keys for consistency. If
... | true |
791849c74ea07d4e5f890c4293985bbebb3d9147 | Ruby | SUMmaro400ex/WyncodeHWAnswers | /CatInTheHat.rb | UTF-8 | 198 | 3.390625 | 3 | [] | no_license | cat = Array.new(100, true)
i=j=0
while i < 100
while j < 100
cat[j] = !cat[j]
j+=i+1
end
j=i+=1
end
cat.each do |hat|
puts "Cat number #{i-99} does not have a hat on!" unless hat
i+=1
end | true |
d657bbe03d5a267b97b49474ae4723c66090f008 | Ruby | shinh/test | /test_fiber.rb | UTF-8 | 127 | 3.0625 | 3 | [] | no_license | def f(i,j)
Fiber.yield
i < 30000 ? f(i+j,j) : 0
end
f=Fiber.new{p f(0,1)}
#p f(0,1)
while true
p 'hoge'
f.resume
end
| true |
741c0d3fd770db173904c46d8b1b474d6a59806e | Ruby | accessd/awesome-report | /lib/session.rb | UTF-8 | 382 | 2.8125 | 3 | [] | no_license | # frozen_string_literal: true
require 'date'
class Session
attr_reader :user_id, :session_id, :browser, :time, :date
def initialize(row)
fields = row.split(COMMA_SEP)
@user_id = fields[1]
@session_id = fields[2]
@browser = fields[3].upcase!
@time = fields[4]
@date = fields[5]
end
def... | true |
7f3b25295750445cfd3dcc21755fc31f2a338eac | Ruby | Hiro-o-ai/ruby-basic | /lib/lesson4.rb | UTF-8 | 826 | 3.65625 | 4 | [] | no_license | def greeting(contry)
return "contryを入力してください" if contry.nil?
if contry == "japan"
"こんにちは"
else
"hello"
end
end
def calc_with_break
numbers = [1, 2, 3, 4, 5, 6]
target = nil
numbers.shuffle.each do |n|
target = n
return if n.even?
end
target * 10
end
numbers = [1, 2, 3, 4, 5]
i = 0
wh... | true |
c84ce433454357e014e855f298bacb2b1684e077 | Ruby | jiikko/bf | /lib/bf/scalping/modules/low_tech_validator.rb | UTF-8 | 2,220 | 2.703125 | 3 | [
"MIT"
] | permissive | module BF
class Scalping
module LowTechValidator
def valid?
unless base_valid?
return false
end
# 複数エンキューされていると同じタイミングで爆死する可能性があるので、
# 同時実行できる数を1つに制限する
# if BF::ScalpingWorker.doing?
# return false
# end
unless under?
BF.... | true |
609f536958eddeb94477df1443e04043cec20563 | Ruby | nanenj/ruby-cookie-clicker | /cookie_clicker.rb | UTF-8 | 5,442 | 2.953125 | 3 | [] | no_license | class CookieGenerator
attr_accessor :name, :description, :rate, :cost, :created_at, :generators
@@generators ||= []
def self.descendants
ObjectSpace.each_object(Class).select { |klass| klass < self }
end
def self.all
@@generators
end
def self.rate
@rate
end
def self.cost
@cost
e... | true |
f6a9f0fefff3b1e43549134b047279fa12861a93 | Ruby | doolin/design-patterns-in-ruby | /ch3/ch3.rb | UTF-8 | 4,161 | 3.125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rspec/autorun'
require 'pry'
# The Template method
class Report
def initialize
@title = 'monthly report'
@text = [ 'Things are going', 'really, really well']
end
# I would have named this simply 'output', or possibly
# 'write'.
def output_report
report = ""
re... | true |
cf4d6765f9c89e06942a8a0afba655ed328e85f0 | Ruby | gonzamvita/RubyLessons | /Day 1/reduce.rb | UTF-8 | 364 | 3.421875 | 3 | [] | no_license | require 'pry'
def reduceCity
cities = ["miami", "madrid", "barcelona", "holaquetalestas"]
cities.reverse!
longestNameCity = ""
cities.reduce do |first, city|
if city.length > first.length
longestNameCity = city
first = city
else
longestNameCity = first
first = first
end
e... | true |
0eb29b9ed57238a46cbb76b614747d39c227cf5d | Ruby | rewinfrey/hireology-challenge | /part2/question2/role/role.rb | UTF-8 | 1,463 | 2.78125 | 3 | [] | no_license | require 'part2/question2/role/contexts/create_role'
require 'part2/question2/role/contexts/create_roles_for_organization'
require 'part2/question2/role/contexts/remove_role'
require 'part2/question2/role/contexts/remove_roles_for_user'
require 'part2/question2/role/contexts/roles_for_organization'
require 'part2/questi... | true |
fc0bdbee397e7c492fd0c4f5b14d0def92451a7e | Ruby | ciousiaocing/leetcode-ruby | /algorithms/climbing_stairs.rb | UTF-8 | 830 | 4.21875 | 4 | [] | no_license | # https://leetcode.com/problems/climbing-stairs/
#
# You are climbing a stair case. It takes n steps to reach to the top.
#
# Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
#
# Note: Given n will be a positive integer.
#
#
# Example 1:
#
# Input: 2
# Output: 2
# Explan... | true |
afa4ef1de861bb902609cda94fc1f1f7cc974548 | Ruby | adrianoavelino/projeto-ruby-puro-onebitcode | /token.rb | UTF-8 | 617 | 2.59375 | 3 | [] | no_license | class Token
def create_token token
File.open('./.token', 'w') do |line|
line.puts(token)
end
end
def validate_token token
begin
url = 'https://translate.yandex.net/api/v1.5/tr.json/getLangs?ui=en&key=' + token
json = RestClient.post url, {}
... | true |
1742fe39c47d8134c0c5112822a221af3c318659 | Ruby | rsfarkas/todo-ruby-basics-001-prework-web | /lib/ruby_basics.rb | UTF-8 | 363 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
return num1/num2
end
def assign_variable(value)
return value
end
def argue (name = "Bob")
return name
end
def greeting (a, name)
a = "Hi"
return a, name
end
def return_a_value (value = "Nice")
return value
end
def last_evaluated_value(value = "expert")
return value
end
def pizz... | true |
64bf661d1a4201cce18bcfcd3fab1354004fa278 | Ruby | rodblackney/LRTHW | /Chapter-42/ex42.rb | UTF-8 | 1,321 | 4.09375 | 4 | [] | no_license | ## Animal is-a object look at the extra credit
class Animal
end
## Dog is-a Animal
class Dog < Animal
def initialize(name)
## Dog has-a name
@name = name
end
end
## Cat is-a Animal
class Cat < Animal
def initialize(name)
## Cat has-a name
@name = name
end
end
## is-a Person
class Person
def initializ... | true |
4a985c37e952212434d695692ff18bb410dae4db | Ruby | pyama86/ruby-gof | /struct/composite/composite_equipment.rb | UTF-8 | 573 | 3.0625 | 3 | [] | no_license | class CompositeEquipment < Equipment
attr_accessor :equipment
def add(equipment)
@equipment ||= []
@equipment << equipment
end
def create_iterator
@equipment
end
def net_price
total = 0
create_iterator.each do |item|
total += item.net_price
end
total
end
end
class Chas... | true |
ba063e80f8f43c99d4245896fe50c31b0c697110 | Ruby | C4mz0r/web-server | /tiny-webbrowser.rb | UTF-8 | 1,512 | 3.3125 | 3 | [] | no_license | require 'socket'
require 'colorize'
require 'json'
CRLF = "\r\n"
host = 'localhost'
port = 2000
path = "/index.html"
def communicate(host, port, request)
socket = TCPSocket.open(host, port) # connect to the server
socket.print(request) # send request to the server
response = socket.read # read the respon... | true |
d7a4b7a28ba835f9baf99d751c7937a021054d40 | Ruby | jade-genevieve/oystercard | /spec/oyster_spec.rb | UTF-8 | 739 | 2.984375 | 3 | [] | no_license | require "oyster"
describe Oystercard do
it "creates an instance of oystercard" do
expect(subject).to be_an_instance_of Oystercard
# it {is_expected.to be_an_instance of Oystercard}
end
describe "#initialize" do
it "initializes an Oystercard with a balance of 0" do
expect(subject.balance).to eq ... | true |
1fd7e39d2412e1d258bca0b7576cf5c2b1673196 | Ruby | mendokusai/gameproject | /City/village_factory.rb | UTF-8 | 968 | 3.140625 | 3 | [
"MIT"
] | permissive | require_relative '../map'
require_relative 'city_factory'
require_relative '../Events/shop_event'
require_relative '../Events/inn_event'
require_relative '../Events/guild_event'
require_relative '../Events/temple_event'
# A medium size city factory with the basic necessity for game play purposes.
# Inn, shop, temple a... | true |
409afe7b724e01755f460097e0c1a3436f89667c | Ruby | AlexWaller1/Palisades-Mall-Scraping | /lib/nickelodeon_shows/tv_show.rb | UTF-8 | 522 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | #Will take info from the Scraper Class
#Will initialize instance variables of key tv show attributes
#Will take in class variable @@all as an array
class NickelodeonShows::TvShow
attr_accessor :name, :year, :position
@@all = []
def initialize(name = nil, year = nil, position = nil)
@name = name... | true |
de325b4eaa1d6e8dc01413de7b2cc95844bf5f06 | Ruby | pezra/resourceful | /lib/resourceful/abstract_form_data.rb | UTF-8 | 296 | 2.578125 | 3 | [
"MIT"
] | permissive | module Resourceful
class AbstractFormData
def initialize(contents = {})
@form_data = []
contents.each do |k,v|
add(k, v)
end
end
def add(name, value)
form_data << [name.to_s, value]
end
protected
attr_reader :form_data
end
end
| true |
f6aeff9468176ebfa368992c22f38f6d25692458 | Ruby | Psixodelik/rails-project-lvl1 | /lib/hexlet_code/form_elements.rb | UTF-8 | 1,824 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
module HexletCode
# Rendering Form Element such as input, select
class FormElements
attr_reader :form_option, :default_element_type
attr_accessor :rendered_elements
def initialize(data)
@form_option = data
@rendered_elements = []
@default_element_type = ... | true |
ab45948bfd7bd71bba8881e30569bbb3b4a2d6aa | Ruby | Kalok9990/sparta-oop-recap | /livingOrganism/animal.rb | UTF-8 | 539 | 3.625 | 4 | [] | no_license | require_relative "./living_organism"
class Animal < LivingOrganism
def self.traits
puts 'Animals can breathe, eat, drink, speak and pro-create'
end
def breathe
puts "Animals can breathe"
end
def eat
puts "Animals can eat"
end
def drink
puts "Animals can drink"
end
def speak
p... | true |
1d2b10e28d6b1819960ab77680f349b3272bda51 | Ruby | aosalias/ruby_battleship | /test_battleship.rb | UTF-8 | 1,585 | 2.984375 | 3 | [] | no_license | require_relative "battleship.rb"
class TestBattleship
def self.test_coords
ship = Ship.new(1,1,"h",3)
assert(ship.coords == [[1,1], [1,2], [1,3]])
end
def self.test_hit_hit
ship = Ship.new(1,1,"h",3)
assert ship.hit(1,1)
end
def self.test_hit_miss
ship = Ship.new(1,1,"h",3)
asser... | true |
1ce11686d7f438d4d35a5790e20438794a48bdd2 | Ruby | Daso/CalculatorTDD | /Calculadora.rb | UTF-8 | 272 | 3.40625 | 3 | [] | no_license | #Calculadora.rb
class Calculadora
def suma(a , b)
a + b
end
def resta(c, d)
c - d
end
def multiplica(e, f)
e * f
end
def no_es_cero(g)
g != 0
end
def divide (numerador, denominador)
no_es_cero(denominador) ? numerador / denominador : 0
end
end | true |
bb1ddc7c69f6af45e2acccc29331df706196ce7a | Ruby | kelsin/18xx | /lib/engine/action/sell_shares.rb | UTF-8 | 904 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # frozen_string_literal: true
require_relative 'base'
require_relative '../share_bundle'
module Engine
module Action
class SellShares < Base
attr_reader :entity, :bundle, :swap
def initialize(entity, shares:, share_price: nil, percent: nil, swap: nil)
super(entity)
@bundle = ShareBu... | true |
f23202c43a40303f9ddba1a89eb605723f456423 | Ruby | ahoward/tagz | /lib/tagz.rb | UTF-8 | 14,007 | 2.546875 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
unless defined? Tagz
# core tagz functions
#
module Tagz
require 'cgi'
def Tagz.version()
'9.10.0'
end
def Tagz.description
<<-____
tagz.rb is generates html, xml, or any sgml variant like a small ninja
running across the backs of a herd of gi... | true |
1b6e02d64547003d9da483140d9c6332c1f19719 | Ruby | harshitamukesh/ruby_set3 | /inheritance.rb | UTF-8 | 1,610 | 4.46875 | 4 | [] | no_license | # The user wants to print his address.
# An address consist of three part. streetAddress + cityName + countryName.
# The user now wants to print his completeAddress.
# fix the below code such that.
# 1. When the user checks for countryName, he should get the country name.
# 2. When the user checks for cityName, he s... | true |
6be3430679bee66c1fd8af03e79d28c9bbe9895f | Ruby | goobering/snakes_and_ladders | /specs/game_spec.rb | UTF-8 | 2,239 | 3.28125 | 3 | [] | no_license | require 'Minitest/autorun'
require 'Minitest/rg'
require_relative '../game'
require_relative '../player'
require_relative '../dice'
require_relative '../track'
require_relative '../ladder.rb'
require_relative '../snake.rb'
class TestGame < Minitest::Test
def setup()
@player_1 = Player.new("Steve")
@player_2 = Pl... | true |
3c66443226f16798220402be1cbecfbbe79e744b | Ruby | cypriss/mouth | /test/sucker_test.rb | UTF-8 | 1,524 | 2.578125 | 3 | [
"MIT"
] | permissive | $LOAD_PATH.unshift 'test'
require 'test_helper'
require 'mouth/sucker'
class SuckerTest < Test::Unit::TestCase
def setup
end
def test_storing_count
r = Mouth::Sucker.new
r.store!("happening:3|c")
assert_equal ({"default.happening" => 3}), r.counters.values.first
end
def test_stor... | true |
3a59820d7f7613638741f7548cd509818a2a09a5 | Ruby | BobFromAccounting/Ruby-Projects | /firstprogram.rb | UTF-8 | 396 | 4.0625 | 4 | [] | no_license | print "What's your first name?"
first_name = gets.chomp
first_name.capitalize!
print "What's your last name?"
last_name = gets.chomp
last_name.capitalize!
print "What city are your from?"
city = gets.chomp
city.capitalize!
print "What state/province are you from? (I.e. TX)"
state = gets.chomp
state.upcase!
print "Y... | true |
045bd590f765ec7f96103a777d23faabc92d79e1 | Ruby | idynkydnk/enumerable_methods | /my_all?_spec.rb | UTF-8 | 529 | 3.21875 | 3 | [] | no_license | require "enumerable_methods"
describe Enumerable do
before :all do
@array = [1,2,3,4]
end
describe ".my_all?" do
context "given an array" do
it "responds to the array" do
expect(@array).to respond_to(:my_all?)
end
it "returns true if block is true for all elements" do
... | true |
1fde32744233a264a2436b141b8eb3d320a87e5c | Ruby | DevenClingman/Notes | /ruby_notes/ruby_prompt_user.rb | UTF-8 | 281 | 4.09375 | 4 | [] | no_license | # How to prompt user
#Prompt user
puts "What is your name?"
#get user input
name = gets.chomp # I can also use gets but I will usually use gets.chomp
#difference between gets and gets.chomp
#gets has a \n character at the end of the input and the gets.chomp gets rid of it.
| true |
98aa07f3606df152d85e35b100e44736a294e9da | Ruby | nowviskie/PraxisExercises | /RubytheHardWay/35a.rb | UTF-8 | 3,057 | 4.125 | 4 | [] | no_license | # a game by Vic Sansing, age 8.
def prompt()
print "Your turn! What do you do? > "
end
def huh()
puts "\nI don't understand you. Please try again."
end
def gold_room()
puts "\nYou've found Poseidon's treasure cave! How many treasures will you take?"
def prompt()
print "Type a number. > "
end
prompt; n... | true |
c72e71da591988d8eeaa2e0a27f0b6f1306e8420 | Ruby | lbvf50mobile/til | /20230511_Thursday/20230511.rb | UTF-8 | 946 | 3.234375 | 3 | [] | no_license | # Leetcode: 1035. Uncrossed Lines.
# https://leetcode.com/problems/uncrossed-lines/
# = = = = = = = = = = = = = =
# Accepted.
# Thanks God, Jesus Christ!
# = = = = = = = = = = = = = =
# Runtime: 167 ms, faster than 33.33% of Ruby online submissions for Uncrossed
# Lines.
# Memory Usage: 215 MB, less than 66.67% of Ruby... | true |
913753f5f34f696d1542ec5a51b56113665b1170 | Ruby | fgalassi/kata-ruby-lcd | /test/tc_table.rb | UTF-8 | 2,384 | 3.03125 | 3 | [] | no_license | require "test/unit"
require "table.rb"
class TestTable < Test::Unit::TestCase
def test_empty_table
t = Table.new
assert_equal([], t.columns)
assert_equal([], t.rows)
end
def test_empty_row
t = Table.new([])
assert_equal([[]], t.rows)
assert_equal([], t.columns)
end
def test_row
t = Table.new([1, 2... | true |
385760bf9155c036b9ec82544fc9b0d0c3f33ad6 | Ruby | leon-joel/eratos | /eratos.rb | UTF-8 | 2,093 | 3.515625 | 4 | [] | no_license | # require 'active_support/core_ext/string/strip'
module PrimeNumber
# 素数探索(エラトステネスの篩)
# @param limit 探索する範囲(最大の整数)
# @return [Array] 素数配列
def self.eratosthenes(limit)
# 探索リスト
search_list = Array(2..limit)
# p search_list
# 探索結果(素数配列)
primes = []
# 最後に見つかった素数がコレを越えたら探索終了(残りは全て素数)
... | true |
6499de12959a05794f358db6f344e2ec9478a133 | Ruby | seasarorg/s2container.ruby | /s2cgi/vendor/s2validate/lib/seasar/validate/context.rb | UTF-8 | 3,788 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
#--
# +----------------------------------------------------------------------+
# | Copyright 2005-2008 the Seasar Foundation and the Others. |
# +----------------------------------------------------------------------+
# | Licensed under the Apache License, Version 2.0 (the "License");... | true |
f01de2079d720bcd24258864668c2d95a23a0af3 | Ruby | awwebdev2020/SeatCheck | /app/models/restaurant.rb | UTF-8 | 2,106 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: restaurants
#
# id :bigint not null, primary key
# name :string not null
# address :string not null
# city :string not null
# state :string not null
# zip :integer not ... | true |
00fb6871e38d235f2db0523ef01a3e65a5ed1da0 | Ruby | ghprince/evernote_challenges | /evernote1.rb | UTF-8 | 2,241 | 4.09375 | 4 | [] | no_license | #!/usr/bin/env ruby
# Implement a circular buffer of size N. Allow the caller to append, remove and list the contents of the buffer. Implement the buffer to achieve maximum performance for each of the operations.
# The new items are appended to the end and the order is retained i.e elements are placed in increasing ord... | true |
a4da6ead83d4705ad8c4041d9da9d656958f5cf6 | Ruby | malbazaz/looping-while-until-bootcamp-prep-000 | /lib/while.rb | UTF-8 | 117 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_while
levitation_force = 6
while levitation_force<10
puts "Wingardium Leviosa"
levitation_force += 1
end
end
| true |
4eade8212a6454caa284bddbffdf7cfbb1218173 | Ruby | SaraMc12/Lightings_tic_tac_toe | /tic_tac_toe_test.rb | UTF-8 | 425 | 2.65625 | 3 | [
"MIT"
] | permissive | gem 'minitest', '>= 5.0.0'
require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/unit'
require_relative 'tic_tac_toe'
class GoodbyeTest < Minitest::Test
def test_say_goodbye_cyril
arrange = "cyril"
act = GoodBye.goodbye arrange
assert_equal "goodbye cyril!", act
end
def test_print_g... | true |
c1140670c4f6f186b11a17ac47711e3d9d6fbe5b | Ruby | fernandokokocha/new_catan | /lib/catan/entities/card.rb | UTF-8 | 414 | 3.421875 | 3 | [] | no_license | # frozen_string_literal: true
class Card
attr_reader :owner
NO_OWNER = :no_owner
def initialize(owner: NO_OWNER)
@owner = owner
end
def give(player)
@owner = player
end
def no_owner?
@owner == NO_OWNER
end
def owned_by?(player)
@owner == player
end
def victory?
true
en... | true |
7ff12b8cc30c5b9665efd3247dd4edf03aead94a | Ruby | jdenen/dow | /lib/dow/cli.rb | UTF-8 | 944 | 3.203125 | 3 | [
"MIT"
] | permissive | require_relative "converter"
require_relative "version"
require "optparse"
options = {}
OptionParser.new do |opts|
opts.banner = "Find the day of the week. Usage: dow [options]"
opts.on('-m', '--month', 'Month to convert') do
options[:month] = ARGV.slice!(0)
end
opts.on('-d', '--day', 'Day to convert') ... | true |
d81f14e415dc3949f9ac03e462ff803cdad732ec | Ruby | tlulu/ConNextor | /app/models/feedback.rb | UTF-8 | 1,008 | 2.640625 | 3 | [] | no_license | class Feedback < ActiveRecord::Base
RATING_MAX = 7
RATING_MIN = 0
RATING_NA = 0
belongs_to :user
belongs_to :user_to_task
validates_presence_of :user, :user_to_task, :rating_completion, :rating_quality, :rating_motivation, :rating_communication, :body
validates_numericality_of :rating_completion, :rati... | true |
51010ae72fc0adc2a98730895e2ed58c6baa2002 | Ruby | daveduthie/slang | /ruby/p002tree.rb | UTF-8 | 758 | 3.90625 | 4 | [] | no_license | class Tree
attr_accessor :children, :node_name
def initialize(name, children=[])
@children = children
@node_name = name
# §
# when we instantiate the tree,
# @node_name is set to "Ruby"
# and @children is set to an array
# containing "Reia" and "Macruby"
end
def visit_all(&block)
visit &block
... | true |
26bd96ef55ec495f8d5232297a8e6d8cbcc8d837 | Ruby | hgodinot/hgodinot-Launch_School | /100_introduction/Methods/6.rb | UTF-8 | 162 | 3.78125 | 4 | [] | no_license | def time_of_day(hour)
if hour
puts "It's daytime!"
else
puts "It's nighttime!"
end
end
daylight = [true, false].sample
time_of_day(daylight)
| true |
259c9b53061177c9cc74ed58cd4eccb4cc63e80f | Ruby | siobhanosullivan1/Tennis-Agency | /player.rb | UTF-8 | 263 | 3.015625 | 3 | [] | no_license | class Player
attr_reader :name, :minimum_desired_proficiency, :proficiency
def initialize(name, proficiency, minimum_desired_proficiency)
@name, @proficiency, @minimum_desired_proficiency = name, proficiency, minimum_desired_proficiency
end
end | true |
2985c4879dc94a650fb959511c9cd808b637db62 | Ruby | Sayya/shiftworking_scheduler | /main_scheduler.rb | UTF-8 | 1,287 | 2.859375 | 3 | [] | no_license | require './ShiftTable.rb'
require './Checker.rb'
class Main_Scheduler
attr_reader :better_plan
def process_first
c = Checker.new
t = ShiftTable.new
c.set_shift t
@better_plan = { table: t, checker: c }
debug_conditions
t.month.days_num.times do |num|
t.apply c.planning_date(num)
... | true |
b753430f71f3fb4dada90ba52e9af72cc47b8fd0 | Ruby | gurugu-learning-projects/appacademy---software-engineering-foundations-3 | /rspec_exercise_1/lib/part_2.rb | UTF-8 | 644 | 3.546875 | 4 | [] | no_license | def hipsterfy(word)
vowels = "aeiou"
i = word.length - 1
while i >= 0
if vowels.include?(word[i])
word[i] = ""
return word
end
i -= 1
end
word
end
def vowel_counts(str)
vowels = "aeiou"
vowels_count = Hash.new(0)
str.each_char do |char|
if vowels.include?(char.downcase)
... | true |
46825a32f2a2f7b4bb045e0e29fba97a4ed12290 | Ruby | Charliemowood/Ruby_Class_Exercise_Week2_Day_1 | /team_spec.rb | UTF-8 | 1,783 | 3.6875 | 4 | [] | no_license | require('minitest/autorun')
require_relative('team')
class TestTeam < MiniTest::Test
def setup
@example_team = Team.new("Chealsea", ["John", "Gary", "Tim"], "Pavel Kovar")
end
def test_get_team_name
assert_equal("Chealsea", @example_team.team_name)
end
def test_get_players
assert_equal(["John"... | true |
52975877ae2b88604b4a1b36cb4f8f30dccb09b2 | Ruby | mike591/AppAcademy_daily | /W3D2/model_base.rb | UTF-8 | 1,301 | 2.921875 | 3 | [] | no_license | class ModelBase
def self.title
self.to_s.downcase << 's'
end
def self.all
QuestionsDatabase.instance.execute(<<-SQL, id)
SELECT
*
FROM
#{title}
SQL
end
def self.find_by_id(id)
QuestionsDatabase.instance.execute(<<-SQL, id)
SELECT
*
FROM
... | true |
14b6c4ad4f76de4527816536a871f3ad073be021 | Ruby | ivamluz/meuvale-rails | /test/unit/fetcher/visa_vale_fetcher_test.rb | UTF-8 | 2,647 | 2.578125 | 3 | [] | no_license | require 'test_helper'
# TODO: Implement logic to test charge dates (when next charge is on next year)
class VisaValeFetcherTest < ActiveSupport::TestCase
VALIDATION_PATTERN = {
:card_number_regex => /^[0-9]{16}$/,
:date_regex => /^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/,
:optional_date_regex => /^... | true |
8c803dc1d025c354266b9fbeb2aad58ac3c5e303 | Ruby | kern/webbed | /lib/webbed/helpers/request_uri_helper.rb | UTF-8 | 898 | 2.59375 | 3 | [
"MIT"
] | permissive | module Webbed
module Helpers
# Request helper for the Request-URI
module RequestURIHelper
# Aliases the {Request#request_uri} method to `#request_url`.
def self.included(base)
base.class_eval do
alias :request_url :request_uri
end
end
# The URI of the a... | true |
7f52708dadb629a118f77b391b7706cad76d2980 | Ruby | kwahome/project-euler | /prime_factors/ruby/largest_prime_factor.rb | UTF-8 | 59 | 2.828125 | 3 | [] | no_license | t = gets.strip.to_i
1.upto(t) do
n = gets.strip.to_i
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.