class Yadriggy::InstanceType
Type
of a particular Ruby object.
Attributes
object[R]
@return [Object] the Ruby object.
Public Class Methods
new(obj)
click to toggle source
# File lib/yadriggy/type.rb, line 416 def initialize(obj) @object = obj end
Public Instance Methods
<=(t)
click to toggle source
@api private Check the subtype relation. @param [Type] t the other type. @return [Boolean] true if `self` is equivalent to `t`
or a subtype of `t`.
# File lib/yadriggy/type.rb, line 435 def <= (t) if t.is_super_of?(self) true else it = InstanceType.role(t) (!it.nil? && it.object == @object) || RubyClass[exact_type] <= t end end
==(t)
click to toggle source
@api private
# File lib/yadriggy/type.rb, line 421 def == (t) InstanceType.role(t)&.object == @object end
exact_type()
click to toggle source
@api private Recall that `1.class` was `Fixnum` in Ruby earlier than 2.4.
# File lib/yadriggy/type.rb, line 447 def exact_type @object.is_a?(Integer) ? Integer : @object.class end
get_method_object(method_name)
click to toggle source
@api private
# File lib/yadriggy/type.rb, line 452 def get_method_object(method_name) @object.method(method_name) rescue NameError Type.error_found!("no such method: #{@object.class}\##{method_name}") end
hash()
click to toggle source
@api private
# File lib/yadriggy/type.rb, line 426 def hash @object.hash end
name()
click to toggle source
Obtains the name of this type. @return [String] the type name.
# File lib/yadriggy/type.rb, line 465 def name @object.to_s end
supertype()
click to toggle source
@return [RubyClass] the {RubyClass} for this class.
# File lib/yadriggy/type.rb, line 459 def supertype RubyClass[exact_type] end