Class: Puppet::Pops::Types::PNotUndefType

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

Constant Summary collapse

DEFAULT =
PNotUndefType.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PAnyType

#assignable?, #callable?, #callable_args?, #enumerable?, #kind_of_callable?, #simple_name, #to_s

Methods included from Visitable

#accept

Constructor Details

#initialize(type = nil) ⇒ PNotUndefType

Returns a new instance of PNotUndefType.



231
232
233
# File 'lib/puppet/pops/types/types.rb', line 231

def initialize(type = nil)
  @type = type.class == PAnyType ? nil : type
end

Instance Attribute Details

#typeObject (readonly)



229
230
231
# File 'lib/puppet/pops/types/types.rb', line 229

def type
  @type
end

Instance Method Details

#==(o) ⇒ Object



247
248
249
# File 'lib/puppet/pops/types/types.rb', line 247

def ==(o)
  self.class == o.class && @type == o.type
end

#generalizeObject



239
240
241
# File 'lib/puppet/pops/types/types.rb', line 239

def generalize
  @type.nil? ? DEFAULT : PNotUndefType.new(type.generalize)
end

#hashObject



243
244
245
# File 'lib/puppet/pops/types/types.rb', line 243

def hash
  31 * @type.hash
end

#instance?(o) ⇒ Boolean

Returns:

  • (Boolean)


235
236
237
# File 'lib/puppet/pops/types/types.rb', line 235

def instance?(o)
  !(o.nil? || o == :undef) && (@type.nil? || @type.instance?(o))
end