Class: SyntaxTree::CSS::BasicVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/css/basic_visitor.rb

Overview

The parent class of all visitors that provides the double dispatch pattern. It doesn’t provide any of the aliases so it can’t actually be used to visit the tree. It’s used to implement visitors that should raise an error if a node that’s not implemented is visited.

Direct Known Subclasses

Format, PrettyPrint

Instance Method Summary collapse

Instance Method Details

#visit(node) ⇒ Object



10
11
12
# File 'lib/syntax_tree/css/basic_visitor.rb', line 10

def visit(node)
  node&.accept(self)
end

#visit_all(nodes) ⇒ Object



14
15
16
# File 'lib/syntax_tree/css/basic_visitor.rb', line 14

def visit_all(nodes)
  nodes.map { |node| visit(node) }
end

#visit_child_nodes(node) ⇒ Object



18
19
20
# File 'lib/syntax_tree/css/basic_visitor.rb', line 18

def visit_child_nodes(node)
  visit_all(node.child_nodes)
end