Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created December 23, 2011 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/1514334 to your computer and use it in GitHub Desktop.
Save walterdavis/1514334 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -wKU
verse = "start bottles of beer on the wall,\nstart bottles of beer...\nYou take one down, pass it around,\nnext bottles of beer on the wall!\n\n"
class Numeric
#add ' more' to the end of one-syllable numbers, returning a string
#useful in auto-generated poetry to smooth out the scansion when a short-sounding number is used
def add_more
self.to_s + ([1,2,3,4,5,6,7,8,9,10,12].include?( self ) ? ' more' : '')
end
end
99.downto(1) do |d|
puts verse.gsub(/start/,d.add_more).sub(/next/,(d-1).add_more).gsub(/\b1( more)? bottles/,'1 more bottle').gsub(/\b0 bottles/,'No more bottles')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment