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.78 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.77 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.76 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.75 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.74 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.73 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.72 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.71 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.70 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.69 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.68 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.67 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.66 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.65 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.64 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.63 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.62 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.61 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.60 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.59 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb