Created
January 18, 2012 21:45
-
-
Save anewusername1/1635930 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
class CarElement | |
# force subclasses to override the accept method | |
def accept(visitor) | |
raise NotImpelementedError.new | |
end | |
end | |
class Wheel < CarElement | |
include Visitable # now we have the 'accept' method | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
class Engine < CarElement | |
include Visitable # now we have the 'accept' method | |
end | |
class Body < CarElement | |
include Visitable # now we have the 'accept' method | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment