Class: NodeQuery::ParserAdapter
- Inherits:
-
Object
- Object
- NodeQuery::ParserAdapter
- Defined in:
- lib/node_query/adapter/parser.rb
Instance Method Summary collapse
- #get_children(node) ⇒ Object
- #get_node_type(node) ⇒ Object
- #get_siblings(node) ⇒ Object
- #get_source(node) ⇒ Object
- #is_node?(node) ⇒ Boolean
Instance Method Details
#get_children(node) ⇒ Object
19 20 21 |
# File 'lib/node_query/adapter/parser.rb', line 19 def get_children(node) node.children end |
#get_node_type(node) ⇒ Object
11 12 13 |
# File 'lib/node_query/adapter/parser.rb', line 11 def get_node_type(node) node.type end |
#get_siblings(node) ⇒ Object
23 24 25 26 |
# File 'lib/node_query/adapter/parser.rb', line 23 def get_siblings(node) index = node.parent.children.index(node) node.parent.children[index + 1..] end |
#get_source(node) ⇒ Object
15 16 17 |
# File 'lib/node_query/adapter/parser.rb', line 15 def get_source(node) node.loc.expression.source end |
#is_node?(node) ⇒ Boolean
7 8 9 |
# File 'lib/node_query/adapter/parser.rb', line 7 def is_node?(node) node.is_a?(Parser::AST::Node) end |