-
-
Save danvideo/7244313 to your computer and use it in GitHub Desktop.
class BottlesOfBeer | |
def count_off | |
puts "How many bottles of beer have you got? " | |
numbers = gets.chomp.to_i | |
numbers.downto(1) do |number| | |
puts "#{number} bottles of beer on the wall, #{number} bottles of beer! Take one down, pass it around, #{number-1} bottles of beer on the wall!" | |
end | |
end | |
bottle = BottlesOfBeer.new | |
bottle.count_off | |
end |
oh cool, didn't realize you commented/added (too bad gists don't send out notifications)
nice, good work chris - heh I was so tired I totally forgot about the end of the song
thanks
after trying this I saw a site that rates a bunch of "bottle" versions. I don't completely follow what the highly rated ruby one is doing, but you might want to take a look:
http://www.99-bottles-of-beer.net/language-ruby-1272.html
Hey guys - I also forked and added stuff. I made a pluralize?
method that figures out if bottle should be "bottle" or "bottles" so the string doesn't have to be written out again for 1 bottle of beer. https://gist.github.com/daniellermcd/7252130
👍
Love it!
I'm at work right now, so I'll post later. I added an 'elsif' so the '1 bottle of beer line' so now reads: "1 bottle of beer on the wall, 1 bottle of beer! Take one down, pass it around, No more bottles of beer on the wall". I also added if number.zero? on line 14.
My try! https://gist.github.com/StevenNunez/7253815 The first one is more readable...
ha - great. don't have ruby on my office computer so trying to map it out in my head... definitely need to take a deeper look later
The short one was a bit obtuse on purpose. The word you want to look for is lambda
Late to the party but here's my attempt! https://gist.github.com/christianmendoza/7293928
Haha this is great! I forked it and made a few changes to get the last two verses correct: https://gist.github.com/chriskuruc/7244582