Class: Puppet::Pops::Model::RelationshipExpression
- Inherits:
-
BinaryExpression
- Object
- PopsObject
- Positioned
- Expression
- BinaryExpression
- Puppet::Pops::Model::RelationshipExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #operator ⇒ Object readonly
Attributes inherited from BinaryExpression
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, left_expr, right_expr, operator) ⇒ 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, right_expr, operator) ⇒ RelationshipExpression
constructor
A new instance of RelationshipExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, left_expr, right_expr, operator) ⇒ RelationshipExpression
Returns a new instance of RelationshipExpression.
573 574 575 576 577 |
# File 'lib/puppet/pops/model/ast.rb', line 573 def initialize(locator, offset, length, left_expr, right_expr, operator) super(locator, offset, length, left_expr, right_expr) @hash = @hash ^ operator.hash @operator = operator end |
Instance Attribute Details
#operator ⇒ Object (readonly)
571 572 573 |
# File 'lib/puppet/pops/model/ast.rb', line 571 def operator @operator end |
Class Method Details
._pcore_type ⇒ Object
536 537 538 539 540 541 542 543 |
# File 'lib/puppet/pops/model/ast.rb', line 536 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::RelationshipExpression', { 'parent' => BinaryExpression._pcore_type, 'attributes' => { 'operator' => Types::PEnumType.new(['->', '<-', '<~', '~>']) } }) end |
.create(locator, offset, length, left_expr, right_expr, operator) ⇒ Object
559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/puppet/pops/model/ast.rb', line 559 def self.create(locator, offset, length, left_expr, right_expr, operator) 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::BinaryExpression[left_expr]', attrs['left_expr'].type, left_expr) ta.assert_instance_of('Puppet::AST::BinaryExpression[right_expr]', attrs['right_expr'].type, right_expr) ta.assert_instance_of('Puppet::AST::RelationshipExpression[operator]', attrs['operator'].type, operator) new(locator, offset, length, left_expr, right_expr, operator) end |
.from_asserted_hash(init_hash) ⇒ Object
549 550 551 552 553 554 555 556 557 |
# File 'lib/puppet/pops/model/ast.rb', line 549 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['left_expr'], init_hash['right_expr'], init_hash['operator']) end |
.from_hash(init_hash) ⇒ Object
545 546 547 |
# File 'lib/puppet/pops/model/ast.rb', line 545 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::RelationshipExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/puppet/pops/model/ast.rb', line 590 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 unless @right_expr.nil? block.call(@right_expr, path) @right_expr._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@left_expr| ... } ⇒ Object
585 586 587 588 |
# File 'lib/puppet/pops/model/ast.rb', line 585 def _pcore_contents yield(@left_expr) unless @left_expr.nil? yield(@right_expr) unless @right_expr.nil? end |
#_pcore_init_hash ⇒ Object
579 580 581 582 583 |
# File 'lib/puppet/pops/model/ast.rb', line 579 def _pcore_init_hash result = super result['operator'] = @operator result end |
#eql?(o) ⇒ Boolean Also known as: ==
603 604 605 606 |
# File 'lib/puppet/pops/model/ast.rb', line 603 def eql?(o) super && @operator.eql?(o.operator) end |