Class: Yadriggy::CommonSuperType

Inherits:
Type
  • Object
show all
Defined in:
lib/yadriggy/type.rb

Overview

The most specific common super type. A value of this type is either an instance of self.type or a subclass of self.type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#!=, #copy, #eql?, error_found!, #exact_type, #has_role?, role

Constructor Details

#initialize(t) ⇒ CommonSuperType

Returns a new instance of CommonSuperType.

Parameters:

  • t (Module)

    the type.



243
244
245
# File 'lib/yadriggy/type.rb', line 243

def initialize(t)
  @type = t
end

Instance Attribute Details

#typeModule (readonly)

Returns the common super type.

Returns:

  • (Module)

    the common super type.



240
241
242
# File 'lib/yadriggy/type.rb', line 240

def type
  @type
end

Instance Method Details

#nameString

Obtains the name of this type.

Returns:

  • (String)

    the type name.



287
288
289
# File 'lib/yadriggy/type.rb', line 287

def name
  @type.name + '+'
end

#supertypeCommonSuperType|nil

Returns the Yadriggy::CommonSuperType for the super class.

Returns:



277
278
279
280
281
282
283
# File 'lib/yadriggy/type.rb', line 277

def supertype
  if @type.is_a?(Class) && !@type.superclass.nil?
    CommonSuperType.new(@type.superclass)
  else
    nil
  end
end