Class: Puppet::Pops::Types::PTypeWithContainedType Abstract
- Inherits:
-
PAnyType
- Object
- TypedModelObject
- PAnyType
- Puppet::Pops::Types::PTypeWithContainedType
- Defined in:
- lib/puppet/pops/types/types.rb
Overview
This class is abstract.
Encapsulates common behavior for a type that contains one type
Direct Known Subclasses
PIterableType, PIteratorType, PNotUndefType, POptionalType, PType
Constant Summary
Constants inherited from PAnyType
Puppet::Pops::Types::PAnyType::DEFAULT
Instance Attribute Summary collapse
- #type ⇒ Object readonly
Instance Method Summary collapse
- #accept(visitor, guard) ⇒ Object
- #eql?(o) ⇒ Boolean
- #generalize ⇒ Object
- #hash ⇒ Object
-
#initialize(type) ⇒ PTypeWithContainedType
constructor
A new instance of PTypeWithContainedType.
- #normalize(guard = nil) ⇒ Object
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
#type ⇒ Object (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
330 331 332 |
# File 'lib/puppet/pops/types/types.rb', line 330 def eql?(o) self.class == o.class && @type == o.type end |
#generalize ⇒ Object
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 |
#hash ⇒ Object
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 |