Class: Literal::Types::DescendantType

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ DescendantType

Returns a new instance of DescendantType.



6
7
8
9
# File 'lib/literal/types/descendant_type.rb', line 6

def initialize(type)
  @type = type
  freeze
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/literal/types/descendant_type.rb', line 11

def type
  @type
end

Instance Method Details

#===(value) ⇒ Object



17
18
19
# File 'lib/literal/types/descendant_type.rb', line 17

def ===(value)
  Module === value && value < @type
end

#>=(other) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/literal/types/descendant_type.rb', line 21

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

#inspectObject



13
14
15
# File 'lib/literal/types/descendant_type.rb', line 13

def inspect
  "_Descendant(#{@type})"
end