Class: Xampl::CountingVisitor

Inherits:
Visitor
  • Object
show all
Defined in:
lib/xamplr/visitors.rb

Instance Attribute Summary collapse

Attributes inherited from Visitor

#done, #no_children, #no_siblings

Instance Method Summary collapse

Methods inherited from Visitor

#after_visit, #around_visit, #cycle, #method_missing, #reset, #revisit, #short_circuit, #start, #substitute_in_visit, #visit_string

Constructor Details

#initializeCountingVisitor

Returns a new instance of CountingVisitor.



30
31
32
33
# File 'lib/xamplr/visitors.rb', line 30

def initialize
  super
  @count = 0
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Xampl::Visitor

Instance Attribute Details

#countObject

Returns the value of attribute count.



28
29
30
# File 'lib/xamplr/visitors.rb', line 28

def count
  @count
end

Instance Method Details

#before_visit(xampl) ⇒ Object



35
36
37
# File 'lib/xamplr/visitors.rb', line 35

def before_visit(xampl)
  @count += 1
end