Class: Puppet::Pops::Types::PIterableType Private

Inherits:
PTypeWithContainedType show all
Defined in:
lib/puppet/pops/types/types.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

DEFAULT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

PIterableType.new(nil)

Instance Attribute Summary

Attributes inherited from PTypeWithContainedType

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PTypeWithContainedType

#accept, #eql?, #generalize, #hash, #initialize, #normalize, #resolve

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #eql?, #generalize, #hash, #kind_of_callable?, #loader, #name, #new_function, new_function, #normalize, #really_instance?, #resolve, #roundtrip_with_string?, #simple_name, simple_name, #to_alias_expanded_s, #to_s

Methods inherited from TypedModelObject

_pcore_type, create_ptype, register_ptypes

Methods included from Visitable

#accept

Methods included from PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s

Constructor Details

This class inherits a constructor from Puppet::Pops::Types::PTypeWithContainedType

Class Method Details

.register_ptype(loader, ir) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1402
1403
1404
1405
1406
1407
1408
1409
# File 'lib/puppet/pops/types/types.rb', line 1402

def self.register_ptype(loader, ir)
  create_ptype(loader, ir, 'AnyType',
    'type' => {
      KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
      KEY_VALUE => nil
    }
  )
end

Instance Method Details

#element_typeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1411
1412
1413
# File 'lib/puppet/pops/types/types.rb', line 1411

def element_type
  @type
end

#instance?(o, guard = nil) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
# File 'lib/puppet/pops/types/types.rb', line 1415

def instance?(o, guard = nil)
  if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
    # Any element_type will do
    case o
    when Iterable, String, Hash, Array, Range, PEnumType
      true
    when Integer
      o >= 0
    when PIntegerType
      o.finite_range?
    when PTypeAliasType
      instance?(o.resolved_type, guard)
    else
      false
    end
  else
    assignable?(TypeCalculator.infer(o), guard)
  end
end

#iterable?(guard = nil) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


1435
1436
1437
# File 'lib/puppet/pops/types/types.rb', line 1435

def iterable?(guard = nil)
  true
end

#iterable_type(guard = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1439
1440
1441
# File 'lib/puppet/pops/types/types.rb', line 1439

def iterable_type(guard = nil)
  self
end