Class: ORB::AST::ControlExpressionNode
- Inherits:
-
AbstractNode
- Object
- AbstractNode
- ORB::AST::ControlExpressionNode
- Defined in:
- lib/orb/ast/control_expression_node.rb
Overview
A node representing a non-printing expression Non-printing expressions are used for control flow and variable assignment. Any output from a non-printing expression is captured and discarded.
Constant Summary collapse
- BLOCK_RE =
/\A(if|unless)\b|\bdo\s*(\|[^|]*\|)?\s*$/
Constants inherited from AbstractNode
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
Attributes inherited from AbstractNode
#attributes, #children, #errors
Instance Method Summary collapse
- #block? ⇒ Boolean
- #end? ⇒ Boolean
-
#initialize(token) ⇒ ControlExpressionNode
constructor
A new instance of ControlExpressionNode.
Methods inherited from AbstractNode
#==, #add_child, #add_error, #render
Constructor Details
#initialize(token) ⇒ ControlExpressionNode
Returns a new instance of ControlExpressionNode.
13 14 15 16 17 18 |
# File 'lib/orb/ast/control_expression_node.rb', line 13 def initialize(token) super @expression = token.value @is_block = BLOCK_RE.match?(@expression) @is_end = @expression == 'end' || @expression.strip == 'end' end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
11 12 13 |
# File 'lib/orb/ast/control_expression_node.rb', line 11 def expression @expression end |
Instance Method Details
#block? ⇒ Boolean
20 21 22 |
# File 'lib/orb/ast/control_expression_node.rb', line 20 def block? @is_block end |
#end? ⇒ Boolean
24 25 26 |
# File 'lib/orb/ast/control_expression_node.rb', line 24 def end? @is_end end |