I hereby claim:
- I am oinak on github.
- I am oinak (https://keybase.io/oinak) on keybase.
- I have a public key whose fingerprint is 02CA 3672 C423 0B10 014D 05F2 6668 B7D8 8FA5 D8AC
To claim this, I am signing this object:
module Donor | |
def foo(extra) | |
puts "bar #{extra}" | |
end | |
def not_foo | |
puts "not bar" | |
end | |
end |
I hereby claim:
To claim this, I am signing this object:
This is a Ruby version of the Gilded Rose Kata, found [here](http://www.iamnotmyself.com/2011/02/13/RefactorThisTheGildedRoseKata.aspx I Am Not Myself).
This is a refactorying kata, so you will be starting with a legacy code base. To work the Kata, clone this git repository and checkout the tag 'start-here'. Read the description below for the "rules" involving this kata.
module Includeable | |
def have_module | |
"metodo desde Includeable" | |
end | |
def self.included(mod) | |
puts "Includeable incluido en #{mod}" | |
end | |
end | |
class First |
module TicTacToe | |
class Game | |
def self.play | |
new.run | |
end | |
def players | |
@players ||= %w(X O).cycle | |
end |
>> h = {true => '1 is odd', false => '1 is even'} | |
=> {true=>"1 is odd", false=>"1 is even"} | |
>> h[true] | |
=> "1 is odd" | |
>> h = {1.odd? => '1 is odd', 1.even? => '1 is even'} | |
=> {true=>"1 is odd", false=>"1 is even"} | |
>> h[true] | |
=> "1 is odd" |
Upon reading I decided to try an implement Sandi's concept before lookig at her code.
It wasn't worth a dime in comparison, but after reading her code, I decided to try and improvise from there.
Of course, this is no more than remixing the composition from a genius to feel your own style on it. But it was a interesting exercise. I opted for a module with no state and pure functions.
source 'https://rubygems.org' | |
ruby '2.3.0' | |
gem 'sinatra' |
class Bottles | |
def song | |
verses(99, 0) | |
end | |
def verse(n) | |
<<-END | |
#{bottles(n).capitalize} on the wall, #{bottles(n)}. | |
#{what_now(n)}, #{bottles(n-1)} on the wall. |