class Puppet::Pops::Model::IfExpression

Attributes

else_expr[R]
test[R]
then_expr[R]

Public Class Methods

_pcore_type() click to toggle source
     # File lib/puppet/pops/model/ast.rb
2815 def self._pcore_type
2816   @_pcore_type ||= Types::PObjectType.new('Puppet::AST::IfExpression', {
2817     'parent' => Expression._pcore_type,
2818     'attributes' => {
2819       'test' => Expression._pcore_type,
2820       'then_expr' => {
2821         'type' => Types::POptionalType.new(Expression._pcore_type),
2822         'value' => nil
2823       },
2824       'else_expr' => {
2825         'type' => Types::POptionalType.new(Expression._pcore_type),
2826         'value' => nil
2827       }
2828     }
2829   })
2830 end
create(locator, offset, length, test, then_expr = nil, else_expr = nil) click to toggle source
     # File lib/puppet/pops/model/ast.rb
2846 def self.create(locator, offset, length, test, then_expr = nil, else_expr = nil)
2847   ta = Types::TypeAsserter
2848   attrs = _pcore_type.attributes(true)
2849   ta.assert_instance_of('Puppet::AST::Positioned[locator]', attrs['locator'].type, locator)
2850   ta.assert_instance_of('Puppet::AST::Positioned[offset]', attrs['offset'].type, offset)
2851   ta.assert_instance_of('Puppet::AST::Positioned[length]', attrs['length'].type, length)
2852   ta.assert_instance_of('Puppet::AST::IfExpression[test]', attrs['test'].type, test)
2853   ta.assert_instance_of('Puppet::AST::IfExpression[then_expr]', attrs['then_expr'].type, then_expr)
2854   ta.assert_instance_of('Puppet::AST::IfExpression[else_expr]', attrs['else_expr'].type, else_expr)
2855   new(locator, offset, length, test, then_expr, else_expr)
2856 end
from_asserted_hash(init_hash) click to toggle source
     # File lib/puppet/pops/model/ast.rb
2836 def self.from_asserted_hash(init_hash)
2837   new(
2838     init_hash['locator'],
2839     init_hash['offset'],
2840     init_hash['length'],
2841     init_hash['test'],
2842     init_hash['then_expr'],
2843     init_hash['else_expr'])
2844 end
from_hash(init_hash) click to toggle source
     # File lib/puppet/pops/model/ast.rb
2832 def self.from_hash(init_hash)
2833   from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::IfExpression initializer', _pcore_type.init_hash_type, init_hash))
2834 end
new(locator, offset, length, test, then_expr = nil, else_expr = nil) click to toggle source
Calls superclass method Puppet::Pops::Model::Positioned::new
     # File lib/puppet/pops/model/ast.rb
2862 def initialize(locator, offset, length, test, then_expr = nil, else_expr = nil)
2863   super(locator, offset, length)
2864   @hash = @hash ^ test.hash ^ then_expr.hash ^ else_expr.hash
2865   @test = test
2866   @then_expr = then_expr
2867   @else_expr = else_expr
2868 end

Public Instance Methods

==(o)
Alias for: eql?
_pcore_all_contents(path, &block) click to toggle source
     # File lib/puppet/pops/model/ast.rb
2884 def _pcore_all_contents(path, &block)
2885   path << self
2886   unless @test.nil?
2887     block.call(@test, path)
2888     @test._pcore_all_contents(path, &block)
2889   end
2890   unless @then_expr.nil?
2891     block.call(@then_expr, path)
2892     @then_expr._pcore_all_contents(path, &block)
2893   end
2894   unless @else_expr.nil?
2895     block.call(@else_expr, path)
2896     @else_expr._pcore_all_contents(path, &block)
2897   end
2898   path.pop
2899 end
_pcore_contents() { |test| ... } click to toggle source
     # File lib/puppet/pops/model/ast.rb
2878 def _pcore_contents
2879   yield(@test) unless @test.nil?
2880   yield(@then_expr) unless @then_expr.nil?
2881   yield(@else_expr) unless @else_expr.nil?
2882 end
_pcore_init_hash() click to toggle source
Calls superclass method Puppet::Pops::Model::Positioned#_pcore_init_hash
     # File lib/puppet/pops/model/ast.rb
2870 def _pcore_init_hash
2871   result = super
2872   result['test'] = @test
2873   result['then_expr'] = @then_expr unless @then_expr == nil
2874   result['else_expr'] = @else_expr unless @else_expr == nil
2875   result
2876 end
eql?(o) click to toggle source
Calls superclass method Puppet::Pops::Model::PopsObject#eql?
     # File lib/puppet/pops/model/ast.rb
2901 def eql?(o)
2902   super &&
2903   @test.eql?(o.test) &&
2904   @then_expr.eql?(o.then_expr) &&
2905   @else_expr.eql?(o.else_expr)
2906 end
Also aliased as: ==