Class: Puppet::Pops::Model::EppExpression

Inherits:
Expression show all
Defined in:
lib/puppet/pops/model/ast.rb

Instance Attribute Summary collapse

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, parameters_specified = nil, body = nil) ⇒ EppExpression

Returns a new instance of EppExpression.


3794
3795
3796
3797
3798
3799
# File 'lib/puppet/pops/model/ast.rb', line 3794

def initialize(locator, offset, length, parameters_specified = nil, body = nil)
  super(locator, offset, length)
  @hash = @hash ^ parameters_specified.hash ^ body.hash
  @parameters_specified = parameters_specified
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)


3792
3793
3794
# File 'lib/puppet/pops/model/ast.rb', line 3792

def body
  @body
end

#parameters_specifiedObject (readonly)


3791
3792
3793
# File 'lib/puppet/pops/model/ast.rb', line 3791

def parameters_specified
  @parameters_specified
end

Class Method Details

._pcore_typeObject


3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
# File 'lib/puppet/pops/model/ast.rb', line 3751

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::EppExpression', {
    'parent' => Expression._pcore_type,
    'attributes' => {
      'parameters_specified' => {
        'type' => Types::POptionalType.new(Types::PBooleanType::DEFAULT),
        'value' => nil
      },
      'body' => {
        'type' => Types::POptionalType.new(Expression._pcore_type),
        'value' => nil
      }
    }
  })
end

.create(locator, offset, length, parameters_specified = nil, body = nil) ⇒ Object


3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
# File 'lib/puppet/pops/model/ast.rb', line 3780

def self.create(locator, offset, length, parameters_specified = nil, body = nil)
  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::EppExpression[parameters_specified]', attrs['parameters_specified'].type, parameters_specified)
  ta.assert_instance_of('Puppet::AST::EppExpression[body]', attrs['body'].type, body)
  new(locator, offset, length, parameters_specified, body)
end

.from_asserted_hash(init_hash) ⇒ Object


3771
3772
3773
3774
3775
3776
3777
3778
# File 'lib/puppet/pops/model/ast.rb', line 3771

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['parameters_specified'],
    init_hash['body'])
end

.from_hash(init_hash) ⇒ Object


3767
3768
3769
# File 'lib/puppet/pops/model/ast.rb', line 3767

def self.from_hash(init_hash)
  from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::EppExpression initializer', _pcore_type.init_hash_type, init_hash))
end

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object


3812
3813
3814
3815
3816
3817
3818
3819
# File 'lib/puppet/pops/model/ast.rb', line 3812

def _pcore_all_contents(path, &block)
  path << self
  unless @body.nil?
    block.call(@body, path)
    @body._pcore_all_contents(path, &block)
  end
  path.pop
end

#_pcore_contents {|@body| ... } ⇒ Object

Yields:


3808
3809
3810
# File 'lib/puppet/pops/model/ast.rb', line 3808

def _pcore_contents
  yield(@body) unless @body.nil?
end

#_pcore_init_hashObject


3801
3802
3803
3804
3805
3806
# File 'lib/puppet/pops/model/ast.rb', line 3801

def _pcore_init_hash
  result = super
  result['parameters_specified'] = @parameters_specified unless @parameters_specified == nil
  result['body'] = @body unless @body == nil
  result
end

#eql?(o) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)

3821
3822
3823
3824
3825
# File 'lib/puppet/pops/model/ast.rb', line 3821

def eql?(o)
  super &&
  @parameters_specified.eql?(o.parameters_specified) &&
  @body.eql?(o.body)
end