Skip to content

Instantly share code, notes, and snippets.

@anewusername1
Created January 18, 2012 21:45
Show Gist options
  • Save anewusername1/1635930 to your computer and use it in GitHub Desktop.
Save anewusername1/1635930 to your computer and use it in GitHub Desktop.
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