Class: SolidRail::Parser::ASTNode
- Inherits:
-
Object
- Object
- SolidRail::Parser::ASTNode
- Defined in:
- lib/solidrail/parser.rb
Overview
AST Node representation
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(node_data) ⇒ ASTNode
constructor
A new instance of ASTNode.
- #method_missing(method_name, *args) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(node_data) ⇒ ASTNode
Returns a new instance of ASTNode.
21 22 23 24 25 26 27 28 29 |
# File 'lib/solidrail/parser.rb', line 21 def initialize(node_data) if node_data.is_a?(Array) && node_data.length >= 2 @type = node_data[0] @children = node_data[1..].compact.map { |child| ASTNode.new(child) } else @type = :literal @value = node_data end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/solidrail/parser.rb', line 31 def method_missing(method_name, *args) if method_name.to_s.end_with?('?') type == method_name.to_s.chomp('?').to_sym else super end end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
19 20 21 |
# File 'lib/solidrail/parser.rb', line 19 def children @children end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
19 20 21 |
# File 'lib/solidrail/parser.rb', line 19 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
19 20 21 |
# File 'lib/solidrail/parser.rb', line 19 def line @line end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
19 20 21 |
# File 'lib/solidrail/parser.rb', line 19 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
19 20 21 |
# File 'lib/solidrail/parser.rb', line 19 def value @value end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
39 40 41 |
# File 'lib/solidrail/parser.rb', line 39 def respond_to_missing?(method_name, include_private = false) method_name.to_s.end_with?('?') || super end |