Class: Puppet::Pops::Model::ComparisonExpression
- Inherits:
-
BinaryExpression
- Object
- PopsObject
- Positioned
- Expression
- BinaryExpression
- Puppet::Pops::Model::ComparisonExpression
- 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(i12n) ⇒ Object
- .from_hash(i12n) ⇒ 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) ⇒ ComparisonExpression
constructor
A new instance of ComparisonExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, left_expr, right_expr, operator) ⇒ ComparisonExpression
Returns a new instance of ComparisonExpression.
718 719 720 721 722 |
# File 'lib/puppet/pops/model/ast.rb', line 718 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)
716 717 718 |
# File 'lib/puppet/pops/model/ast.rb', line 716 def operator @operator end |
Class Method Details
._pcore_type ⇒ Object
681 682 683 684 685 686 687 688 |
# File 'lib/puppet/pops/model/ast.rb', line 681 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::ComparisonExpression', { 'parent' => BinaryExpression._pcore_type, 'attributes' => { 'operator' => Types::PEnumType.new(['!=', '<', '<=', '==', '>', '>=']) } }) end |
.create(locator, offset, length, left_expr, right_expr, operator) ⇒ Object
704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/puppet/pops/model/ast.rb', line 704 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::ComparisonExpression[operator]', attrs['operator'].type, operator) new(locator, offset, length, left_expr, right_expr, operator) end |
.from_asserted_hash(i12n) ⇒ Object
694 695 696 697 698 699 700 701 702 |
# File 'lib/puppet/pops/model/ast.rb', line 694 def self.from_asserted_hash(i12n) new( i12n['locator'], i12n['offset'], i12n['length'], i12n['left_expr'], i12n['right_expr'], i12n['operator']) end |
.from_hash(i12n) ⇒ Object
690 691 692 |
# File 'lib/puppet/pops/model/ast.rb', line 690 def self.from_hash(i12n) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::ComparisonExpression initializer', _pcore_type.i12n_type, i12n)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
735 736 737 738 739 740 741 742 743 744 745 746 |
# File 'lib/puppet/pops/model/ast.rb', line 735 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
730 731 732 733 |
# File 'lib/puppet/pops/model/ast.rb', line 730 def _pcore_contents yield(@left_expr) unless @left_expr.nil? yield(@right_expr) unless @right_expr.nil? end |
#_pcore_init_hash ⇒ Object
724 725 726 727 728 |
# File 'lib/puppet/pops/model/ast.rb', line 724 def _pcore_init_hash result = super result['operator'] = @operator result end |
#eql?(o) ⇒ Boolean Also known as: ==
748 749 750 751 |
# File 'lib/puppet/pops/model/ast.rb', line 748 def eql?(o) super && @operator.eql?(o.operator) end |