Class: Puppet::Pops::Model::CaseExpression
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::CaseExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #options ⇒ Object readonly
- #test ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, test, options = _pcore_type['options'].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 {|@test| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, test, options = _pcore_type['options'].value) ⇒ CaseExpression
constructor
A new instance of CaseExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, test, options = _pcore_type['options'].value) ⇒ CaseExpression
Returns a new instance of CaseExpression.
1341 1342 1343 1344 1345 1346 |
# File 'lib/puppet/pops/model/ast.rb', line 1341 def initialize(locator, offset, length, test, = _pcore_type['options'].value) super(locator, offset, length) @hash = @hash ^ test.hash ^ .hash @test = test @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
1339 1340 1341 |
# File 'lib/puppet/pops/model/ast.rb', line 1339 def @options end |
#test ⇒ Object (readonly)
1338 1339 1340 |
# File 'lib/puppet/pops/model/ast.rb', line 1338 def test @test end |
Class Method Details
._pcore_type ⇒ Object
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 |
# File 'lib/puppet/pops/model/ast.rb', line 1301 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::CaseExpression', { 'parent' => Expression._pcore_type, 'attributes' => { 'test' => Expression._pcore_type, 'options' => { 'type' => Types::PArrayType.new(CaseOption._pcore_type), 'value' => [] } } }) end |
.create(locator, offset, length, test, options = _pcore_type['options'].value) ⇒ Object
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 |
# File 'lib/puppet/pops/model/ast.rb', line 1327 def self.create(locator, offset, length, test, = _pcore_type['options'].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::CaseExpression[test]', attrs['test'].type, test) ta.assert_instance_of('Puppet::AST::CaseExpression[options]', attrs['options'].type, ) new(locator, offset, length, test, ) end |
.from_asserted_hash(init_hash) ⇒ Object
1318 1319 1320 1321 1322 1323 1324 1325 |
# File 'lib/puppet/pops/model/ast.rb', line 1318 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['test'], init_hash.fetch('options') { _pcore_type['options'].value }) end |
.from_hash(init_hash) ⇒ Object
1314 1315 1316 |
# File 'lib/puppet/pops/model/ast.rb', line 1314 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::CaseExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 |
# File 'lib/puppet/pops/model/ast.rb', line 1360 def _pcore_all_contents(path, &block) path << self unless @test.nil? block.call(@test, path) @test._pcore_all_contents(path, &block) end @options.each do |value| block.call(value, path) value._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@test| ... } ⇒ Object
1355 1356 1357 1358 |
# File 'lib/puppet/pops/model/ast.rb', line 1355 def _pcore_contents yield(@test) unless @test.nil? @options.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
1348 1349 1350 1351 1352 1353 |
# File 'lib/puppet/pops/model/ast.rb', line 1348 def _pcore_init_hash result = super result['test'] = @test result['options'] = @options unless _pcore_type['options'].default_value?(@options) result end |
#eql?(o) ⇒ Boolean Also known as: ==
1373 1374 1375 1376 1377 |
# File 'lib/puppet/pops/model/ast.rb', line 1373 def eql?(o) super && @test.eql?(o.test) && @options.eql?(o.) end |