Class: Literal::Types::ClassType Private

Inherits:
Object
  • Object
show all
Includes:
Literal::Type
Defined in:
lib/literal/types/class_type.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Literal::Type

#<=

Constructor Details

#initialize(type) ⇒ ClassType

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ClassType.

API:

  • private



7
8
9
10
# File 'lib/literal/types/class_type.rb', line 7

def initialize(type)
  @type = type
  freeze
end

Instance Attribute Details

#typeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



12
13
14
# File 'lib/literal/types/class_type.rb', line 12

def type
  @type
end

Instance Method Details

#===(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



18
19
20
# File 'lib/literal/types/class_type.rb', line 18

def ===(value)
  Class === value && (value == @type || value < @type)
end

#>=(other, context: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



22
23
24
25
26
27
28
29
30
31
# File 'lib/literal/types/class_type.rb', line 22

def >=(other, context: nil)
  case other
  when Literal::Types::ClassType
    Literal.subtype?(other.type, @type, context:)
  when Literal::Types::DescendantType
    (Class === other.type) && Literal.subtype?(other.type, @type, context:)
  else
    false
  end
end

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



14
15
16
# File 'lib/literal/types/class_type.rb', line 14

def inspect
  "_Class(#{@type.name})"
end