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.
1378 1379 1380 1381 1382 1383 |
# File 'lib/puppet/pops/model/ast.rb', line 1378 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)
1376 1377 1378 |
# File 'lib/puppet/pops/model/ast.rb', line 1376 def @options end |
#test ⇒ Object (readonly)
1375 1376 1377 |
# File 'lib/puppet/pops/model/ast.rb', line 1375 def test @test end |
Class Method Details
._pcore_type ⇒ Object
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 |
# File 'lib/puppet/pops/model/ast.rb', line 1336 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
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
# File 'lib/puppet/pops/model/ast.rb', line 1364 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
1355 1356 1357 1358 1359 1360 1361 1362 |
# File 'lib/puppet/pops/model/ast.rb', line 1355 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
1351 1352 1353 |
# File 'lib/puppet/pops/model/ast.rb', line 1351 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
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 |
# File 'lib/puppet/pops/model/ast.rb', line 1397 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
1392 1393 1394 1395 |
# File 'lib/puppet/pops/model/ast.rb', line 1392 def _pcore_contents yield(@test) unless @test.nil? @options.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
1385 1386 1387 1388 1389 1390 |
# File 'lib/puppet/pops/model/ast.rb', line 1385 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: ==
1410 1411 1412 1413 1414 |
# File 'lib/puppet/pops/model/ast.rb', line 1410 def eql?(o) super && @test.eql?(o.test) && @options.eql?(o.) end |