Class: Puppet::Pops::Types::PType
- Inherits:
-
PTypeWithContainedType
- Object
- TypedModelObject
- PAnyType
- PTypeWithContainedType
- Puppet::Pops::Types::PType
- Defined in:
- lib/puppet/pops/types/types.rb
Overview
The type of types.
Constant Summary collapse
- DEFAULT =
PType.new(nil)
Instance Attribute Summary
Attributes inherited from PTypeWithContainedType
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(o) ⇒ Boolean
- #instance?(o, guard = nil) ⇒ Boolean
- #iterable?(guard = nil) ⇒ Boolean
- #iterable_type(guard = nil) ⇒ Object
Methods inherited from PTypeWithContainedType
#accept, #generalize, #hash, #initialize, #normalize, #resolve
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, #create, create, #generalize, #hash, #kind_of_callable?, #name, new_function, #new_function, #normalize, #really_instance?, #resolve, #roundtrip_with_string?, #simple_name, #to_alias_expanded_s, #to_s
Methods inherited from TypedModelObject
_pcore_type, create_ptype, register_ptypes
Methods included from Visitable
Methods included from PuppetObject
#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type
Constructor Details
This class inherits a constructor from Puppet::Pops::Types::PTypeWithContainedType
Class Method Details
.register_ptype(loader, ir) ⇒ Object
449 450 451 452 453 454 455 456 |
# File 'lib/puppet/pops/types/types.rb', line 449 def self.register_ptype(loader, ir) create_ptype(loader, ir, 'AnyType', 'type' => { KEY_TYPE => POptionalType.new(PType::DEFAULT), KEY_VALUE => nil } ) end |
.simple_name ⇒ Object
499 500 501 502 |
# File 'lib/puppet/pops/types/types.rb', line 499 def self.simple_name # since this the class is inconsistently named PType and not PTypeType 'Type' end |
Instance Method Details
#eql?(o) ⇒ Boolean
495 496 497 |
# File 'lib/puppet/pops/types/types.rb', line 495 def eql?(o) self.class == o.class && @type == o.type end |
#instance?(o, guard = nil) ⇒ Boolean
458 459 460 461 462 463 464 465 466 |
# File 'lib/puppet/pops/types/types.rb', line 458 def instance?(o, guard = nil) if o.is_a?(PAnyType) type.nil? || type.assignable?(o, guard) elsif o.is_a?(Module) || o.is_a?(Puppet::Resource) || o.is_a?(Puppet::Parser::Resource) @type.nil? ? true : assignable?(TypeCalculator.infer(o)) else false end end |
#iterable?(guard = nil) ⇒ Boolean
468 469 470 471 472 473 474 475 476 477 |
# File 'lib/puppet/pops/types/types.rb', line 468 def iterable?(guard = nil) case @type when PEnumType true when PIntegerType @type.finite_range? else false end end |
#iterable_type(guard = nil) ⇒ Object
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/puppet/pops/types/types.rb', line 479 def iterable_type(guard = nil) # The types PIntegerType and PEnumType are Iterable case @type when PEnumType # @type describes the element type perfectly since the iteration is made over the # contained choices. PIterableType.new(@type) when PIntegerType # @type describes the element type perfectly since the iteration is made over the # specified range. @type.finite_range? ? PIterableType.new(@type) : nil else nil end end |