Class: Puppet::Pops::Model::ConcatenatedString

Inherits:
Expression 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

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, segments = _pcore_type['segments'].value) ⇒ ConcatenatedString

Returns a new instance of ConcatenatedString.


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

def initialize(locator, offset, length, segments = _pcore_type['segments'].value)
  super(locator, offset, length)
  @hash = @hash ^ segments.hash
  @segments = segments
end

Instance Attribute Details

#segmentsObject (readonly)


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

def segments
  @segments
end

Class Method Details

._pcore_typeObject


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

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::ConcatenatedString', {
    'parent' => Expression._pcore_type,
    'attributes' => {
      'segments' => {
        'type' => Types::PArrayType.new(Expression._pcore_type),
        'value' => []
      }
    }
  })
end

.create(locator, offset, length, segments = _pcore_type['segments'].value) ⇒ Object


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

def self.create(locator, offset, length, segments = _pcore_type['segments'].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::ConcatenatedString[segments]', attrs['segments'].type, segments)
  new(locator, offset, length, segments)
end

.from_asserted_hash(init_hash) ⇒ Object


3500
3501
3502
3503
3504
3505
3506
# File 'lib/puppet/pops/model/ast.rb', line 3500

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

.from_hash(init_hash) ⇒ Object


3496
3497
3498
# File 'lib/puppet/pops/model/ast.rb', line 3496

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object


3536
3537
3538
3539
3540
3541
3542
3543
# File 'lib/puppet/pops/model/ast.rb', line 3536

def _pcore_all_contents(path, &block)
  path << self
  @segments.each do |value|
    block.call(value, path)
    value._pcore_all_contents(path, &block)
  end
  path.pop
end

#_pcore_contentsObject


3532
3533
3534
# File 'lib/puppet/pops/model/ast.rb', line 3532

def _pcore_contents
  @segments.each { |value| yield(value) }
end

#_pcore_init_hashObject


3526
3527
3528
3529
3530
# File 'lib/puppet/pops/model/ast.rb', line 3526

def _pcore_init_hash
  result = super
  result['segments'] = @segments unless _pcore_type['segments'].default_value?(@segments)
  result
end

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

Returns:

  • (Boolean)

3545
3546
3547
3548
# File 'lib/puppet/pops/model/ast.rb', line 3545

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