Class: Puppet::Pops::Types::PType
Overview
Constant Summary
collapse
- DEFAULT =
PType.new(nil)
Instance Attribute Summary
#type
Class Method Summary
collapse
Instance Method Summary
collapse
#accept, #generalize, #hash, #initialize, #normalize, #resolve
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #check_self_recursion, #create, #generalize, #hash, #kind_of_callable?, #name, new_function, #new_function, #normalize, #really_instance?, #resolve, #simple_name, #to_alias_expanded_s, #to_s
_ptype, create_ptype, register_ptypes
Methods included from Visitable
#accept
#_ptype
Class Method Details
.register_ptype(loader, ir) ⇒ Object
429
430
431
432
433
434
435
436
|
# File 'lib/puppet/pops/types/types.rb', line 429
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
477
478
479
480
|
# File 'lib/puppet/pops/types/types.rb', line 477
def self.simple_name
'Type'
end
|
Instance Method Details
#eql?(o) ⇒ Boolean
473
474
475
|
# File 'lib/puppet/pops/types/types.rb', line 473
def eql?(o)
self.class == o.class && @type == o.type
end
|
#instance?(o, guard = nil) ⇒ Boolean
438
439
440
441
442
443
444
|
# File 'lib/puppet/pops/types/types.rb', line 438
def instance?(o, guard = nil)
if o.is_a?(PAnyType)
type.nil? || type.assignable?(o, guard)
else
assignable?(TypeCalculator.infer(o), guard)
end
end
|
#iterable?(guard = nil) ⇒ Boolean
446
447
448
449
450
451
452
453
454
455
|
# File 'lib/puppet/pops/types/types.rb', line 446
def iterable?(guard = nil)
case @type
when PEnumType
true
when PIntegerType
@type.finite_range?
else
false
end
end
|
#iterable_type(guard = nil) ⇒ Object
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
# File 'lib/puppet/pops/types/types.rb', line 457
def iterable_type(guard = nil)
case @type
when PEnumType
PIterableType.new(@type)
when PIntegerType
@type.finite_range? ? PIterableType.new(@type) : nil
else
nil
end
end
|