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.



3878
3879
3880
3881
3882
3883
# File 'lib/puppet/pops/model/ast.rb', line 3878

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)



3876
3877
3878
# File 'lib/puppet/pops/model/ast.rb', line 3876

def body
  @body
end

#parameters_specifiedObject (readonly)



3875
3876
3877
# File 'lib/puppet/pops/model/ast.rb', line 3875

def parameters_specified
  @parameters_specified
end

Class Method Details

._pcore_typeObject



3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
# File 'lib/puppet/pops/model/ast.rb', line 3833

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



3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
# File 'lib/puppet/pops/model/ast.rb', line 3864

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



3855
3856
3857
3858
3859
3860
3861
3862
# File 'lib/puppet/pops/model/ast.rb', line 3855

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



3851
3852
3853
# File 'lib/puppet/pops/model/ast.rb', line 3851

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



3896
3897
3898
3899
3900
3901
3902
3903
# File 'lib/puppet/pops/model/ast.rb', line 3896

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:



3892
3893
3894
# File 'lib/puppet/pops/model/ast.rb', line 3892

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

#_pcore_init_hashObject



3885
3886
3887
3888
3889
3890
# File 'lib/puppet/pops/model/ast.rb', line 3885

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)


3905
3906
3907
3908
3909
# File 'lib/puppet/pops/model/ast.rb', line 3905

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