Skip to content
This repository was archived by the owner on Feb 13, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/bottles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Bottles
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

def verses(from, to)
from.downto(to).map { |e| verse(e) }.join("\n")
end

def song
verses(99, 0)
end
end
7 changes: 0 additions & 7 deletions test/bottles_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_the_first_verse
end

def test_another_verse
skip
expected = <<-VERSE
89 bottles of beer on the wall, 89 bottles of beer.
Take one down and pass it around, 88 bottles of beer on the wall.
Expand All @@ -21,7 +20,6 @@ def test_another_verse
end

def test_verse_2
skip
expected = <<-VERSE
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
Expand All @@ -30,7 +28,6 @@ def test_verse_2
end

def test_verse_1
skip
expected = <<-VERSE
1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.
Expand All @@ -39,7 +36,6 @@ def test_verse_1
end

def test_verse_0
skip
expected = <<-VERSE
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
Expand All @@ -48,7 +44,6 @@ def test_verse_0
end

def test_a_couple_verses
skip
expected = <<-VERSES
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
Expand All @@ -60,7 +55,6 @@ def test_a_couple_verses
end

def test_a_few_verses
skip
expected = <<-VERSES
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
Expand All @@ -75,7 +69,6 @@ def test_a_few_verses
end

def test_the_whole_song
skip
expected = <<-SONG
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
Expand Down