Class: Puppet::Pops::PN::Call

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(name, *elements) ⇒ Call

Returns a new instance of Call.



86
87
88
89
# File 'lib/puppet/pops/pn.rb', line 86

def initialize(name, *elements)
  @name = name
  @elements = elements
end

Instance Attribute Details

#elementsObject (readonly)



84
85
86
# File 'lib/puppet/pops/pn.rb', line 84

def elements
  @elements
end

#nameObject (readonly)



84
85
86
# File 'lib/puppet/pops/pn.rb', line 84

def name
  @name
end

Instance Method Details

#[](idx) ⇒ Object



91
92
93
# File 'lib/puppet/pops/pn.rb', line 91

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

#as_call(name) ⇒ Object



95
96
97
# File 'lib/puppet/pops/pn.rb', line 95

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

#as_parametersObject



99
100
101
# File 'lib/puppet/pops/pn.rb', line 99

def as_parameters
  List.new(@elements)
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/puppet/pops/pn.rb', line 103

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

#format(indent, b) ⇒ Object



107
108
109
110
111
112
113
114
# File 'lib/puppet/pops/pn.rb', line 107

def format(indent, b)
  b << '(' << @name
  if @elements.size > 0
    b << ' ' unless indent
    format_elements(@elements, indent ? indent.increase : nil, b)
  end
  b << ')'
end

#to_dataObject



116
117
118
# File 'lib/puppet/pops/pn.rb', line 116

def to_data
  { '^' => [@name] + @elements.map { |e| e.to_data } }
end