Class: NScript::ArrayNode
Constant Summary
Constants inherited from Node
Instance Method Summary collapse
- #compile_node(o) ⇒ Object
-
#initialize(objects = []) ⇒ ArrayNode
constructor
A new instance of ArrayNode.
Methods inherited from Node
#children, children, #compile, #compile_closure, #contains?, #idt, statement, #statement?, statement_only, #statement_only?, top_sensitive, #top_sensitive?, #unwrap, #write
Constructor Details
#initialize(objects = []) ⇒ ArrayNode
Returns a new instance of ArrayNode.
655 656 657 |
# File 'lib/nscript/parser/nodes.rb', line 655 def initialize(objects=[]) @objects = objects end |
Instance Method Details
#compile_node(o) ⇒ Object
659 660 661 662 663 664 665 666 667 668 |
# File 'lib/nscript/parser/nodes.rb', line 659 def compile_node(o) o[:indent] = idt(1) objects = @objects.map { |obj| code = obj.compile(o) obj.is_a?(CommentNode) ? "\n#{code}\n#{o[:indent]}" : obj == @objects.last ? code : "#{code}, " }.join('') ending = objects.include?("\n") ? "\n#{idt}]" : ']' write("[#{objects}#{ending}") end |