Class: Puppet::Pops::Model::AccessExpression
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::AccessExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #keys ⇒ Object readonly
- #left_expr ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, left_expr, keys = _pcore_type['keys'].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 {|@left_expr| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, left_expr, keys = _pcore_type['keys'].value) ⇒ AccessExpression
constructor
A new instance of AccessExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, left_expr, keys = _pcore_type['keys'].value) ⇒ AccessExpression
Returns a new instance of AccessExpression.
640 641 642 643 644 645 |
# File 'lib/puppet/pops/model/ast.rb', line 640 def initialize(locator, offset, length, left_expr, keys = _pcore_type['keys'].value) super(locator, offset, length) @hash = @hash ^ left_expr.hash ^ keys.hash @left_expr = left_expr @keys = keys end |
Instance Attribute Details
#keys ⇒ Object (readonly)
638 639 640 |
# File 'lib/puppet/pops/model/ast.rb', line 638 def keys @keys end |
#left_expr ⇒ Object (readonly)
637 638 639 |
# File 'lib/puppet/pops/model/ast.rb', line 637 def left_expr @left_expr end |
Class Method Details
._pcore_type ⇒ Object
600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/puppet/pops/model/ast.rb', line 600 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::AccessExpression', { 'parent' => Expression._pcore_type, 'attributes' => { 'left_expr' => Expression._pcore_type, 'keys' => { 'type' => Types::PArrayType.new(Expression._pcore_type), 'value' => [] } } }) end |
.create(locator, offset, length, left_expr, keys = _pcore_type['keys'].value) ⇒ Object
626 627 628 629 630 631 632 633 634 635 |
# File 'lib/puppet/pops/model/ast.rb', line 626 def self.create(locator, offset, length, left_expr, keys = _pcore_type['keys'].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::AccessExpression[left_expr]', attrs['left_expr'].type, left_expr) ta.assert_instance_of('Puppet::AST::AccessExpression[keys]', attrs['keys'].type, keys) new(locator, offset, length, left_expr, keys) end |
.from_asserted_hash(init_hash) ⇒ Object
617 618 619 620 621 622 623 624 |
# File 'lib/puppet/pops/model/ast.rb', line 617 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['left_expr'], init_hash.fetch('keys') { _pcore_type['keys'].value }) end |
.from_hash(init_hash) ⇒ Object
613 614 615 |
# File 'lib/puppet/pops/model/ast.rb', line 613 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::AccessExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
659 660 661 662 663 664 665 666 667 668 669 670 |
# File 'lib/puppet/pops/model/ast.rb', line 659 def _pcore_all_contents(path, &block) path << self unless @left_expr.nil? block.call(@left_expr, path) @left_expr._pcore_all_contents(path, &block) end @keys.each do |value| block.call(value, path) value._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@left_expr| ... } ⇒ Object
654 655 656 657 |
# File 'lib/puppet/pops/model/ast.rb', line 654 def _pcore_contents yield(@left_expr) unless @left_expr.nil? @keys.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
647 648 649 650 651 652 |
# File 'lib/puppet/pops/model/ast.rb', line 647 def _pcore_init_hash result = super result['left_expr'] = @left_expr result['keys'] = @keys unless _pcore_type['keys'].default_value?(@keys) result end |
#eql?(o) ⇒ Boolean Also known as: ==
672 673 674 675 676 |
# File 'lib/puppet/pops/model/ast.rb', line 672 def eql?(o) super && @left_expr.eql?(o.left_expr) && @keys.eql?(o.keys) end |