Class: Puppet::Pops::Model::LiteralInteger
- Inherits:
-
LiteralNumber
- Object
- PopsObject
- Positioned
- Expression
- Literal
- LiteralValue
- LiteralNumber
- Puppet::Pops::Model::LiteralInteger
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #radix ⇒ Object readonly
- #value ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, value, radix = 10) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, value, radix = 10) ⇒ LiteralInteger
constructor
A new instance of LiteralInteger.
Methods inherited from Positioned
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.
3318 3319 3320 3321 3322 3323 |
# File 'lib/puppet/pops/model/ast.rb', line 3318 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
#radix ⇒ Object (readonly)
3315 3316 3317 |
# File 'lib/puppet/pops/model/ast.rb', line 3315 def radix @radix end |
#value ⇒ Object (readonly)
3316 3317 3318 |
# File 'lib/puppet/pops/model/ast.rb', line 3316 def value @value end |
Class Method Details
._pcore_type ⇒ Object
3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 |
# File 'lib/puppet/pops/model/ast.rb', line 3278 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
3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 |
# File 'lib/puppet/pops/model/ast.rb', line 3304 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
3295 3296 3297 3298 3299 3300 3301 3302 |
# File 'lib/puppet/pops/model/ast.rb', line 3295 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
3291 3292 3293 |
# File 'lib/puppet/pops/model/ast.rb', line 3291 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_hash ⇒ Object
3325 3326 3327 3328 3329 3330 |
# File 'lib/puppet/pops/model/ast.rb', line 3325 def _pcore_init_hash result = super result['radix'] = @radix unless @radix == 10 result['value'] = @value result end |
#eql?(o) ⇒ Boolean Also known as: ==
3332 3333 3334 3335 3336 |
# File 'lib/puppet/pops/model/ast.rb', line 3332 def eql?(o) super && @radix.eql?(o.radix) && @value.eql?(o.value) end |