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

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

Overview

API:

  • public

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.

API:

  • public



3711
3712
3713
3714
3715
# File 'lib/puppet/pops/model/ast.rb', line 3711

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)

API:

  • public



3709
3710
3711
# File 'lib/puppet/pops/model/ast.rb', line 3709

def segments
  @segments
end

Class Method Details

._pcore_typeObject

API:

  • public



3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
# File 'lib/puppet/pops/model/ast.rb', line 3675

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

API:

  • public



3699
3700
3701
3702
3703
3704
3705
3706
3707
# File 'lib/puppet/pops/model/ast.rb', line 3699

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

API:

  • public



3691
3692
3693
3694
3695
3696
3697
# File 'lib/puppet/pops/model/ast.rb', line 3691

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

API:

  • public



3687
3688
3689
# File 'lib/puppet/pops/model/ast.rb', line 3687

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

API:

  • public



3727
3728
3729
3730
3731
3732
3733
3734
# File 'lib/puppet/pops/model/ast.rb', line 3727

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

API:

  • public



3723
3724
3725
# File 'lib/puppet/pops/model/ast.rb', line 3723

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

#_pcore_init_hashObject

API:

  • public



3717
3718
3719
3720
3721
# File 'lib/puppet/pops/model/ast.rb', line 3717

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:

API:

  • public



3736
3737
3738
3739
# File 'lib/puppet/pops/model/ast.rb', line 3736

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