Class: ORB::AST::ControlExpressionNode

Inherits:
AbstractNode show all
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*$/

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#attributes, #children, #errors

Instance Method Summary collapse

Methods inherited from AbstractNode

#==, #add_child, #render

Constructor Details

#initialize(token) ⇒ ControlExpressionNode

Returns a new instance of ControlExpressionNode.



13
14
15
16
# File 'lib/orb/ast/control_expression_node.rb', line 13

def initialize(token)
  super
  @expression = token.value
end

Instance Attribute Details

#expressionObject (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

Returns:

  • (Boolean)


18
19
20
# File 'lib/orb/ast/control_expression_node.rb', line 18

def block?
  @expression =~ BLOCK_RE
end

#end?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/orb/ast/control_expression_node.rb', line 22

def end?
  @expression.strip == 'end'
end