Class: Puppet::Pops::Types::PArrayType

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

Constant Summary collapse

DATA =
PArrayType.new(PDataType::DEFAULT, DEFAULT_SIZE)
DEFAULT =
PArrayType.new(nil)
EMPTY =
PArrayType.new(PUnitType::DEFAULT, ZERO_SIZE)

Constants inherited from PCollectionType

Puppet::Pops::Types::PCollectionType::DEFAULT_SIZE, Puppet::Pops::Types::PCollectionType::ZERO_SIZE

Instance Attribute Summary

Attributes inherited from PCollectionType

#element_type, #size_type

Instance Method Summary collapse

Methods inherited from PCollectionType

#accept, #eql?, #hash, #initialize, #iterable?, #iterable_type, #size_range

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #eql?, #hash, #iterable?, #iterable_type, #kind_of_callable?, #simple_name, #to_alias_expanded_s, #to_s

Methods included from Visitable

#accept

Constructor Details

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

Instance Method Details

#callable_args?(callable, 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)


1606
1607
1608
1609
1610
1611
# File 'lib/puppet/pops/types/types.rb', line 1606

def callable_args?(callable, guard = nil)
  param_t = callable.param_types
  block_t = callable.block_type
  # does not support calling with a block, but have to check that callable is ok with missing block
  (param_t.nil? || param_t.assignable?(self, guard)) && (block_t.nil? || block_t.assignable(PUndefType::DEFAULT, guard))
end

#generalizeObject



1613
1614
1615
1616
1617
1618
1619
# File 'lib/puppet/pops/types/types.rb', line 1613

def generalize
  if self == DATA
    self
  else
    super
  end
end

#instance?(o) ⇒ Boolean

Returns:

  • (Boolean)


1629
1630
1631
1632
1633
1634
1635
# File 'lib/puppet/pops/types/types.rb', line 1629

def instance?(o)
  return false unless o.is_a?(Array)
  element_t = element_type
  return false unless element_t.nil? || o.all? {|element| element_t.instance?(element) }
  size_t = size_type
  size_t.nil? || size_t.instance?(o.size)
end

#normalize(guard = nil) ⇒ Object



1621
1622
1623
1624
1625
1626
1627
# File 'lib/puppet/pops/types/types.rb', line 1621

def normalize(guard = nil)
  if self == DATA
    self
  else
    super
  end
end