Sha256: f9045ea6f44456652a0a63862ed096ef1add6c673b8927d9d83a262b7d3bcd2f

Contents?: true

Size: 872 Bytes

Versions: 277

Compression:

Stored size: 872 Bytes

Contents

module BookKeeping
  VERSION = 3
end

class BeerSong
  def verses(upper_bound, lower_bound)
    upper_bound.downto(lower_bound).map { |i| verse(i) }.join("\n")
  end

  def verse(number)
    case number
    when 0
      "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
    when 1
      "%s bottle of beer on the wall, %s bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n" % [number, number]
    when 2
      "%s bottles of beer on the wall, %s bottles of beer.\nTake one down and pass it around, %s bottle of beer on the wall.\n" % [number, number, number - 1]
    else
      "%s bottles of beer on the wall, %s bottles of beer.\nTake one down and pass it around, %s bottles of beer on the wall.\n" % [number, number, number - 1]
    end
  end
end

Version data entries

277 entries across 277 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.97 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.96 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.95 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.94 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.93 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.92 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.91 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.90 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.89 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.88 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.87 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.86 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.85 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.84 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.83 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.82 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.81 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.80 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.79 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb