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.



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

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)



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

def segments
  @segments
end

Class Method Details

._pcore_typeObject



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

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



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

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



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

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



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

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



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

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



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

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

#_pcore_init_hashObject



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

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)


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

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