Class: Ruby::Aggregate

Inherits:
Node show all
Defined in:
lib/ruby/aggregate.rb

Direct Known Subclasses

Assignment, Assoc, Call, DelimitedAggregate, List, Range

Instance Attribute Summary

Attributes included from Node::Composite

#parent

Instance Method Summary collapse

Methods inherited from Node

#<=>, #all_nodes, #column, #length, #nodes, #row

Methods included from Conversions

included, #to_node

Methods included from Node::Traversal

#has_token?, #has_type?, #has_value?, #is_instance_of?, #left_of?, #matches?, #position?, #right_of?, #select

Methods included from Node::Source

#context, #filename, #line, #lines, #src

Methods included from Node::Composite

included, #root, #root?

Instance Method Details

#position(prolog = false) ⇒ Object



5
6
7
8
9
# File 'lib/ruby/aggregate.rb', line 5

def position(prolog = false)
  nodes = self.nodes
  nodes.unshift(self.prolog) if prolog
  nodes.compact.each { |n| return n.position.dup if n } && nil
end

#position=(position) ⇒ Object



11
12
13
# File 'lib/ruby/aggregate.rb', line 11

def position=(position)
  nodes.each { |n| return n.position = position if n }
end

#prologObject



15
16
17
# File 'lib/ruby/aggregate.rb', line 15

def prolog
  nodes.each { |n| return n.prolog if n } && nil
end

#prolog=(prolog) ⇒ Object



19
20
21
# File 'lib/ruby/aggregate.rb', line 19

def prolog=(prolog)
  nodes.each { |n| return n.prolog = prolog if n }
end

#to_ruby(prolog = false) ⇒ Object



23
24
25
26
# File 'lib/ruby/aggregate.rb', line 23

def to_ruby(prolog = false)
  nodes = self.nodes.compact
  (nodes.shift.try(:to_ruby, prolog) || '') + nodes.map { |node| node.to_ruby(true) }.join
end