Class: Puppet::Pops::Model::UnaryExpression

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, expr) ⇒ UnaryExpression

Returns a new instance of UnaryExpression.



266
267
268
269
270
# File 'lib/puppet/pops/model/ast.rb', line 266

def initialize(locator, offset, length, expr)
  super(locator, offset, length)
  @hash = @hash ^ expr.hash
  @expr = expr
end

Instance Attribute Details

#exprObject (readonly)



264
265
266
# File 'lib/puppet/pops/model/ast.rb', line 264

def expr
  @expr
end

Class Method Details

._pcore_typeObject



232
233
234
235
236
237
238
239
240
# File 'lib/puppet/pops/model/ast.rb', line 232

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType.new('Puppet::AST::UnaryExpression', {
                             'parent' => Expression._pcore_type,
                             'attributes' => {
                               'expr' => Expression._pcore_type
                             }
                           })
end

.create(locator, offset, length, expr) ⇒ Object



254
255
256
257
258
259
260
261
262
# File 'lib/puppet/pops/model/ast.rb', line 254

def self.create(locator, offset, length, expr)
  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::UnaryExpression[expr]', attrs['expr'].type, expr)
  new(locator, offset, length, expr)
end

.from_asserted_hash(init_hash) ⇒ Object



246
247
248
249
250
251
252
# File 'lib/puppet/pops/model/ast.rb', line 246

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

.from_hash(init_hash) ⇒ Object



242
243
244
# File 'lib/puppet/pops/model/ast.rb', line 242

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



282
283
284
285
286
287
288
289
# File 'lib/puppet/pops/model/ast.rb', line 282

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

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

Yields:



278
279
280
# File 'lib/puppet/pops/model/ast.rb', line 278

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

#_pcore_init_hashObject



272
273
274
275
276
# File 'lib/puppet/pops/model/ast.rb', line 272

def _pcore_init_hash
  result = super
  result['expr'] = @expr
  result
end

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

Returns:

  • (Boolean)


291
292
293
294
# File 'lib/puppet/pops/model/ast.rb', line 291

def eql?(o)
  super &&
  @expr.eql?(o.expr)
end