Last active
July 16, 2017 16:10
-
-
Save Sihui/bd082dae745ba0be0e9b1bc482957edb to your computer and use it in GitHub Desktop.
Design Pattern: Decorator and Waffle
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
class StrawberryWaffle | |
attr_reader :waffle | |
attr_accessor :topping | |
def initialize(waffle) | |
@waffle = waffle | |
@topping = 'strawberries' | |
end | |
def serve | |
waffle.serve | |
puts " topped with #{topping}" | |
end | |
def eat | |
waffle.eat | |
puts " and then eat some #{topping}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment