Class: Puppet::Pops::Model::LiteralRegularExpression

Inherits:
LiteralValue 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, pattern) ⇒ LiteralRegularExpression

Returns a new instance of LiteralRegularExpression


3384
3385
3386
3387
3388
3389
# File 'lib/puppet/pops/model/ast.rb', line 3384

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

Instance Attribute Details

#patternObject (readonly)


3382
3383
3384
# File 'lib/puppet/pops/model/ast.rb', line 3382

def pattern
  @pattern
end

#valueObject (readonly)


3381
3382
3383
# File 'lib/puppet/pops/model/ast.rb', line 3381

def value
  @value
end

Class Method Details

._pcore_typeObject


3347
3348
3349
3350
3351
3352
3353
3354
3355
# File 'lib/puppet/pops/model/ast.rb', line 3347

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::LiteralRegularExpression', {
    'parent' => LiteralValue._pcore_type,
    'attributes' => {
      'value' => Types::PAnyType::DEFAULT,
      'pattern' => Types::PStringType::DEFAULT
    }
  })
end

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


3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
# File 'lib/puppet/pops/model/ast.rb', line 3370

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

.from_asserted_hash(init_hash) ⇒ Object


3361
3362
3363
3364
3365
3366
3367
3368
# File 'lib/puppet/pops/model/ast.rb', line 3361

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

.from_hash(init_hash) ⇒ Object


3357
3358
3359
# File 'lib/puppet/pops/model/ast.rb', line 3357

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

Instance Method Details

#_pcore_init_hashObject


3391
3392
3393
3394
3395
3396
# File 'lib/puppet/pops/model/ast.rb', line 3391

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

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


3398
3399
3400
3401
3402
# File 'lib/puppet/pops/model/ast.rb', line 3398

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