Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

initial commit #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.bundle/
.gemtags
.tags
.tags_sorted_by_file
.tags_sorted_by_file
.idea
.byebug_history
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org' do
gem 'railties'

group :test do
gem 'byebug'
gem 'minitest', '~> 5.9', '>= 5.9.1'
gem 'minitest-reporters', '~> 1.1', '>= 1.1.12'
gem 'm', '~> 1.5.0'
end
end
75 changes: 75 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
GEM
remote: https://rubygems.org/
specs:
actionpack (5.0.0.1)
actionview (= 5.0.0.1)
activesupport (= 5.0.0.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.0.1)
activesupport (= 5.0.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
ansi (1.5.0)
builder (3.2.2)
byebug (9.0.6)
concurrent-ruby (1.0.2)
erubis (2.7.0)
i18n (0.7.0)
loofah (2.0.3)
nokogiri (>= 1.5.9)
m (1.5.0)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
method_source (0.8.2)
mini_portile2 (2.1.0)
minitest (5.9.1)
minitest-reporters (1.1.12)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
rack (2.0.1)
rack-test (0.6.3)
rack (>= 1.0)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.3.0)
ruby-progressbar (1.8.1)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby

DEPENDENCIES
byebug!
m (~> 1.5.0)!
minitest (~> 5.9, >= 5.9.1)!
minitest-reporters (~> 1.1, >= 1.1.12)!
railties!

BUNDLED WITH
1.13.6
36 changes: 36 additions & 0 deletions lib/bottles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'byebug'
require 'active_support'
require 'active_support/core_ext'

class Bottles
def song
verses(99, 0)
end

def verses(starting, ending)
starting.downto(ending).map {|i| verse(i)}.join("\n")
end

def verse(number)
if number > 1
<<-VERSE
#{number} #{pluralize_bottle(number)} of beer on the wall, #{number} #{pluralize_bottle(number)} of beer.
Take one down and pass it around, #{number-1} #{pluralize_bottle(number-1)} of beer on the wall.
VERSE
elsif number == 1
<<-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.
VERSE
elsif number == 0
<<-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.
VERSE
end
end

def pluralize_bottle(count)
'bottle'.pluralize(count)
end
end
Loading