Class: Puppet::Pops::PN::List

Inherits:
Object
  • Object
show all
Includes:
Puppet::Pops::PN
Defined in:
lib/puppet/pops/pn.rb

Constant Summary

Constants included from Puppet::Pops::PN

KEY_PATTERN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Puppet::Pops::PN

#==, #double_quote, #format_elements, #pnError, #to_s, #with_name

Constructor Details

#initialize(elements) ⇒ List

Returns a new instance of List


138
139
140
# File 'lib/puppet/pops/pn.rb', line 138

def initialize(elements)
  @elements = elements
end

Instance Attribute Details

#elementsObject (readonly)


136
137
138
# File 'lib/puppet/pops/pn.rb', line 136

def elements
  @elements
end

Instance Method Details

#[](idx) ⇒ Object


142
143
144
# File 'lib/puppet/pops/pn.rb', line 142

def [](idx)
  @elements[idx]
end

#as_call(name) ⇒ Object


146
147
148
# File 'lib/puppet/pops/pn.rb', line 146

def as_call(name)
  Call.new(name, *@elements)
end

#as_parametersObject


150
151
152
# File 'lib/puppet/pops/pn.rb', line 150

def as_parameters
  @elements
end

#eql?(o) ⇒ Boolean


154
155
156
# File 'lib/puppet/pops/pn.rb', line 154

def eql?(o)
  o.is_a?(List) && @elements == o.elements
end

#format(indent, b) ⇒ Object


158
159
160
161
162
# File 'lib/puppet/pops/pn.rb', line 158

def format(indent, b)
  b << '['
  format_elements(@elements, indent ? indent.increase : nil, b) unless @elements.empty?
  b << ']'
end

#to_dataObject


164
165
166
# File 'lib/puppet/pops/pn.rb', line 164

def to_data
  @elements.map { |e| e.to_data }
end