Class: Puppet::Pops::Types::PCollectionType
Constant Summary
collapse
- DEFAULT_SIZE =
PIntegerType.new(0)
- ZERO_SIZE =
PIntegerType.new(0, 0)
- DEFAULT =
PCollectionType.new(nil)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from PAnyType
#assignable?, #callable?, #callable_args?, #enumerable?, #kind_of_callable?, #simple_name, #to_s
Methods included from Visitable
#accept
Constructor Details
#initialize(element_type, size_type = nil) ⇒ PCollectionType
Returns a new instance of PCollectionType.
558
559
560
561
|
# File 'lib/puppet/pops/types/types.rb', line 558
def initialize(element_type, size_type = nil)
@element_type = element_type
@size_type = size_type
end
|
Instance Attribute Details
#element_type ⇒ Object
556
557
558
|
# File 'lib/puppet/pops/types/types.rb', line 556
def element_type
@element_type
end
|
#size_type ⇒ Object
556
557
558
|
# File 'lib/puppet/pops/types/types.rb', line 556
def size_type
@size_type
end
|
Instance Method Details
580
581
582
|
# File 'lib/puppet/pops/types/types.rb', line 580
def ==(o)
self.class == o.class && @element_type == o.element_type && @size_type == o.size_type
end
|
#generalize ⇒ Object
563
564
565
|
# File 'lib/puppet/pops/types/types.rb', line 563
def generalize
@element_type.nil? ? DEFAULT : PCollectionType.new(element_type.generalize, nil)
end
|
576
577
578
|
# File 'lib/puppet/pops/types/types.rb', line 576
def hash
@element_type.hash * 31 + @size_type.hash
end
|
#instance?(o) ⇒ Boolean
567
568
569
|
# File 'lib/puppet/pops/types/types.rb', line 567
def instance?(o)
assignable?(TypeCalculator.infer(o))
end
|
#size_range ⇒ Object
Returns an array with from (min) size to (max) size
572
573
574
|
# File 'lib/puppet/pops/types/types.rb', line 572
def size_range
(@size_type || DEFAULT_SIZE).range
end
|