Class: StyleScript::ArrayNode
Overview
An array literal.
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.
746 747 748 |
# File 'lib/style_script/nodes.rb', line 746 def initialize(objects=[]) @objects = objects end |
Instance Method Details
#compile_node(o) ⇒ Object
750 751 752 753 754 755 756 757 758 759 |
# File 'lib/style_script/nodes.rb', line 750 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 |