Created
December 13, 2011 05:08
-
-
Save mike-burns/1470690 to your computer and use it in GitHub Desktop.
latte art
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 Coffee | |
def cost | |
2.0 | |
end | |
def origin | |
"Columbia" | |
end | |
end | |
class MilkDecorator | |
def initialize(drink) | |
@drink = drink | |
end | |
def cost | |
@drink.cost + 0.4 | |
end | |
def method_missing(meth, *args) | |
if @drink.respond_to?(meth) | |
@drink.send(meth, *args) | |
else | |
super | |
end | |
end | |
def respond_to?(meth) | |
@drink.respond_to?(meth) | |
end | |
end | |
class SugarDecorator | |
def initialize(drink) | |
@drink = drink | |
end | |
def cost | |
@drink.cost + 0.2 | |
end | |
def method_missing(meth, *args) | |
if @drink.respond_to?(meth) | |
@drink.send(meth, *args) | |
else | |
super | |
end | |
end | |
def respond_to?(meth) | |
@drink.respond_to?(meth) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment