Class: Emf::Model::Visitor
- Inherits:
-
Object
- Object
- Emf::Model::Visitor
- Defined in:
- lib/emf/model/visitor.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.visit_methods ⇒ Object
readonly
Returns the value of attribute visit_methods.
Class Method Summary collapse
-
.register_visit(name, record_class) ⇒ Object
Record classes call this to declare a visit method name.
-
.visit_all(visitor, metafile) ⇒ Object
Walk every record in the metafile (and a nested EMF+ sub-stream if any), dispatching to the matching visit_* method.
Instance Method Summary collapse
Class Attribute Details
.visit_methods ⇒ Object (readonly)
Returns the value of attribute visit_methods.
19 20 21 |
# File 'lib/emf/model/visitor.rb', line 19 def visit_methods @visit_methods end |
Class Method Details
.register_visit(name, record_class) ⇒ Object
Record classes call this to declare a visit method name. The base class installs a no-op default so subclasses can override only what they need.
12 13 14 15 16 17 |
# File 'lib/emf/model/visitor.rb', line 12 def register_visit(name, record_class) @visit_methods[name] = record_class return if method_defined?(name) define_method(name) { |_| nil } end |
.visit_all(visitor, metafile) ⇒ Object
Walk every record in the metafile (and a nested EMF+ sub-stream if any), dispatching to the matching visit_* method.
23 24 25 26 27 28 |
# File 'lib/emf/model/visitor.rb', line 23 def visit_all(visitor, ) .each { |record| record.accept(visitor) } nested = .emf_plus visit_all(visitor, nested) if nested.is_a?(Emf::Model::Metafile) visitor end |
Instance Method Details
#visit(record) ⇒ Object
31 32 33 34 |
# File 'lib/emf/model/visitor.rb', line 31 def visit(record) record.accept(self) self end |
#visit_all(metafile) ⇒ Object
36 37 38 39 |
# File 'lib/emf/model/visitor.rb', line 36 def visit_all() self.class.visit_all(self, ) self end |