Class: Roodi::Core::CheckingVisitor
- Inherits:
-
Object
- Object
- Roodi::Core::CheckingVisitor
- Defined in:
- lib/roodi/core/checking_visitor.rb
Instance Method Summary collapse
-
#initialize(*checks) ⇒ CheckingVisitor
constructor
A new instance of CheckingVisitor.
- #visit(node) ⇒ Object
Constructor Details
#initialize(*checks) ⇒ CheckingVisitor
Returns a new instance of CheckingVisitor.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/roodi/core/checking_visitor.rb', line 4 def initialize(*checks) @checks ||= {} checks.first.each do |check| nodes = check.interesting_nodes nodes.each do |node| @checks[node] ||= [] @checks[node] << check @checks[node].uniq! end end end |
Instance Method Details
#visit(node) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/roodi/core/checking_visitor.rb', line 16 def visit(node) checks = @checks[node.node_type] checks.each {|check| check.evaluate_node_start(node)} unless checks.nil? node.visitable_children.each {|sexp| sexp.accept(self)} checks.each {|check| check.evaluate_node_end(node)} unless checks.nil? end |