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.



88
89
90
91
# File 'lib/puppet/pops/pn.rb', line 88

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

Instance Attribute Details

#elementsObject (readonly)



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

def elements
  @elements
end

#nameObject (readonly)



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

def name
  @name
end

Instance Method Details

#[](idx) ⇒ Object



93
94
95
# File 'lib/puppet/pops/pn.rb', line 93

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

#as_call(name) ⇒ Object



97
98
99
# File 'lib/puppet/pops/pn.rb', line 97

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

#as_parametersObject



101
102
103
# File 'lib/puppet/pops/pn.rb', line 101

def as_parameters
  List.new(@elements)
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/puppet/pops/pn.rb', line 105

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

#format(indent, b) ⇒ Object



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

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



118
119
120
# File 'lib/puppet/pops/pn.rb', line 118

def to_data
  { '^' => [@name] + @elements.map(&:to_data) }
end