Class: Puppet::Pops::Model::Program
- Inherits:
-
PopsObject
- Object
- PopsObject
- Puppet::Pops::Model::Program
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #body ⇒ Object readonly
- #definitions ⇒ Object readonly
- #locator ⇒ Object readonly
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, body = nil, definitions = _pcore_type['definitions'].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 {|@body| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #current ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, body = nil, definitions = _pcore_type['definitions'].value) ⇒ Program
constructor
A new instance of Program.
- #line_offsets ⇒ Object
- #source_ref ⇒ Object
- #source_text ⇒ Object
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, body = nil, definitions = _pcore_type['definitions'].value) ⇒ Program
Returns a new instance of Program.
4624 4625 4626 4627 4628 4629 4630 |
# File 'lib/puppet/pops/model/ast.rb', line 4624 def initialize(locator, body = nil, definitions = _pcore_type['definitions'].value) super() @hash = @hash ^ body.hash ^ definitions.hash ^ locator.hash @body = body @definitions = definitions @locator = locator end |
Instance Attribute Details
#body ⇒ Object (readonly)
4604 4605 4606 |
# File 'lib/puppet/pops/model/ast.rb', line 4604 def body @body end |
#definitions ⇒ Object (readonly)
4605 4606 4607 |
# File 'lib/puppet/pops/model/ast.rb', line 4605 def definitions @definitions end |
#locator ⇒ Object (readonly)
4606 4607 4608 |
# File 'lib/puppet/pops/model/ast.rb', line 4606 def locator @locator end |
Class Method Details
._pcore_type ⇒ Object
4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 |
# File 'lib/puppet/pops/model/ast.rb', line 4552 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::Program', { 'parent' => PopsObject._pcore_type, 'attributes' => { 'body' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil }, 'definitions' => { 'type' => Types::PArrayType.new(Definition._pcore_type), 'kind' => 'reference', 'value' => [] }, 'source_text' => { 'type' => Types::PStringType::DEFAULT, 'kind' => 'derived' }, 'source_ref' => { 'type' => Types::PStringType::DEFAULT, 'kind' => 'derived' }, 'line_offsets' => { 'type' => Types::PArrayType.new(Types::PIntegerType::DEFAULT), 'kind' => 'derived' }, 'locator' => Parser::Locator::Locator19._pcore_type } }) end |
.create(locator, body = nil, definitions = _pcore_type['definitions'].value) ⇒ Object
4595 4596 4597 4598 4599 4600 4601 4602 |
# File 'lib/puppet/pops/model/ast.rb', line 4595 def self.create(locator, body = nil, definitions = _pcore_type['definitions'].value) ta = Types::TypeAsserter attrs = _pcore_type.attributes(true) ta.assert_instance_of('Puppet::AST::Program[body]', attrs['body'].type, body) ta.assert_instance_of('Puppet::AST::Program[definitions]', attrs['definitions'].type, definitions) ta.assert_instance_of('Puppet::AST::Program[locator]', attrs['locator'].type, locator) new(locator, body, definitions) end |
.from_asserted_hash(init_hash) ⇒ Object
4588 4589 4590 4591 4592 4593 |
# File 'lib/puppet/pops/model/ast.rb', line 4588 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['body'], init_hash.fetch('definitions') { _pcore_type['definitions'].value }) end |
.from_hash(init_hash) ⇒ Object
4584 4585 4586 |
# File 'lib/puppet/pops/model/ast.rb', line 4584 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::Program initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 |
# File 'lib/puppet/pops/model/ast.rb', line 4645 def _pcore_all_contents(path, &block) path << self unless @body.nil? block.call(@body, path) @body._pcore_all_contents(path, &block) end unless @locator.nil? block.call(@locator, path) @locator._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@body| ... } ⇒ Object
4640 4641 4642 4643 |
# File 'lib/puppet/pops/model/ast.rb', line 4640 def _pcore_contents yield(@body) unless @body.nil? yield(@locator) unless @locator.nil? end |
#_pcore_init_hash ⇒ Object
4632 4633 4634 4635 4636 4637 4638 |
# File 'lib/puppet/pops/model/ast.rb', line 4632 def _pcore_init_hash result = super result['body'] = @body unless @body == nil result['definitions'] = @definitions unless _pcore_type['definitions'].default_value?(@definitions) result['locator'] = @locator result end |
#current ⇒ Object
4608 4609 4610 |
# File 'lib/puppet/pops/model/ast.rb', line 4608 def current self end |
#eql?(o) ⇒ Boolean Also known as: ==
4658 4659 4660 4661 4662 4663 |
# File 'lib/puppet/pops/model/ast.rb', line 4658 def eql?(o) super && @body.eql?(o.body) && @definitions.eql?(o.definitions) && @locator.eql?(o.locator) end |
#line_offsets ⇒ Object
4620 4621 4622 |
# File 'lib/puppet/pops/model/ast.rb', line 4620 def line_offsets @locator.line_index end |
#source_ref ⇒ Object
4616 4617 4618 |
# File 'lib/puppet/pops/model/ast.rb', line 4616 def source_ref @locator.file end |
#source_text ⇒ Object
4612 4613 4614 |
# File 'lib/puppet/pops/model/ast.rb', line 4612 def source_text @locator.string end |