Class: ZOMG::IDL::Visitors::Duhr

Inherits:
Object
  • Object
show all
Defined in:
lib/zomg/idl/visitors/duhr.rb

Overview

Stupid path navigation

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#treeObject

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_sexpObject



11
# File 'lib/zomg/idl/visitors/duhr.rb', line 11

def to_sexp; @tree.to_sexp; end