Class: Puppet::Pops::Types::PTypeWithContainedType Abstract

Inherits:
PAnyType show all
Defined in:
lib/puppet/pops/types/types.rb

Overview

This class is abstract.

Encapsulates common behavior for a type that contains one type

Constant Summary

Constants inherited from PAnyType

Puppet::Pops::Types::PAnyType::DEFAULT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PAnyType

#==, #assignable?, #callable?, #callable_args?, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #simple_name, #to_alias_expanded_s, #to_s

Constructor Details

#initialize(type) ⇒ PTypeWithContainedType

Returns a new instance of PTypeWithContainedType.



299
300
301
# File 'lib/puppet/pops/types/types.rb', line 299

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



297
298
299
# File 'lib/puppet/pops/types/types.rb', line 297

def type
  @type
end

Instance Method Details

#accept(visitor, guard) ⇒ Object



303
304
305
306
# File 'lib/puppet/pops/types/types.rb', line 303

def accept(visitor, guard)
  super
  @type.accept(visitor, guard) unless @type.nil?
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


330
331
332
# File 'lib/puppet/pops/types/types.rb', line 330

def eql?(o)
  self.class == o.class && @type == o.type
end

#generalizeObject



308
309
310
311
312
313
314
315
# File 'lib/puppet/pops/types/types.rb', line 308

def generalize
  if @type.nil?
    self.class::DEFAULT
  else
    ge_type = @type.generalize
    @type.equal?(ge_type) ? self : self.class.new(ge_type)
  end
end

#hashObject



326
327
328
# File 'lib/puppet/pops/types/types.rb', line 326

def hash
  self.class.hash ^ @type.hash
end

#normalize(guard = nil) ⇒ Object



317
318
319
320
321
322
323
324
# File 'lib/puppet/pops/types/types.rb', line 317

def normalize(guard = nil)
  if @type.nil?
    self.class::DEFAULT
  else
    ne_type = @type.normalize(guard)
    @type.equal?(ne_type) ? self : self.class.new(ne_type)
  end
end