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.180 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.179 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.178 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.177 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.176 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.175 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.174 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.173 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.172 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.171 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.170 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.169 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.167 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.166 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.165 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.164 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.163 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.162 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.161 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb
trackler-2.2.1.160 tracks/ruby/exercises/beer-song/.meta/solutions/beer_song.rb