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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
faa9e3fce4844598f78d89871ebd59e61c787994 | Ruby | jsgarvin/gatekeeper | /test/gate_keeper_test.rb | UTF-8 | 13,509 | 2.53125 | 3 | [
"MIT"
] | permissive | $: << File.expand_path(File.dirname(__FILE__) + "/models")
require 'test/unit'
require 'rubygems'
gem 'activerecord', '>= 2.0.2'
require 'active_record'
require "#{File.dirname(__FILE__)}/../init"
require 'person'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
class GateKeeperTe... | true |
26a3c11b44cb4aef4cbf973eece397c46307bbb2 | Ruby | lucasbonner/RB130-139 | /Exercises/easy_2/from_to_step_sequence_generator.rb | UTF-8 | 769 | 4.15625 | 4 | [] | no_license | =begin
The Range#step method lets you iterate over a range of values
where each value in the iteration is the previous value plus
a "step" value. It returns the original range.
Write a method that does the same thing as Range#step,
but does not operate on a range. Instead, your method
should take 3 arguments: the star... | true |
4a7fdc38f75851b7bb063de580be5d72241b4b05 | Ruby | mccleary/ruby_challenges | /attribute_accessors.rb | UTF-8 | 1,832 | 4.53125 | 5 | [] | no_license | # refactor the following class using attribute accessors.
# attr_writers are setters and attr_readers are getters
# original code
class Cat
def set_name=(cat_name)
@name = cat_name
end
def get_name
return @name
end
def set_gender=(cat_gender)
@gender = cat_gender
end
def get_gender
re... | true |
4f37af18047de2f9ebdbfdf1ff336dedf4233f1d | Ruby | Beertaster/triangle-classification-online-web-ft-100719 | /lib/triangle.rb | UTF-8 | 800 | 3.46875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
attr_accessor :f_side, :s_side, :t_side
def initialize(f_side, s_side, t_side)
@sides = []
@sides << f_side
@sides << s_side
@sides << t_side
end
def valid_triangle?
sum_f_s = @sides[0] + @sides[1]
sum_s_t = @sides[1] + @sides[2]
sum_f_t = @sides[0] + @sides[2... | true |
9234b127628db536523f08896ac1ec6eab5b39a4 | Ruby | QadirM/projects | /minesweeper.rb | UTF-8 | 202 | 3 | 3 | [] | no_license | require_relative 'board'
class Game
def initialize()
@board = Board.new
@board.populate
end
def testing
pos = [0,0]
puts @board[pos].reveal
end
end
bb = Game.new
bb.testing
| true |
523b99a7ac09524ef511ba3318038ff15d5a9837 | Ruby | Indhu1/ttt-7-valid-move-kwk-000 | /lib/valid_move.rb | UTF-8 | 424 | 3.375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # code your #valid_move? method here
def valid_move?(a,i)
if i.between?(0,8) && !position_taken?(a,i)
true
else
false
end
end
# re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.
def position_taken?(a,i)
if a[i]==" " || a[i]=="" || a[i]==nil
fal... | true |
cdbd80c8f6ed090d66700fb7fa68aedc4dc4274f | Ruby | gottschalkbrigid89/admin_ka | /templates/query.rb | UTF-8 | 7,283 | 2.59375 | 3 | [] | no_license | class QueryColumn
attr_accessor :name, :sortable, :default_order
def initialize(name, options={})
self.name = name
self.sortable = options[:sortable]
self.default_order = options[:default_order]
end
def caption
"field_#{name}"
end
end
class Query
attr_accessor :filters
d... | true |
8bc30b3d0f196b61a95a38ed37ee53a0c2906bb1 | Ruby | marcandre/tlaw | /lib/tlaw/endpoint.rb | UTF-8 | 4,142 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'faraday'
require 'faraday_middleware'
require 'addressable/template'
require 'crack'
module TLAW
# This class does all the hard work: actually calling some HTTP API
# and processing responses.
#
# Each real API endpoint is this class descendant, defining its own
# params and response processors. On ... | true |
e94a4cf92ddb6acf7e9eb93a3ac52769f1f4cdaf | Ruby | yureru/wpfProGen | /wpfProGen.rb | UTF-8 | 2,165 | 3.046875 | 3 | [] | no_license | require_relative 'core/lib'
require 'json'
file = File.open("metadata.txt") { |file| file.read }
my_hash = JSON.parse(file)
my_hash.each do | metadata |
#currentFile is the file specified in the metadata, propertiesGrup is all the properties for that file.
metadata.each do | currentFile, propertiesGroup |
#p... | true |
0a1d187da6352641be73560da1cd702e9fffc55b | Ruby | SarahCam/codeclan_work | /week_01/day_3/arrays.rb | UTF-8 | 1,531 | 4.09375 | 4 | [] | no_license | fruits = ["apple", "bananas", "grape", "orange"]
p fruits[0]
p fruits[4]
# fruits.insert( 2, "pear" )
# p fruits
p fruits[-1] #prints last one in the array
p fruits[-5]
p fruits.first()
p fruits.first(2) # prints first 2 array items
p fruits.last()
p fruits.last(2) # prints last 2 array items
# def number_... | true |
65f8ed9d47a78c66703650cf1868f99158a8a9ec | Ruby | felixclack/rotavator | /test/shoulda_macros/date_validations.rb | UTF-8 | 680 | 2.5625 | 3 | [] | no_license | module DateValidations
def should_validate_future_date(attribute)
@instance = get_instance_of(self)
@instance.send("#{attribute}=", 7.days.ago)
assert_equal false, @instance.valid?
assert_contains(@instance.errors.on[attribute], /#{attribute} should be in the future/)
@instance.send("#{attribut... | true |
fc152426b12f502b6115d3d0fa212b64839f626a | Ruby | bwielk/codeclan-c9-classnotes | /week_09/day_03/code/ruby/thread_play_lock_broke.rb | UTF-8 | 519 | 3.484375 | 3 | [] | no_license | def expensive_operation(number)
(0..100).each do |iteration|
number = Math.sqrt(number) + 5
end
number
end
array_size = 999999
start_time = Time.now
sum = 0#shared
t1 = Thread.new do
(1..array_size/2).each do |number|
sum += expensive_operation(number)
end
end
t2 = Thread.new do
((array_size/2+... | true |
8beefb6786ecec4d3aa3d58bf1376e2849f9a27f | Ruby | cjhdev/ldl_chirp_test | /frame.rb | UTF-8 | 5,432 | 2.546875 | 3 | [] | no_license | require_relative 'codec'
module Flora
class Frame
@type = nil
@@subs = []
def self.inherited(klass)
if self == Frame
@@subs << klass
else
superclass.inherited(klass)
end
end
def self.type
@type
end
def type
self.class.type
end
d... | true |
4ce28dfd483d8e1a913825415af22325108cd64c | Ruby | vishallama/assignment_data_structures | /stacks_and_queues/lib/stack.rb | UTF-8 | 503 | 3.65625 | 4 | [] | no_license | # stack.rb
class Stack
attr_reader :stack
def initialize
@stack = []
end
def push(value)
next_index = @stack.length
@stack[next_index] = value
self
end
def pop
return nil if empty?
last_index = @stack.length - 1
last_elem = @stack[last_index]
@stack = @stack[0...last_index... | true |
d450d434901f36b7b6b573294697dd521fc5cdff | Ruby | abdibogor/Ruby | /2.betacoding/Ruby/4.doing simple math, basic operations.rb | UTF-8 | 185 | 3.75 | 4 | [] | no_license | puts "MATH operations:"
# + , - , / . * + %
puts 5+9
print 10*5
print 10*5*5
puts 10+5
puts 1*2/3-4*5
puts (5.0*3.0)/(5.0-3.0)
puts (5.0*3.0) > (5.0-3.0)
puts (5.0*3.0) < (5.0-3.0) | true |
210391ff6938dbf15c48334ba708a7ecca80416f | Ruby | cvilla714/all-about-ruby | /conditional.rb | UTF-8 | 298 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
system 'clear'
puts 10 == 11 # ralse
puts 10 != 11 # true
puts 10 > 15 # false
puts 10 >= 15 # false
puts 10 <= 100 # true
puts 'luffy' == 'Luffy' # false
puts 'luffy' == 'luffy' # true
puts 'jinbei'.upcase != 'jinbei' # true
puts 'jinbei'.upcase == 'JINBEI' # true
| true |
60ef4b61ebc7e2fa5199fee3f0da58232607fc65 | Ruby | teddyviking/the_mall | /lib/the_mall/warehouse.rb | UTF-8 | 686 | 3.046875 | 3 | [] | no_license | module TheMall
class Warehouse
def initialize
@available_supplies = {
meat: TheMall::Item.new("Meat", 2),
fish: TheMall::Item.new("Fish", 2),
orange: TheMall::Fruit.new("Orange", 1),
vacuum: TheMall::Houseware.new("Vacuum", 20)
}
@minimum_accepted_order = 20
... | true |
98efbc0440ec920b9e42949833ac97815cf2b147 | Ruby | jtc27/makers-bnb | /spec/booking_spec.rb | UTF-8 | 4,811 | 2.5625 | 3 | [] | no_license | require 'booking'
require 'database_helpers'
describe Booking do
let(:host_user_id) { create_host } # from database_helpers
let(:bnb_id) { create_bnb(host_id: host_user_id) } # isolates this class for testing
let(:booking) {
Booking.create(
start_date: Time.new(2021, 11),
end_date: Time.new(2021,... | true |
e3320b71f463e560ca7141020729c7a881dc68c2 | Ruby | redding/osheet-xmlss | /examples/basic.rb | UTF-8 | 1,420 | 3.078125 | 3 | [
"MIT"
] | permissive | # To run:
# $ bundle install
# $ bundle exec ruby examples/basic.rb
# $ open examples/basic.xls
require 'rubygems'
require 'osheet/xmlss'
fields = ['Sex', 'Age', 'Height', 'Weight']
data = {
'Tom' => ['M', 52, "6'2\"", '220 lbs.'],
'Dick' => ['M', 33, "6'5\"", '243 lbs.'],
'Sally' => ['F', 29, "5'3\"", '132 lbs... | true |
75e226094798a74cdde0004de458296fe6db9868 | Ruby | crazyivan/FinModeling | /spec/time_series_estimator_spec.rb | UTF-8 | 1,746 | 2.75 | 3 | [] | no_license | require 'spec_helper'
describe FinModeling::TimeSeriesEstimator do
describe ".new" do
let(:a) { 1.0 }
let(:b) { 0.2 }
subject { FinModeling::TimeSeriesEstimator.new(a, b) }
it { should be_a FinModeling::TimeSeriesEstimator }
its(:a) { should be_within(0.01).of(a) }
its(:b) { should be_withi... | true |
286c2c477a1ea9e173fb2a1be461af9d8d285c00 | Ruby | dfinninger/lita-mailer | /lib/lita/handlers/mailer.rb | UTF-8 | 3,860 | 2.9375 | 3 | [] | no_license | require 'json'
require 'mail'
module Lita
module Handlers
class Mailer < Handler
route(/^mail new/, :mail, command: true, help: { "mail new" => "Start building an email" })
route(/^mail list.+/, :list, command: true)
route(/^mail subj.+/, :subj, command: true)
route(/^mail body.+/, :body... | true |
dd3a2f310a033a7362959465137cfad602f5e110 | Ruby | brionwolf/acc-ruby | /notes-ongoing.rb | UTF-8 | 19,926 | 3.90625 | 4 | [] | no_license | # ⧏⫷⦿⫸⧐
# --------------------------------------------------------------------------------------
# + ++++ ++++ ++++++ + + ++++++ + + ⧏⫷⦿⫸⧐
# + + + + + + + + + + + + ⧏⫷⦿⫸⧐
# + + + + ... | true |
0e7fb095b58cc85a2b9616884da43f7f93c723d3 | Ruby | lucasec/gitlab-server | /libraries/url-helper.rb | UTF-8 | 339 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | module GitLabURL
def self.buildURL( hash )
url = hash['secure_port'].nil? ? 'http://' : 'https://'
url += hash['hostname']
unless hash['secure_port'].nil?
url += ':' + hash['secure_port'] unless hash['secure_port']=='443'
else
url += ':' + hash['port'] unless hash['port']=='80'
end
url += hash['path']
r... | true |
14c875f5706f024600aa814ef4a096a1fb35319d | Ruby | Carmer/list-y-list | /app/models/task.rb | UTF-8 | 2,585 | 2.640625 | 3 | [] | no_license | require "csv"
class Task < ActiveRecord::Base
attr_accessor :attachment
has_attached_file :attachment, default_url: "alpaca.jpg",
storage: :s3,
s3_credentials: {
access_key_id: ENV['AWSAccessKeyId'],
... | true |
51ac6d9c742f526800f8a32b79a2ef30616a32d8 | Ruby | ssteeg-mdsol/openapi3-generator | /gems/gems/prawn-2.2.2/manual/graphics/helper.rb | UTF-8 | 863 | 2.75 | 3 | [
"GPL-3.0-only",
"GPL-2.0-only",
"Ruby",
"Apache-2.0"
] | permissive | # To produce this manual we use the <code>stroke_axis</code> helper method
# within the examples.
#
# <code>stroke_axis</code> prints the x and y axis for the current bounding box
# with markers in 100 increments. The defaults can be changed with various
# options.
#
# Note that the examples define a custom <code>:heig... | true |
7440593ca043d4726aea0828de303d68208c1307 | Ruby | menachemkorf/launchschool-intro-to-programming | /ch05-loops-iterators/e03.rb | UTF-8 | 127 | 3.703125 | 4 | [] | no_license | # exercise 3
names = ['Bob', 'Mike', 'John', 'Joe']
names.each_with_index do |value, index|
puts "#{index} => #{value}"
end | true |
b6ba47d4f84179f642a777d9d83aee91cdb33316 | Ruby | oneiros/hdm | /app/models/hierarchy.rb | UTF-8 | 1,770 | 2.578125 | 3 | [] | permissive | class Hierarchy
attr_reader :name, :environment, :node, :datadir, :backend, :files
def self.all(node)
facts = node.facts
environment = node.environment
HieraData.new(environment.name).hierarchies.map do |hierarchy|
new(node: node,
name: hierarchy.name,
datadir: hierarchy.datad... | true |
d8c00ab9c644bb2ff9a670760e1da32c0c123ceb | Ruby | appdev-projects/ruby-practice | /string/chomp.rb | UTF-8 | 87 | 2.859375 | 3 | [] | no_license | # Output:
#
# "Hello!"
#
# using the given starting variable.
greeting = "Hello!$"
| true |
5682f4f819d3411a0b99d213e274f8d22093245a | Ruby | ankurnehra/tdd-class-8-dec | /9-dec-search-organization.rb | UTF-8 | 2,527 | 2.609375 | 3 | [] | no_license | # test this with controller test
# submit the JSON that hypothetically comes in via the API
# check the JSON that comes back
# I have two tests (positive and negative case),
# because I'm really just testing that everything was wired up right
class SearchController < ApiController
# POST /api/v1/search (json)
def s... | true |
886c996fec94db3e2876158c8a13ed562cc84e51 | Ruby | JoseDLopez/DL_Ruby | /Clase030_Ejercicios_01_ArrayBasicos.rb | UTF-8 | 1,192 | 4.6875 | 5 | [] | no_license | # Dado el array [1,2,3,9,1,4,5,2,3,6,6]
# 1. Mostrar el primer elemento.
# 2. Mostrar el último elemento.
# 3. Mostrar todos los elementos
# 4. Mostrar todos los elementos junto con un índice
# 5. Mostrar todos los elementos que se encuentren en una posición par
# 6. Determinar si un elemento ingresando pertenece al ar... | true |
68df50ecf6608b1c2d80a04713378c58945f7ddd | Ruby | pathouse/AdventOfCode2020 | /ruby/day_eleven_spec.rb | UTF-8 | 1,186 | 3.03125 | 3 | [] | no_license | require_relative './day_eleven'
RSpec.describe GameOfSeats do
let(:input) do
<<~LINES
L.LL.LL.LL
LLLLLLL.LL
L.L.L..L..
LLLL.LL.LL
L.LL.LL.LL
L.LLLLL.LL
..L.L.....
LLLLLLLLLL
L.LLLLLL.L
L.LLLLL.LL
LINES
end
it 'simulates the game of seats' do
game = GameOfSeats.new(input)
expect(game.simulate).t... | true |
29b356b4987606beb59fecf5ec74eb674b5e7033 | Ruby | mattn/mruby | /test/assert.rb | UTF-8 | 1,735 | 3.015625 | 3 | [
"MIT"
] | permissive | $ok_test = 0
$ko_test = 0
$kill_test = 0
$asserts = []
$test_start = Time.now if Object.const_defined?(:Time)
##
# Create the assertion in a readable way
def assertion_string(err, str, iso=nil, e=nil)
msg = "#{err}#{str}"
msg += " [#{iso}]" if iso && iso != ''
msg += " => #{e.message}" if e
msg += " (mrbgems:... | true |
da6d7ba37809fdc6cecd1a7de62e21d5063724c4 | Ruby | dougsko/projecteuler.net | /solved/357/solution.rb | UTF-8 | 752 | 3.21875 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# projecteuler.net
# problem 357
#
# Consider the divisors of 30: 1,2,3,5,6,10,15,30.
# It can be seen that for every divisor d of 30, d+30/d is prime.
#
# Find the sum of all positive integers n not exceeding 100 000 000
# such that for every divisor d of n, d+n/d is prime.
#
# 1739023853136 is w... | true |
af2c649c32f6e9c62a9b4d996025401956c090dc | Ruby | arielscherman/api_events | /lib/api_events/model.rb | UTF-8 | 1,292 | 2.640625 | 3 | [
"MIT"
] | permissive | require "api_events/model/config"
module ApiEvents
module Model
def self.included(base)
base.send :extend, ClassMethods
base.send :include, InstanceMethods
end
module ClassMethods
def broadcast(options = {})
api_events.setup(options)
end
def api_events
::A... | true |
247d1074948d396af39e4f10d8e62a0bbcbe2da6 | Ruby | tuckerbohman5/ttt-with-ai-project-v-000 | /lib/board.rb | UTF-8 | 2,222 | 4.375 | 4 | [] | no_license | require "pry"
class Board
attr_accessor :cells, :player, :token_1, :token_2
def initialize
@cells = Array.new(9, " ")
end
def reset! #Can reset the state of the board to how it should be at the start of the game an array with 9 " " elements.
@cells = Array.new(9, " ")
end
def display #Prints th... | true |
88d717fd09ea6f546081b4a907996fe29754138a | Ruby | oorion/event_reporter | /lib/build_file.rb | UTF-8 | 657 | 2.84375 | 3 | [] | no_license | module BuildFile
def get_file_path(file_name)
path_to_file = File.expand_path("../data", __dir__)
file_path = File.join(path_to_file, file_name)
end
def convert_saved_file_header(file_name)
file_path = get_file_path(file_name)
header = CSV.open(file_path,'r').first
capital_headers = header.ma... | true |
b41df57bf6771febdebd34cd71a6eac7eae0ec99 | Ruby | Vladholovchak/border_point | /lib/parser/border_parser.rb | UTF-8 | 495 | 2.75 | 3 | [] | no_license | class BorderParser
def initialize(doc)
@doc = doc
end
def call
container = []
@doc.css('section.countries_table > .container > .countries_table_info > .row > .col-md-12.col-sm-12 >
.responsive > tbody > tr').each do |tr|
time_car = tr.css('td:nth-child(2)').text
time_truck = tr.css('t... | true |
b81238029873059437e1a7e600be15db94c19981 | Ruby | pjrcisco/trains_example | /lib/src/IOT/Listeners/MQTTSensors.rb | UTF-8 | 2,366 | 2.640625 | 3 | [] | no_license | require 'rubygems'
require 'mqtt'
require 'json'
require 'thread/pool'
require_relative '../API/REST/MQTTSensors/Event'
require_relative '../API/REST/Base'
module IOT
module Listener
class Sensor
attr_reader :name, :uri, :headers, :body
def initialize(args={})
@name = args[:name] || args["name"... | true |
5bb14eb4c6d8a2a8dae747cb596e5db9a49fac2c | Ruby | rohalla2/card-counting-simulation | /shoe.rb | UTF-8 | 863 | 3.5625 | 4 | [] | no_license | require_relative 'card'
class Shoe
attr_accessor :num_decks, :available_cards, :discard_pile
def initialize(num_decks = 6)
@num_decks = num_decks
@available_cards = []
@discard_pile = []
num_decks.times do
@available_cards.push(*create_deck)
end
shuffle
end
def shuffle
@av... | true |
f1d77d0b42b973f45a8ad273ffb282d451db1252 | Ruby | jouissances/school-domain-v-000 | /lib/school.rb | UTF-8 | 492 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_reader :roster
def initialize(school_name)
@school_name = school_name
@roster = Hash.new
end
def add_student(student_name, grade)
@student_name = student_name
@grade = grade
if @roster.keys.include?(grade)
@roster[grade] << student_name
else
@roster[grade]... | true |
c3c37e1a0eef47c6a08e2c646a0bdd5d550867ea | Ruby | thoughtworks-tcaceres/ruby_practise | /inheritance/ex4.rb | UTF-8 | 688 | 3.96875 | 4 | [] | no_license | # frozen_string_literal: true
module Towable
def can_tow?(pounds)
pounds < 2000
end
end
class Vehicle
@@number_of_vehicles = 0
def initialize
@@number_of_vehicles += 1
end
def self.number_of_vehicles
puts "number of vehicles: #{@@number_of_vehicles}"
end
def self.gas_mileage(litres, kilo... | true |
e0f46535d9bcaf6a2f7240f24f3042e097c5fb51 | Ruby | scottwater/blog | /_plugins/short_feed_hook.rb | UTF-8 | 1,303 | 2.609375 | 3 | [] | no_license | require "active_support/core_ext/string/filters"
require "active_support/core_ext/object/blank"
require "twitter-text"
Jekyll::Hooks.register :posts, :post_render do |post|
if post.data["categories"].include?("short")
if post.data["excerpt_separator"].nil? && post.content =~ /(<!--\s*more\s*-->)/
post.dat... | true |
56915fdcb6dcc67aeefdcc7af0dc3c6160966dbe | Ruby | jonchay/cracking-the-coding-interview | /test/chapter_5/test_5_8_draw_line.rb | UTF-8 | 900 | 2.71875 | 3 | [] | no_license | require 'test_helper.rb'
require './lib/chapter_5/5_8_draw_line.rb'
class TestDrawLine < Minitest::Test
def test_draw_line
screen = [
[], [], [], [],
[], [], [], []
]
width = 32
x1 = 6
x2 = 21
y = 1
expected = [
[0b0000_0000], [0b0000_0000], [0b0000_0000], [0b0000_0000],... | true |
a6f5e5975977aafaaaa62632c31ad7f17db9e6df | Ruby | hmistry/ar_sql | /ar/seed.rb | UTF-8 | 1,541 | 2.875 | 3 | [] | no_license | # frozen_string_literal: true
require "./db.rb"
require "./models.rb"
require "faker"
NUM_OF_TOPICS = 10
NUM_OF_POSTS_PER_TOPIC = 100
NUM_OF_COMMENTS_PER_POST = 20
def time_offset(start, stop) # in num of days
raise "start must be greater than stop" if stop < start
start_day = start * 86_400
stop_day = stop * ... | true |
53202f7e19c96453030035a689c3ce7dba277fd4 | Ruby | svmelton/numerology-app | /app/controllers/index_controller.rb | UTF-8 | 767 | 2.796875 | 3 | [] | no_license |
get '/:birthdate' do
setup_index_view
end
get '/message/:birthpath_number' do
birthpath_number = params[:birthpath_number].to_i
@message = Person.numerology_message(birthpath_number)
erb :index
end
get '/' do
erb :form
end
post '/' do
birthdate = params[:birthdate].gsub("-", "")
if Person.valid_b... | true |
de3b597d0aee4d893e39aee0782693f496171855 | Ruby | stubblyhead/advent2016 | /day18/rodney.rb | UTF-8 | 1,244 | 3.609375 | 4 | [] | no_license | require 'pry'
#binding.pry
class Traps
attr_reader :layout
def initialize(previous)
@layout = ''
trapmap = { ?^ => true, ?. => false }
previous.chars.each_index do |i|
if i == 0
slice = [false, trapmap[previous[i]], trapmap[previous[i+1]] ]
elsif i == previous.length - 1
sl... | true |
5f73b2e1e19f64f30f5a6e239eab29b3db70de8f | Ruby | romero-c-raul/Ruby-Small-Problems | /easy_8/pr2.rb | UTF-8 | 645 | 3.921875 | 4 | [] | no_license | =begin
PROBLEM
- Input: None
- Output: String
rules:
- Explicit Requirements:
- Create a simple mad-lib program that prompts for a noun, a verb, an adverb, and an adjective
and injects those into a story that you create
ALGORITHM
- Obtain noun, verb, adjective, and adverb from user
- Print a ... | true |
01e3203a7f9bfed1540e609f12c27c3ba8774767 | Ruby | moutainhigh/chelaike | /lcyz-server/spec/models/app_version_spec.rb | UTF-8 | 1,933 | 2.546875 | 3 | [] | no_license | # == Schema Information
#
# Table name: app_versions # app版本控制
#
# id :integer not null, primary key # app版本控制
# version_number :string # 版本号
# version_type :string # 版本类型
# note :text ... | true |
ef6901c37a6b1cdd19e2e446064314c72593871a | Ruby | shibbster321/surf-scraping | /scrape.rb | UTF-8 | 2,537 | 3.15625 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
def scrape(location)
url = "https://www.surf-forecast.com/breaks/#{location}/forecasts/latest/six_day"
html_file = open(url).read
html_doc = Nokogiri::HTML(html_file)
# set 0 values for loops
i = 0
attributes = {}
ratings = []; wave_height = []; wind_speed = ... | true |
3f3533b90f30150c9bad958722d62cb65f845341 | Ruby | learn-labs/programming_languages-prework | /programming_languages.rb | UTF-8 | 412 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reformat_languages(languages)
new_hash = {}
languages.each do |style, language|
language.each do |name, typeinfo|
typeinfo.each do |type, int_or_comp|
if new_hash[name].nil?
new_hash[name] = {}
end
new_hash[name][:style] ||= []
new_hash[name][:style] << s... | true |
c4505587ef00b53c60b32b08463cff22b60dcec9 | Ruby | janschill/uni-pandora | /server/src/parser/logger.rb | UTF-8 | 295 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
module Parser
class Logger < Parser
def initialize; end
def parse_row(row:)
row_parsed = {}
row.split(', ').each do |kv|
key, value = kv.split(': ')
row_parsed[key.to_sym] = value
end
row_parsed
end
end
end
| true |
a34409c021c9542cd5d81d507695eacabea6c519 | Ruby | krzy5zt0f-1/boris-bikes1 | /spec/boris_bikes_spec.rb | UTF-8 | 2,709 | 3.03125 | 3 | [] | no_license | require 'boris_bikes'
RSpec.describe DockingStation do
it {is_expected.to respond_to(:release_bike)}
describe "read capactiy variable from the docking station instance" do
it 'returns the capacity value' do
expect(subject.capacity).to_not eq(nil)
expect(subject.capacity).to eq(20)
end
it ... | true |
8221eb79c20f802563ef0aad5d2db553c0a2d3a7 | Ruby | wfischer42/backend_prework | /day_4/mutate.rb | UTF-8 | 629 | 4.03125 | 4 | [] | no_license | def mutator(string)
string.concat("... AHHHHHHHH! I mutated!")
string.upcase! # Bang methods are cool! It's nice to be able to control
# the mutation
end
def nonmutator(string)
string += "... AHHHHHHHH! I mutated!"
newstring = string.upcase
return newstring # No "return" necessary, since rub... | true |
82c864a7a0ff0e0f48662066d5d7dd23aa37deca | Ruby | bbarcio/bDodge | /lib/my_game.rb | UTF-8 | 3,994 | 2.59375 | 3 | [] | no_license | class MyGame < Gosu::Window
attr_reader :running
attr_reader :paused
attr_accessor :background_color
attr_accessor :background_image
attr_accessor :font_color
attr_accessor :music
Z_BG, Z_PLAYER, Z_BALL = (0..2).to_a
PADDING = 10
FRAME_RATE = 60
BLACK = Gosu::Color.new(0xff000000)
WHITE = Gosu::Co... | true |
97e6b636bd0e1f39dfe5799c581d16428a8fca79 | Ruby | bestwebua/codewars | /ruby/identify_case.rb | UTF-8 | 1,722 | 4.09375 | 4 | [] | no_license | =begin
Identify Case by Vladislav Trotsenko.
So the task here is to implement a function that takes a string,
c_str, and returns a string with the case the input is in. The
possible case types are “kebab”, “camel”, and ”snake”. If none
of the cases match with the input, or if there are no 'spaces'
in the input (for ex... | true |
1dd0d02e178969d5c2acf84e63bccd6e3569e4bb | Ruby | yuki3738/RubyCrawler | /RubyCrawlerSample/chapter6/use-s3.rb | UTF-8 | 1,046 | 2.890625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'aws-sdk'
AWS.config({
:access_key_id => 'AWS_ACCESS_KEY',
:secret_access_key => 'AWS_SECRET_ACCESS_KEY'
})
s3 = AWS::S3.new
bucket = s3.buckets['your-bucket-name']
tree = bucket.as_tree
# ディレクトリ一覧
directories = tree.children.select(&:branch?).collect(&:prefix)
direct... | true |
4a079b6a729562fa57839a904c014b2290b44057 | Ruby | rjspencer/phase_0_unit_2 | /week_4/7_refactor/reverse_cipher/my_solution.rb | UTF-8 | 3,301 | 4.125 | 4 | [] | no_license | # U2.W4: Refactor Cipher Solution
# I worked on this challenge [by myself, with: ].
# 1. Solution
# Write your comments on what each thing is doing.
# If you have difficulty, go into IRB and play with the methods.
# Also make sure each step is necessary. If you don't think it's necessary
# Try implementing the cod... | true |
a27db774dc899b7b57494321a8a2be3b3420fb01 | Ruby | Maisde300Reais/middleware-ruby | /app_martial_academy/training.rb | UTF-8 | 180 | 2.96875 | 3 | [] | no_license | class Training
attr_accessor :id, :day, :time, :instructor
def initialize(id, day, time, instructor)
@id = id
@day = day
@time = time
@instructor = instructor
end
end | true |
ed42841032931a4b4e09610f5084ee984fcae7f6 | Ruby | nkotsev/Noted | /lib/noted/note_decorator.rb | UTF-8 | 1,166 | 2.953125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class NoteDecorator
def initialize(note, color_pair, measurements)
@note = note
@color_pair = color_pair
@measurements = measurements
@screen_width = ENV['COLUMNS']
end
# TODO: Extract to Decorator module
def method_missing(method_name, *args, &block)
super un... | true |
041c977351794be18e6c2421de580255a614c63f | Ruby | thejud/scripts | /bin/trim.rb | UTF-8 | 696 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
########################################
# FUNCTIONS
########################################
def parse_args
o = {cmd: 'strip'}
OptionParser.new do |opts|
opts.banner = "Usage: trim.rb [options]"
opts.on("-h", "--help", "Show help") do
puts opts
exit
... | true |
c77153664e737e47de5fdb6d5e080433522cacd5 | Ruby | SJeannie/countdown-to-midnight-prework | /countdown.rb | UTF-8 | 341 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def countdown(counter)
seconds = counter
while seconds > 0
puts "#{seconds} SECOND(S)!"
seconds -= 1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(counter)
seconds = counter
while seconds > 0
puts "#{seconds} SECOND(S)!"
seconds -= 1
sleep(1)
end
"HA... | true |
275711e8c25c7064bce6590b8ba6b757df9cb0c9 | Ruby | pofystyy/codewars | /6 kyu/replace_with_alphabet_position.rb | UTF-8 | 561 | 4.1875 | 4 | [] | no_license | # https://www.codewars.com/kata/546f922b54af40e1e90001da
# Details:
# Welcome.
# In this kata you are required to, given a string, replace every letter with its position in the alphabet.
# If anything in the text isn't a letter, ignore it and don't return it.
# "a" = 1, "b" = 2, etc.
# Example
# alphabet_position... | true |
0e9b1867ce24a221418fbf85736252df61000e52 | Ruby | twomack/clr_exercises | /section2_sorting_and_order_statistics/exercise_7_5_4.rb | UTF-8 | 2,263 | 3.765625 | 4 | [] | no_license | #!/usr/bin/ruby -w
require_relative 'lib/heap'
my_array = [0, 2, 4, 6, 8]
my_heap = Heap.new(my_array)
my_heap.print_heap_tree()
# First, test maximum method
puts 'TESTING MAXIMUM ===================================='
puts my_heap.maximum()
# Test extract_max method
puts 'TESTING EXTRACT_MAX =======================... | true |
a4146b9771d1b784c49356ef3ebd3b0be193772d | Ruby | bluepostit/hashes-and-symbols-628 | /hash-crud.rb | UTF-8 | 551 | 4.09375 | 4 | [] | no_license | student_ages = {
'Peter' => 24,
'Mary' => 25,
'George' => 22,
'Emma' => 20,
# 'George' => 45
}
# CRUD
# C-reate
student_ages['Celia'] = 23
p student_ages
# R-ead
# Print George and his age
puts "George is #{student_ages['George']} years old"
# U-pdate
student_ages['Emma'] = 21
p student_ages
# D-elete
st... | true |
15c6878a5b55d7f23f02c2ada915d297bd5b6a58 | Ruby | itggot-julia-ekeblad/standard-biblioteket | /lib/exclude.rb | UTF-8 | 564 | 4.1875 | 4 | [] | no_license | # Public: In an array it doesn't leaves the values of the char in the array.
#
# arr - Your array with desierd continent.
# char - character with value you want to exclude.
#
# Examples
#
# exclude(["bosse", "olof", "kalle", "olof"], "olof")
# # => ["bosse", "kalle"]
#
# Returns array with the other values.
def ex... | true |
e0f9452f4d1594f6b79577b1edcf37ac85fc492a | Ruby | nadavmatalon/battleships_web | /lib/player.rb | UTF-8 | 1,109 | 3.140625 | 3 | [
"MIT"
] | permissive | require_relative "board"
class Player
def initialize(name = "Player", board = Board.new)
@name = name
@board = board
end
def board
@board
end
def name
@name
end
def set_name new_name
@name = new_name
end
def ships
@ships = board.ships
end
def ship_count
ships.count
end
def place new_s... | true |
647a1778b2bd6290f9a647edfede7892459263eb | Ruby | mayokake/practice_ruby | /ruby_for_pro/test/bowling_test8.rb | UTF-8 | 1,663 | 3.609375 | 4 | [] | no_license | # frozen_string_literal: true
class Bowling
def initialize(score)
@score = score
p @score
@sc = @score[0].split(',')
p @sc
@basic_score = []
@sc.each { |s| s == 'X' ? @basic_score.push(10, 0) : @basic_score.push(s.to_i) }
@basic_score
p @basic_score
end
# def scores
# @sc = @... | true |
200975cf623a748d7cbf07c40c0b5aa5b7c2f601 | Ruby | luizfilho00/mario_binary_hacking | /hex.rb | UTF-8 | 3,412 | 3.484375 | 3 | [] | no_license | class HexEditor
# Cria uma hash_map em @table contendo os dados de @table_file
# Cria uma string @rom que recebe os bytes do arquivo @rom_file
# Cria uma string @dump que contém os dados da @rom_file em hexadecimal
def initialize(rom_file, table_file)
begin
@table = Hash[File.read(table_file).split("\... | true |
8aca35704b90ba1f9ccdec4b0b1f120384973d5e | Ruby | aaronburmeister/hayk-assessment-library | /tools/console.rb | UTF-8 | 721 | 3.15625 | 3 | [] | no_license | require_relative '../config/environment'
tolkien = Author.new("J.R.R. Tolkien")
martin = Author.new("George R. R. Martin")
herbert = Author.new("Brian Herbert")
gameofthrones = Book.new("A Game of Thrones", 1995)
stormofswords = Book.new("A Storm of Swords", 1998)
dune = Book.new("Dune", 1970)
thehobbit = Book.new("T... | true |
21d8c4d9d208a5c697a448b8c310d62040ed72ec | Ruby | fzondlo/elevators | /elevator_router.rb | UTF-8 | 870 | 3.28125 | 3 | [] | no_license | #why doesn't binding.pry work??
require_relative "elevator"
class ElevatorRouter
attr_reader :top_floor, :bottom_floor
def initialize(top_floor, bottom_floor = 1, elevator_count = 1)
@bottom_floor = bottom_floor
@top_floor = top_floor
@elevators = create_elevators(elevator_count)
end
# returns ha... | true |
a2387b5526f2ca79e4a071f025a15c015dbae44d | Ruby | baberthal/smarter_home | /lib/trakt/client.rb | UTF-8 | 1,849 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'rest-client'
require 'json'
module Trakt
class Client
attr_reader :resource
def initialize(omniauth_auth_hash, options = {})
@headers = {
content_type: 'application/json',
authorization: "Bearer #{omniauth_auth_hash['token']}",
trakt_api_version: '2',
trakt_api_... | true |
b28a8b2a9a37d45c2ad350ace1cdb3e0d9f82478 | Ruby | Sillhouette/operators-v-000 | /lib/operations.rb | UTF-8 | 295 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ##
# returns true if at unsafe speeds using if statements
##
def unsafe?(speed)
if(speed < 40 || speed > 60)
return true;
else
return false;
end
end
##
# returns true if at unsafe speeds using ternary operator
##
def not_safe?(speed)
return speed < 40 || speed > 60 ? true : false;
end
| true |
714d63a2c7e981c940501e7b7403bc8ccd784267 | Ruby | davissamuel997/davissamuel997.github.io | /1_calculate_array_total/my_solution.rb | UTF-8 | 2,711 | 4.4375 | 4 | [
"MIT"
] | permissive | # U1.W3: Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge by myself.
# 1. Pseudocode
# What is the input?
# we need a function that takes in an array
# for the... | true |
92b12a489cb224b26c0caec54a13bd47db71a3f3 | Ruby | fnando/recurrence | /test/recurrence/default_starts_date_test.rb | UTF-8 | 645 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
class DefaultStartsDateTest < Minitest::Test
test "returns Date.current by default" do
assert_equal Date.current, Recurrence.default_starts_date
end
test "requires only strings and procs" do
assert_raises(ArgumentError) do
Recurrence.default_sta... | true |
c36df48f714ce328cd634866f0bb8414a41b3e76 | Ruby | CamillaCdC/seic38-homework | /Jasper Overall/week_5/Wednesday/MTA.rb | UTF-8 | 2,394 | 3.234375 | 3 | [] | no_license | subway = {
'N' => ['Times Square', '34th', 'n28th', 'n23rd', 'Union Square', 'n8th'],
'L' => ['l8th', '6th', 'Union Square', '3rd', '1st'],
'six' => ['Grand Central', '33rd', '6_28th', '6_23rd', 'Union Square', 'Astor Place']
}
leave_journey_planner = false
until leave_journey_planner == true do
puts "What li... | true |
38e9aa631150dd548279b015a2f59891a1d300ee | Ruby | isabella232/degreed | /lib/degreed.rb | UTF-8 | 1,515 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "json"
require "degreed/version"
require "degreed/request"
require "degreed/response"
require "degreed/content/courses"
# Client for the Degreed API
module Degreed
# Access the current configuration
def configuration
@configuration ||= Configuration.new
end
module_fun... | true |
8e9b2e1cfe1ebdc9feb323c8d0e143f680e67d93 | Ruby | mmcnickle-float/aoc2020 | /day12/vector.rb | UTF-8 | 383 | 3.375 | 3 | [] | no_license | # frozen_string_literal: true
Vector = Struct.new(:x, :y) do
def l90
x2 = -y
y2 = x
self.x = x2
self.y = y2
end
def r90
x2 = y
y2 = -x
self.x = x2
self.y = y2
end
def *(other)
Vector.new(x * other, y * other)
end
def +(other)
Vector.new(x + other.x, y + other.... | true |
0b7804ebf1f77a0a318ae03ea7dc2a7166e762c2 | Ruby | albertbahia/wdi_june_2014 | /w02/d01/hoa_newton/GoT/lib/human.rb | UTF-8 | 549 | 3.8125 | 4 | [] | no_license | class Human
attr_reader(:name, :house, :strength)
attr_accessor(:hp)
def initialize (name, house, strength)
@name = name
@house = house
@strength = strength
@hp = 200
end
def introduce
"My name is #{@name}. I am from the house of #{@house}"
end
def take_damage(damage)
if damage < 0
return @hp
... | true |
ddb6ce970c8ce6d214035dd1ba1486e309794d85 | Ruby | roitblatari/looping-loop-v-000 | /looping.rb | UTF-8 | 79 | 2.8125 | 3 | [] | no_license | def looping
12.times do
puts "hi"
end
end
#call your method here
looping
| true |
5ed302e91f9589c21fbbaf204361b0d28908ba7d | Ruby | tianxind/cpwiki | /lib/sanitize.rb | UTF-8 | 684 | 3.15625 | 3 | [] | no_license | module Sanitize
def sanitize_tag(wiki, tag)
pos = 0
start_part = tag[0..tag.length - 2]
tag_len = start_part.length
while pos < wiki.length
start_div_tag = wiki.index(start_part, pos)
if start_div_tag == nil then break end
pos = start_div_tag + tag_len
end_start_tag = wiki.index("... | true |
777dfd5a99616ec9aea586318e6b7a22dde8cca0 | Ruby | Burrick2003/oo-tic-tac-toe-v-000 | /lib/tic_tac_toe.rb | UTF-8 | 3,256 | 4.28125 | 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 = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
end
def play
until over? == true
turn
end
if won? != false
win_char = ... | true |
146258d7065d784eccea28b330b18b0e3a4c94a5 | Ruby | Dean-Delagrange/RB101 | /lesson_4/selected_vowels.rb | UTF-8 | 517 | 4 | 4 | [] | no_license | def select_vowels(str)
vowels = ''
counter = 0
loop do
current_chars = str[counter]
if 'aeiouAERIOU'.include?(current_chars)
vowels << current_chars
end
counter += 1
break if counter == str.length
end
vowels
end
select_vowels('the quick brown fox') # => "e... | true |
698dd7cebd157fe02302d6386a718aac30ab7265 | Ruby | RicardoRojo/launch_school | /exercism/nth-prime/nth_prime.rb | UTF-8 | 531 | 4.03125 | 4 | [] | no_license | require 'pry'
class Prime
attr_accessor :primes
def self.nth(number_of_primes)
raise ArgumentError if number_of_primes == 0
primes = []
i = 2
while primes.size < number_of_primes
if is_primo?(i,primes)
primes << i
end
i += 1
end
primes.last
end
... | true |
4dcc7412114a5e6d411bd280ee04dbed6c502248 | Ruby | Perez-png/ruby-instance-variables-lab-onl01-seng-pt-012220 | /lib/dog.rb | UTF-8 | 359 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
def name=(dog_name
this_dogs_name = dog_name
def name
this_dogs_name
end
end
lassie = Dog.new
lassie.name = "Lassie"
lassie.name #=> "Lassie"
end
class Dog
def name=(dog_name)
@this_dogs_name =
dog_name
end
def name
@this_dogs_name
end
end
lassie =Dog.new
lassie.na... | true |
39832adb264e7e1cf8ff1e3e5b1e1265cc966d64 | Ruby | Des-sk/apples-and-holidays-onl01-seng-pt-070620 | /lib/holiday.rb | UTF-8 | 1,791 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def second_supply_for_fourth_of_july(holiday_supplies)
holiday_supplies[:summer][:fourth_of_july][1]
end
def add_supply_to_winter_holidays(holiday_hash, supply)
# holiday_hash is identical to the one above
# add the second argument, which is a supply, to BOTH the
# Christmas AND the New Year's arrays
holiday... | true |
3344d255c2b0f8d5ee8168a70d8b6a6d231daa9d | Ruby | hpetru/pcap | /main.rb | UTF-8 | 1,504 | 2.578125 | 3 | [] | no_license | require 'pry'
require 'rest-client'
require 'nokogiri'
REGEXP = /(JSESSIONID|AUTHCODE)=([^;]+)/
APP_URI = 'http://odnoklassniki.ru'
sessions = []
in_file = 'cookies.txt'
users = []
File.open('users.json', 'r') do |file|
users_json = file.read
users_json = '[]' if users_json.empty?
users = JSON.parse(users_jso... | true |
1d588ee167df419369a8c68dc6c0cf8e0f128fdb | Ruby | CalieR/module-one-final-project-guidelines-london-web-career-021819 | /app/models/users.rb | UTF-8 | 5,010 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class User < ActiveRecord::Base
has_many :user_cards
has_many :cards, through: :user_cards
# calls 'choose_hero' to display all the cards to the user, and assigns their choice to 'card'
# TTY prompt for the yes/no menu
# if 'yes', creates a new row in the card table for that specific user_id,... | true |
61534cdfc8fb3f4aa8cd8d4f51bfb3d4e3d7afc6 | Ruby | Zlatov/lab | /ruby/file/file.rb | UTF-8 | 11,584 | 2.71875 | 3 | [] | no_license | # encoding: UTF-8
require 'fileutils'
require_relative '../colorize/colorize'
require 'json'
$stdout.sync = true
#
# somefile = File.open 'path_to_file'[, 'w+']
# somefile.flock = ...
# somefile.pos = ...
# somefile.truncate 0
# somefile.close
#
# или
#
# File.open 'path_to_file'[, 'w+'] do |file|
# file. ...
# e... | true |
12b2e9af1775db1b72e730135709e712929fcbfd | Ruby | sweiss3/cmder | /build.rb | UTF-8 | 3,160 | 2.703125 | 3 | [
"MIT"
] | permissive | # Samuel Vasko 2013
# Cmder build script
# Like really a beta
#
# This script downloads dependencies form google code. Each software is extracted
# in a folder with same name as the project on google code. So Conemu becomes
# conemu-maximus5. Correct files are beeing picked by using labels.
# I will move the script for... | true |
33e1f5a390c393eae14d265ec81911531296d66f | Ruby | johnfig/DBC-Exercises | /fibonnaci_2.rb | UTF-8 | 63 | 2.90625 | 3 | [] | no_license | def fibonacci(number)
first = 0
second = 1
end
fibonacci(7) | true |
e147bf0ec573ff7eaaab2d43f712fa6106f2e640 | Ruby | seanders/racer_oo | /app/controllers/index.rb | UTF-8 | 1,110 | 2.53125 | 3 | [] | no_license | get '/' do
# Look in app/views/index.erb
erb :index
end
post '/game' do
session.clear
@player1 = Player.where(name: params[:name1]).first_or_create
@player2 = Player.where(name: params[:name2]).first_or_create
session[:first_player] = @player1.id
session[:second_player] = @player2.id
@game = Game.crea... | true |
17099b74d5961e70967298896e932445dc74e022 | Ruby | Shaher-11/Ruby_small_projects | /cipher.rb | UTF-8 | 738 | 4.25 | 4 | [] | no_license |
def translate(string, shift) # we define the method and the para
string_array = string.split("").map do |char| # we have our chars and we use map to iterate over them
num_char = char.ord #gets the Integer ordinal of the char
if char.between?('a', 'z') ... | true |
5e2dff626f9566a2fc56b5ce2ba18a026e525db0 | Ruby | MikeSalisbury/Hangman | /lib/hangman.rb | UTF-8 | 3,106 | 3.65625 | 4 | [] | no_license | class Hangman
attr_reader :guesser, :referee, :board
def initialize(guesser: HumanPlayer.new, referee: ComputerPlayer.new)
@guesser = guesser
@referee = referee
@board = board
end
def setup
word = @referee.pick_secret_word
@board = Array.new(word)
@guesser.register_secret_length(word)
... | true |
bd876c32a093d1afdc25c59431683ccd468f554b | Ruby | bouyagas/learn-ruby-the-hard-way | /ex_25.rb | UTF-8 | 1,066 | 4.1875 | 4 | [] | no_license | module Ex25
# This functionn will break up words for us.
def Ex25.break_words(stuff)
words = stuff.split('')
return words
end
# Sort the words
def Ex25.sort_words
reurn words.sort
end
# Print the first words after shifting it off
def Ex25.print_first_words(words)
word = words.shift
puts word
end... | true |
af985d429e7eed2126f93816c6a328e58c8ecf14 | Ruby | jrosaaen/examples | /mvc_play/view.rb | UTF-8 | 237 | 2.90625 | 3 | [] | no_license | class View
def self.welcome
puts "Welcome!"
end
def self.username
print "Please enter username: "
end
def self.display_name
puts "Your name is awesome"
end
def self.display_user_name_error
puts "Username not found"
end
end
| true |
7672aaea626f92228cb902b782bfdff292f5109e | Ruby | leedu708/project_tdd_minesweeper | /spec/board_spec.rb | UTF-8 | 4,149 | 3.21875 | 3 | [] | no_license | require 'board'
require 'field'
describe Board do
let(:board) { Board.new }
let(:field) { board.get_field([1,1]) }
describe '#initialize' do
it 'properly initializes @flags_remaining to 10 by default' do
expect(board.flags_remaining).to eq(10)
end
end
describe '#init_board' do
it 'fill... | true |
23c3203360674b8607153468b4e1bd89a261fad0 | Ruby | kode-tiki/school-domain-v-000 | /lib/school.rb | UTF-8 | 517 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
def initialize(name)
@name = name
@roster = {}
end
def roster
@roster
end
def add_student(name, grade)
if @roster.key?(grade)
@roster[grade] << name
else
@roster[grade] = [name]
end
def grade(grade)
@roster[grade]
end
... | true |
5cea50f34e37c0005e522c7c003cc878507a9481 | Ruby | chenbd/ruby-programming-source | /ch-12/exercise.rb | UTF-8 | 627 | 3.703125 | 4 | [] | no_license | def cels2fahr(cels)
cels * 9.0 / 5.0 + 32.0
end
def fahr2cels(fahr)
(fahr.to_f - 32) * 5.0 / 9.0
end
1.upto(100) do |i|
print "fahr2cels(#{i})", fahr2cels(i), "\n"
end
1.upto(100) do |i|
print "cels2fahr(#{i})", cels2fahr(i), "\n"
end
def dice
Random.rand(6) + 1
end
def dice10
ret = 0
1... | true |
80b619730b4b004d4d6aeb35f069b64726939fce | Ruby | lcbeh/bank_tech_test | /spec/printer_spec.rb | UTF-8 | 471 | 2.578125 | 3 | [] | no_license | require 'printer'
require 'bank_account'
require 'transaction'
describe Printer do
subject(:printer) { Printer.new }
it "can prints a record of all the transactions" do
transactions = ["29/11/2016 || 500.00 || || 500.00 "]
statement = "date || credit || debit || balance ... | true |
cc3eb262156411c4f3f72d261a9c4d7168451ec3 | Ruby | scrubmx/CodeKatas | /ruby/fizzbuzz/fizzbuzz.rb | UTF-8 | 67 | 2.984375 | 3 | [] | no_license | class FizzBuzz
def convert(number)
return number.to_s
end
end | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.