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.



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

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

Instance Attribute Details

#elementsObject (readonly)



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

def elements
  @elements
end

#nameObject (readonly)



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

def name
  @name
end

Instance Method Details

#[](idx) ⇒ Object



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

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

#as_call(name) ⇒ Object



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

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

#as_parametersObject



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

def as_parameters
  List.new(@elements)
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#format(indent, b) ⇒ Object



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

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



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

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