Class: Puppet::Pops::Model::LiteralInteger

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, radix = 10) ⇒ LiteralInteger

Returns a new instance of LiteralInteger


3508
3509
3510
3511
3512
3513
# File 'lib/puppet/pops/model/ast.rb', line 3508

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

Instance Attribute Details

#radixObject (readonly)


3505
3506
3507
# File 'lib/puppet/pops/model/ast.rb', line 3505

def radix
  @radix
end

#valueObject (readonly)


3506
3507
3508
# File 'lib/puppet/pops/model/ast.rb', line 3506

def value
  @value
end

Class Method Details

._pcore_typeObject


3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
# File 'lib/puppet/pops/model/ast.rb', line 3468

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::LiteralInteger', {
    'parent' => LiteralNumber._pcore_type,
    'attributes' => {
      'radix' => {
        'type' => Types::PIntegerType::DEFAULT,
        'value' => 10
      },
      'value' => Types::PIntegerType::DEFAULT
    }
  })
end

.create(locator, offset, length, value, radix = 10) ⇒ Object


3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
# File 'lib/puppet/pops/model/ast.rb', line 3494

def self.create(locator, offset, length, value, radix = 10)
  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::LiteralInteger[radix]', attrs['radix'].type, radix)
  ta.assert_instance_of('Puppet::AST::LiteralInteger[value]', attrs['value'].type, value)
  new(locator, offset, length, value, radix)
end

.from_asserted_hash(init_hash) ⇒ Object


3485
3486
3487
3488
3489
3490
3491
3492
# File 'lib/puppet/pops/model/ast.rb', line 3485

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['value'],
    init_hash.fetch('radix') { 10 })
end

.from_hash(init_hash) ⇒ Object


3481
3482
3483
# File 'lib/puppet/pops/model/ast.rb', line 3481

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

Instance Method Details

#_pcore_init_hashObject


3515
3516
3517
3518
3519
3520
# File 'lib/puppet/pops/model/ast.rb', line 3515

def _pcore_init_hash
  result = super
  result['radix'] = @radix unless @radix == 10
  result['value'] = @value
  result
end

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


3522
3523
3524
3525
3526
# File 'lib/puppet/pops/model/ast.rb', line 3522

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