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.



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

def initialize(elements)
  @elements = elements
end

Instance Attribute Details

#elementsObject (readonly)



140
141
142
# File 'lib/puppet/pops/pn.rb', line 140

def elements
  @elements
end

Instance Method Details

#[](idx) ⇒ Object



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

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

#as_call(name) ⇒ Object



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

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

#as_parametersObject



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

def as_parameters
  @elements
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#format(indent, b) ⇒ Object



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

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

#to_dataObject



168
169
170
# File 'lib/puppet/pops/pn.rb', line 168

def to_data
  @elements.map(&:to_data)
end