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.



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

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)



988
989
990
# File 'lib/puppet/pops/model/ast.rb', line 988

def values
  @values
end

Class Method Details

._pcore_typeObject



952
953
954
955
956
957
958
959
960
961
962
963
964
# File 'lib/puppet/pops/model/ast.rb', line 952

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



978
979
980
981
982
983
984
985
986
# File 'lib/puppet/pops/model/ast.rb', line 978

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



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

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



966
967
968
# File 'lib/puppet/pops/model/ast.rb', line 966

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



1006
1007
1008
1009
1010
1011
1012
1013
# File 'lib/puppet/pops/model/ast.rb', line 1006

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



1002
1003
1004
# File 'lib/puppet/pops/model/ast.rb', line 1002

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

#_pcore_init_hashObject



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

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

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

Returns:

  • (Boolean)


1015
1016
1017
1018
# File 'lib/puppet/pops/model/ast.rb', line 1015

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