Class: ZOMG::IDL::Visitors::Duhr
- Inherits:
-
Object
- Object
- ZOMG::IDL::Visitors::Duhr
- Defined in:
- lib/zomg/idl/visitors/duhr.rb
Overview
Stupid path navigation
Instance Attribute Summary collapse
-
#tree ⇒ Object
Returns the value of attribute tree.
Instance Method Summary collapse
- #[](i) ⇒ Object
-
#initialize(tree) ⇒ Duhr
constructor
A new instance of Duhr.
- #method_missing(sym, *args) ⇒ Object
- #to_sexp ⇒ Object
Constructor Details
#initialize(tree) ⇒ Duhr
Returns a new instance of Duhr.
7 8 9 |
# File 'lib/zomg/idl/visitors/duhr.rb', line 7 def initialize(tree) @tree = tree end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
17 18 19 20 |
# File 'lib/zomg/idl/visitors/duhr.rb', line 17 def method_missing(sym, *args) klass = ZOMG::IDL::Nodes.const_get(sym) Duhr.new(tree.children.find_all { |child| child.is_a?(klass) }) end |
Instance Attribute Details
#tree ⇒ Object
Returns the value of attribute tree.
6 7 8 |
# File 'lib/zomg/idl/visitors/duhr.rb', line 6 def tree @tree end |
Instance Method Details
#[](i) ⇒ Object
13 14 15 |
# File 'lib/zomg/idl/visitors/duhr.rb', line 13 def [](i) Duhr.new(@tree[i]) end |
#to_sexp ⇒ Object
11 |
# File 'lib/zomg/idl/visitors/duhr.rb', line 11 def to_sexp; @tree.to_sexp; end |