Created
December 23, 2011 14:24
-
-
Save walterdavis/1514334 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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