Created
May 5, 2015 02:31
-
-
Save anonymous/8deaba7f10190285bae5 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
module DefaultOrder | |
module_function | |
def order(data) | |
data | |
end | |
end | |
module RandomOrder | |
module_function | |
def order(data) | |
data.shuffle | |
end | |
end | |
class House | |
DATA =[ | |
"the cat that killed", | |
"the rat that ate", | |
"the malt that lay in", | |
"the house that Jack built" | |
] | |
def initialize | |
@data = orderer.order(DATA) | |
end | |
def recite | |
([email protected]).map {|i| line(i)}.join("\n") | |
end | |
def line(number) | |
"This is #{phrase(number)}.\n" | |
end | |
def phrase(number) | |
@data.last(number).join(" ") | |
end | |
def orderer | |
DefaultOrder | |
end | |
end | |
class RandomHouse < House | |
def orderer | |
RandomOrder | |
end | |
end | |
puts House.new.recite | |
puts "="*88 | |
puts "="*88 | |
puts "="*88 | |
puts RandomHouse.new.recite |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment