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.



3596
3597
3598
3599
3600
# File 'lib/puppet/pops/model/ast.rb', line 3596

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)



3594
3595
3596
# File 'lib/puppet/pops/model/ast.rb', line 3594

def segments
  @segments
end

Class Method Details

._pcore_typeObject



3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
# File 'lib/puppet/pops/model/ast.rb', line 3558

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



3584
3585
3586
3587
3588
3589
3590
3591
3592
# File 'lib/puppet/pops/model/ast.rb', line 3584

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



3576
3577
3578
3579
3580
3581
3582
# File 'lib/puppet/pops/model/ast.rb', line 3576

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



3572
3573
3574
# File 'lib/puppet/pops/model/ast.rb', line 3572

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



3612
3613
3614
3615
3616
3617
3618
3619
# File 'lib/puppet/pops/model/ast.rb', line 3612

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



3608
3609
3610
# File 'lib/puppet/pops/model/ast.rb', line 3608

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

#_pcore_init_hashObject



3602
3603
3604
3605
3606
# File 'lib/puppet/pops/model/ast.rb', line 3602

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)


3621
3622
3623
3624
# File 'lib/puppet/pops/model/ast.rb', line 3621

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