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, #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
425
426
427
428
429
430
431
432
|
# File 'lib/puppet/pops/types/types.rb', line 425
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
473
474
475
476
|
# File 'lib/puppet/pops/types/types.rb', line 473
def self.simple_name
'Type'
end
|
Instance Method Details
#eql?(o) ⇒ Boolean
469
470
471
|
# File 'lib/puppet/pops/types/types.rb', line 469
def eql?(o)
self.class == o.class && @type == o.type
end
|
#instance?(o, guard = nil) ⇒ Boolean
434
435
436
437
438
439
440
|
# File 'lib/puppet/pops/types/types.rb', line 434
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
442
443
444
445
446
447
448
449
450
451
|
# File 'lib/puppet/pops/types/types.rb', line 442
def iterable?(guard = nil)
case @type
when PEnumType
true
when PIntegerType
@type.finite_range?
else
false
end
end
|
#iterable_type(guard = nil) ⇒ Object
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
# File 'lib/puppet/pops/types/types.rb', line 453
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
|