Class: Puppet::Pops::Model::LiteralList
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::LiteralList
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #values ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, values = _pcore_type['values'].value) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, values = _pcore_type['values'].value) ⇒ LiteralList
constructor
A new instance of LiteralList.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
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
#values ⇒ Object (readonly)
988 989 990 |
# File 'lib/puppet/pops/model/ast.rb', line 988 def values @values end |
Class Method Details
._pcore_type ⇒ Object
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_contents ⇒ Object
1002 1003 1004 |
# File 'lib/puppet/pops/model/ast.rb', line 1002 def _pcore_contents @values.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
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: ==
1015 1016 1017 1018 |
# File 'lib/puppet/pops/model/ast.rb', line 1015 def eql?(o) super && @values.eql?(o.values) end |