Class: ORB::AST::PrintingExpressionNode

Inherits:
AbstractNode show all
Defined in:
lib/orb/ast/printing_expression_node.rb

Overview

A node representing a printing expression

Constant Summary collapse

BLOCK_RE =
/\A(if|unless)\b|\bdo\s*(\|[^|]*\|)?\s*$/

Constants inherited from AbstractNode

AbstractNode::EMPTY_ARRAY

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#attributes, #children, #errors

Instance Method Summary collapse

Methods inherited from AbstractNode

#==, #add_child, #add_error

Constructor Details

#initialize(token) ⇒ PrintingExpressionNode

Returns a new instance of PrintingExpressionNode.



11
12
13
14
15
16
# File 'lib/orb/ast/printing_expression_node.rb', line 11

def initialize(token)
  super
  @expression = token.value
  @is_block = BLOCK_RE.match?(@expression)
  @is_end = @expression == 'end' || @expression.strip == 'end'
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



9
10
11
# File 'lib/orb/ast/printing_expression_node.rb', line 9

def expression
  @expression
end

Instance Method Details

#block?Boolean

Returns:

  • (Boolean)


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

def block?
  @is_block
end

#end?Boolean

Returns:

  • (Boolean)


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

def end?
  @is_end
end

#render(_context) ⇒ Object



26
27
28
# File 'lib/orb/ast/printing_expression_node.rb', line 26

def render(_context)
  "NOT IMPLEMENTED"
end