Class: Yadriggy::CommonSuperType
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
-
#type ⇒ Module
readonly
The common super type.
Instance Method Summary collapse
-
#<=(t) ⇒ Boolean
Check the subtype relation.
- #==(t) ⇒ Object
- #get_method_object(method_name) ⇒ Object
- #hash ⇒ Object
-
#initialize(t) ⇒ CommonSuperType
constructor
A new instance of CommonSuperType.
-
#name ⇒ String
Obtains the name of this type.
-
#supertype ⇒ CommonSuperType|nil
The CommonSuperType for the super class.
Methods inherited from Type
#!=, #copy, #eql?, error_found!, #exact_type, get_instance_method_object, #has_role?, #is_super_of?, role
Constructor Details
#initialize(t) ⇒ CommonSuperType
243 244 245 |
# File 'lib/yadriggy/type.rb', line 243 def initialize(t) @type = t end |
Instance Attribute Details
#type ⇒ Module (readonly)
240 241 242 |
# File 'lib/yadriggy/type.rb', line 240 def type @type end |
Instance Method Details
#<=(t) ⇒ Boolean
Check the subtype relation. or a subtype of ‘t`.
262 263 264 265 266 267 268 269 |
# File 'lib/yadriggy/type.rb', line 262 def <= (t) if t.is_super_of?(self) true else ct = CommonSuperType.role(t) !ct.nil? && (@type <= ct.type || @type == NilClass) end end |
#==(t) ⇒ Object
248 249 250 |
# File 'lib/yadriggy/type.rb', line 248 def == (t) CommonSuperType.role(t)&.type == @type end |
#get_method_object(method_name) ⇒ Object
272 273 274 |
# File 'lib/yadriggy/type.rb', line 272 def get_method_object(method_name) nil end |
#hash ⇒ Object
253 254 255 |
# File 'lib/yadriggy/type.rb', line 253 def hash @type.hash + 1 end |
#name ⇒ String
Obtains the name of this type.
287 288 289 |
# File 'lib/yadriggy/type.rb', line 287 def name @type.name + '+' end |
#supertype ⇒ CommonSuperType|nil
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 |