-
Notifications
You must be signed in to change notification settings - Fork 0
/
bottles.rb
29 lines (27 loc) · 866 Bytes
/
bottles.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Bottles
def song
verses(99,0)
end
def verses(starting, ending)
starting
.downto(ending)
.map { |number| verse(number) }
.join("\n")
end
def verse(number)
case number
when 0
"No more bottles of beer on the wall, no more bottles of beer.\n" +
"Go to the store and buy some more, 99 bottles of beer on the wall.\n"
when 1
"1 bottle of beer on the wall, 1 bottle of beer.\n" +
"Take it down and pass it around, no more bottles of beer on the wall.\n"
when 2
"2 bottles of beer on the wall, 2 bottles of beer.\n" +
"Take one down and pass it around, 1 bottle of beer on the wall.\n"
else
"#{number} bottles of beer on the wall, #{number} bottles of beer.\n" +
"Take one down and pass it around, #{number - 1} bottles of beer on the wall.\n"
end
end
end