Class: Puppet::Pops::PN::Literal

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

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

Constructor Details

#initialize(value) ⇒ Literal

Returns a new instance of Literal


173
174
175
# File 'lib/puppet/pops/pn.rb', line 173

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)


171
172
173
# File 'lib/puppet/pops/pn.rb', line 171

def value
  @value
end

Instance Method Details

#eql?(o) ⇒ Boolean


187
188
189
# File 'lib/puppet/pops/pn.rb', line 187

def eql?(o)
  o.is_a?(Literal) && @value == o.value
end

#format(indent, b) ⇒ Object


177
178
179
180
181
182
183
184
185
# File 'lib/puppet/pops/pn.rb', line 177

def format(indent, b)
  if @value.nil?
    b << 'nil'
  elsif value.is_a?(String)
    double_quote(value, b)
  else
    b << value.to_s
  end
end

#to_dataObject


191
192
193
# File 'lib/puppet/pops/pn.rb', line 191

def to_data
  @value
end