Class: Puppet::Pops::Types::PScalarType

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

Overview

Type that is a Scalar

Constant Summary collapse

DEFAULT =
PScalarType.new

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #eql?, #generalize, #hash, #iterable?, #iterable_type, #kind_of_callable?, #loader, #name, #new_function, new_function, #normalize, #really_instance?, #resolve, #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

Class Method Details

.register_ptype(loader, ir) ⇒ Object



685
686
687
# File 'lib/puppet/pops/types/types.rb', line 685

def self.register_ptype(loader, ir)
  create_ptype(loader, ir, 'AnyType')
end

Instance Method Details

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

Returns:

  • (Boolean)


689
690
691
692
693
694
695
696
697
# File 'lib/puppet/pops/types/types.rb', line 689

def instance?(o, guard = nil)
  if o.is_a?(String) || o.is_a?(Numeric) || o.is_a?(TrueClass) || o.is_a?(FalseClass) || o.is_a?(Regexp)
    true
  elsif o.instance_of?(Array) || o.instance_of?(Hash) || o.is_a?(PAnyType) || o.is_a?(NilClass)
    false
  else
    assignable?(TypeCalculator.infer(o))
  end
end

#roundtrip_with_string?Boolean

Returns:

  • (Boolean)


699
700
701
# File 'lib/puppet/pops/types/types.rb', line 699

def roundtrip_with_string?
  true
end