Created
January 30, 2011 21:08
-
-
Save weatheredwatcher/803254 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Pizza | |
def initialize(&factory) | |
@factory = factory | |
end | |
def bake | |
@factory.call | |
end | |
end | |
a = Pizza.new { puts 'This is a Cheese Pizza' } | |
a.bake #=> Making A Regular Cheese Pizza | |
b = Pizza.new { puts 'This is a Pepperoni Pizza' } | |
b.bake #=> Making a Pepperoni Pizza | |
c = Pizza.new { puts 'This is a Deluxe Pizza' } | |
c.bake #=> Making a Deluxe Pizza | |
system("stty raw -echo") #=> Raw mode, no echo | |
char = STDIN.getc | |
until char == 113 | |
case char | |
when 97 | |
a.bake | |
when 98 | |
b.bake | |
when 99 | |
c.bake | |
when 113 | |
else | |
"error" | |
end | |
char = STDIN.getc | |
end | |
system("stty -raw echo") #=> Reset terminal mode | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment