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?, #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
Constructor Details
Returns a new instance of PCollectionType.
1197
1198
1199
|
# File 'lib/puppet/pops/types/types.rb', line 1197
def initialize(size_type)
@size_type = size_type
end
|
Instance Attribute Details
#size_type ⇒ Object
1195
1196
1197
|
# File 'lib/puppet/pops/types/types.rb', line 1195
def size_type
@size_type
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
Instance Method Details
#accept(visitor, guard) ⇒ Object
1201
1202
1203
1204
|
# File 'lib/puppet/pops/types/types.rb', line 1201
def accept(visitor, guard)
super
@size_type.accept(visitor, guard) unless @size_type.nil?
end
|
#eql?(o) ⇒ Boolean
1241
1242
1243
|
# File 'lib/puppet/pops/types/types.rb', line 1241
def eql?(o)
self.class == o.class && @size_type == o.size_type
end
|
#generalize ⇒ Object
1206
1207
1208
|
# File 'lib/puppet/pops/types/types.rb', line 1206
def generalize
DEFAULT
end
|
#has_empty_range? ⇒ Boolean
1228
1229
1230
1231
|
# File 'lib/puppet/pops/types/types.rb', line 1228
def has_empty_range?
from, to = size_range
from == 0 && to == 0
end
|
1233
1234
1235
|
# File 'lib/puppet/pops/types/types.rb', line 1233
def hash
@size_type.hash
end
|
#instance?(o, guard = nil) ⇒ Boolean
1214
1215
1216
1217
1218
1219
1220
1221
|
# File 'lib/puppet/pops/types/types.rb', line 1214
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
1237
1238
1239
|
# File 'lib/puppet/pops/types/types.rb', line 1237
def iterable?(guard = nil)
true
end
|
#normalize(guard = nil) ⇒ Object
1210
1211
1212
|
# File 'lib/puppet/pops/types/types.rb', line 1210
def normalize(guard = nil)
DEFAULT
end
|
#size_range ⇒ Object
Returns an array with from (min) size to (max) size
1224
1225
1226
|
# File 'lib/puppet/pops/types/types.rb', line 1224
def size_range
(@size_type || DEFAULT_SIZE).range
end
|