Class: Yadriggy::NonRubyType

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

Instance Method Summary collapse

Methods inherited from Type

#!=, #copy, #eql?, error_found!, #exact_type, get_instance_method_object, #get_method_object, #has_role?, #is_super_of?, role, #supertype

Constructor Details

#initialize(obj_name, type_name) ⇒ NonRubyType

Returns a new instance of NonRubyType.



116
117
118
119
# File 'lib/yadriggy/type.rb', line 116

def initialize(obj_name, type_name)
  @obj_name = obj_name
  @type_name = type_name
end

Instance Method Details

#<=(t) ⇒ Boolean

Check the subtype relation.

Parameters:

  • t (Type)

    the other type.

Returns:

  • (Boolean)

    true if ‘self` is equivalent to `t`.



138
139
140
# File 'lib/yadriggy/type.rb', line 138

def <= (t)
  self == t || t.is_super_of?(self)
end

#==(t) ⇒ Boolean

Checks the equality.

Parameters:

  • t (Type)

    the other type.

Returns:

  • (Boolean)

    true if ‘self` and `t` represent the same type.



130
131
132
133
# File 'lib/yadriggy/type.rb', line 130

def == (t)
  r = NonRubyType.role(t)
  self.equal?(r)
end

#inspectObject



147
148
149
# File 'lib/yadriggy/type.rb', line 147

def inspect()
  @obj_name
end

#nameString

Obtains the name of this type.

Returns:

  • (String)

    the type name.



123
124
125
# File 'lib/yadriggy/type.rb', line 123

def name
  @type_name
end

#role(t) ⇒ Object



142
143
144
145
# File 'lib/yadriggy/type.rb', line 142

def role(t)
  r = NonRubyType.role(t)
  self.equal?(r) ? self : nil
end