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.



7
8
9
10
# File 'lib/xamplr/visitors.rb', line 7

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.



5
6
7
# File 'lib/xamplr/visitors.rb', line 5

def count
  @count
end

Instance Method Details

#before_visit(xampl) ⇒ Object



12
13
14
# File 'lib/xamplr/visitors.rb', line 12

def before_visit(xampl)
  @count += 1
end