Class: Puppet::Pops::Model::LiteralList

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, values = _pcore_type['values'].value) ⇒ LiteralList

Returns a new instance of LiteralList


971
972
973
974
975
# File 'lib/puppet/pops/model/ast.rb', line 971

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

Instance Attribute Details

#valuesObject (readonly)


969
970
971
# File 'lib/puppet/pops/model/ast.rb', line 969

def values
  @values
end

Class Method Details

._pcore_typeObject


935
936
937
938
939
940
941
942
943
944
945
# File 'lib/puppet/pops/model/ast.rb', line 935

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

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


959
960
961
962
963
964
965
966
967
# File 'lib/puppet/pops/model/ast.rb', line 959

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

.from_asserted_hash(init_hash) ⇒ Object


951
952
953
954
955
956
957
# File 'lib/puppet/pops/model/ast.rb', line 951

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

.from_hash(init_hash) ⇒ Object


947
948
949
# File 'lib/puppet/pops/model/ast.rb', line 947

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object


987
988
989
990
991
992
993
994
# File 'lib/puppet/pops/model/ast.rb', line 987

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

#_pcore_contentsObject


983
984
985
# File 'lib/puppet/pops/model/ast.rb', line 983

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

#_pcore_init_hashObject


977
978
979
980
981
# File 'lib/puppet/pops/model/ast.rb', line 977

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

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


996
997
998
999
# File 'lib/puppet/pops/model/ast.rb', line 996

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