Class: Puppet::Pops::Types::PRuntimeType

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

Constant Summary collapse

DEFAULT =
PRuntimeType.new(nil)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #callable_args?, #generalize, #kind_of_callable?, #normalize, #simple_name, #to_alias_expanded_s, #to_s

Methods included from Visitable

#accept

Constructor Details

#initialize(runtime, runtime_type_name = nil) ⇒ PRuntimeType

Returns a new instance of PRuntimeType.



2019
2020
2021
2022
# File 'lib/puppet/pops/types/types.rb', line 2019

def initialize(runtime, runtime_type_name = nil)
  @runtime = runtime
  @runtime_type_name = runtime_type_name
end

Instance Attribute Details

#runtimeObject (readonly)



2017
2018
2019
# File 'lib/puppet/pops/types/types.rb', line 2017

def runtime
  @runtime
end

#runtime_type_nameObject (readonly)



2017
2018
2019
# File 'lib/puppet/pops/types/types.rb', line 2017

def runtime_type_name
  @runtime_type_name
end

Instance Method Details

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


2028
2029
2030
# File 'lib/puppet/pops/types/types.rb', line 2028

def eql?(o)
  self.class == o.class && @runtime == o.runtime && @runtime_type_name == o.runtime_type_name
end

#hashObject



2024
2025
2026
# File 'lib/puppet/pops/types/types.rb', line 2024

def hash
  @runtime.hash ^ @runtime_type_name.hash
end

#instance?(o) ⇒ Boolean

Returns:

  • (Boolean)


2032
2033
2034
# File 'lib/puppet/pops/types/types.rb', line 2032

def instance?(o)
  assignable?(TypeCalculator.infer(o))
end

#iterable?(guard = nil) ⇒ Boolean

Returns:

  • (Boolean)


2036
2037
2038
2039
# File 'lib/puppet/pops/types/types.rb', line 2036

def iterable?(guard = nil)
  c = class_from_string(@runtime_type_name)
  c.nil? ? false : c < Iterable
end

#iterable_type(guard = nil) ⇒ Object



2041
2042
2043
# File 'lib/puppet/pops/types/types.rb', line 2041

def iterable_type(guard = nil)
  iterable?(guard) ? PIterableType.new(self) : nil
end