Class: Puppet::Pops::Types::PCollectionType
Constant Summary
collapse
- DEFAULT_SIZE =
PIntegerType.new(0)
- ZERO_SIZE =
PIntegerType.new(0, 0)
- NOT_EMPTY_SIZE =
PIntegerType.new(1)
- DEFAULT =
PCollectionType.new(nil)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PAnyType
#==, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #iterable_type, #kind_of_callable?, #loader, #name, new_function, #new_function, #really_instance?, #resolve, #roundtrip_with_string?, #simple_name, simple_name, #to_alias_expanded_s, #to_s
_pcore_type, create_ptype, register_ptypes
#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s
Constructor Details
Returns a new instance of PCollectionType.
1328
1329
1330
|
# File 'lib/puppet/pops/types/types.rb', line 1328
def initialize(size_type)
@size_type = size_type.nil? ? nil : size_type.to_size
end
|
Instance Attribute Details
#size_type ⇒ Object
1326
1327
1328
|
# File 'lib/puppet/pops/types/types.rb', line 1326
def size_type
@size_type
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
Instance Method Details
#accept(visitor, guard) ⇒ Object
1332
1333
1334
1335
|
# File 'lib/puppet/pops/types/types.rb', line 1332
def accept(visitor, guard)
super
@size_type.accept(visitor, guard) unless @size_type.nil?
end
|
#eql?(o) ⇒ Boolean
1372
1373
1374
|
# File 'lib/puppet/pops/types/types.rb', line 1372
def eql?(o)
self.class == o.class && @size_type == o.size_type
end
|
#generalize ⇒ Object
1337
1338
1339
|
# File 'lib/puppet/pops/types/types.rb', line 1337
def generalize
DEFAULT
end
|
#has_empty_range? ⇒ Boolean
1359
1360
1361
1362
|
# File 'lib/puppet/pops/types/types.rb', line 1359
def has_empty_range?
from, to = size_range
from == 0 && to == 0
end
|
1364
1365
1366
|
# File 'lib/puppet/pops/types/types.rb', line 1364
def hash
@size_type.hash
end
|
#instance?(o, guard = nil) ⇒ Boolean
1345
1346
1347
1348
1349
1350
1351
1352
|
# File 'lib/puppet/pops/types/types.rb', line 1345
def instance?(o, guard = nil)
if o.instance_of?(Array) || o.instance_of?(Hash)
@size_type.nil? || @size_type.instance?(o.size)
else
false
end
end
|
#iterable?(guard = nil) ⇒ Boolean
1368
1369
1370
|
# File 'lib/puppet/pops/types/types.rb', line 1368
def iterable?(guard = nil)
true
end
|
#normalize(guard = nil) ⇒ Object
1341
1342
1343
|
# File 'lib/puppet/pops/types/types.rb', line 1341
def normalize(guard = nil)
DEFAULT
end
|
#size_range ⇒ Object
Returns an array with from (min) size to (max) size
1355
1356
1357
|
# File 'lib/puppet/pops/types/types.rb', line 1355
def size_range
(@size_type || DEFAULT_SIZE).range
end
|