Over a million developers have joined DZone.

99 Bottles Of Beer And A Meta Bottle

·
module MetaBottle
  def self.make(x)
    Class.new do
      define_method(:bottle) do
        case x
        when 0 then "no more bottles"
        when 1 then "1 bottle"
        else        "#{x} bottles"
        end + " of beer"
      end
      define_method(:bottle_minus_one) do
        case x - 1
        when 0 then "no more bottles"
        when 1 then "1 bottle"
        else        "#{x} bottles"
        end + " of beer"
      end
      define_method(:to_s) do
        return <
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}