Class: Puppet::Pops::Model::LiteralFloat

Inherits:
LiteralNumber show all
Defined in:
lib/puppet/pops/model/ast.rb

Instance Attribute Summary collapse

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#_pcore_all_contents, #_pcore_contents, #to_s

Methods included from Types::PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, value) ⇒ LiteralFloat

Returns a new instance of LiteralFloat.



3446
3447
3448
3449
3450
# File 'lib/puppet/pops/model/ast.rb', line 3446

def initialize(locator, offset, length, value)
  super(locator, offset, length)
  @hash = @hash ^ value.hash
  @value = value
end

Instance Attribute Details

#valueObject (readonly)



3444
3445
3446
# File 'lib/puppet/pops/model/ast.rb', line 3444

def value
  @value
end

Class Method Details

._pcore_typeObject



3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
# File 'lib/puppet/pops/model/ast.rb', line 3411

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType
      .new('Puppet::AST::LiteralFloat', {
             'parent' => LiteralNumber._pcore_type,
             'attributes' => {
               'value' => Types::PFloatType::DEFAULT
             }
           })
end

.create(locator, offset, length, value) ⇒ Object



3434
3435
3436
3437
3438
3439
3440
3441
3442
# File 'lib/puppet/pops/model/ast.rb', line 3434

def self.create(locator, offset, length, value)
  ta = Types::TypeAsserter
  attrs = _pcore_type.attributes(true)
  ta.assert_instance_of('Puppet::AST::Positioned[locator]', attrs['locator'].type, locator)
  ta.assert_instance_of('Puppet::AST::Positioned[offset]', attrs['offset'].type, offset)
  ta.assert_instance_of('Puppet::AST::Positioned[length]', attrs['length'].type, length)
  ta.assert_instance_of('Puppet::AST::LiteralFloat[value]', attrs['value'].type, value)
  new(locator, offset, length, value)
end

.from_asserted_hash(init_hash) ⇒ Object



3426
3427
3428
3429
3430
3431
3432
# File 'lib/puppet/pops/model/ast.rb', line 3426

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['value'])
end

.from_hash(init_hash) ⇒ Object



3422
3423
3424
# File 'lib/puppet/pops/model/ast.rb', line 3422

def self.from_hash(init_hash)
  from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::LiteralFloat initializer', _pcore_type.init_hash_type, init_hash))
end

Instance Method Details

#_pcore_init_hashObject



3452
3453
3454
3455
3456
# File 'lib/puppet/pops/model/ast.rb', line 3452

def _pcore_init_hash
  result = super
  result['value'] = @value
  result
end

#eql?(o) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


3458
3459
3460
3461
# File 'lib/puppet/pops/model/ast.rb', line 3458

def eql?(o)
  super &&
  @value.eql?(o.value)
end