Class: Literal::Types::DescendantType
- Inherits:
-
Object
- Object
- Literal::Types::DescendantType
- Includes:
- Literal::Type
- Defined in:
- lib/literal/types/descendant_type.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #===(value) ⇒ Object
- #>=(other) ⇒ Object
-
#initialize(type) ⇒ DescendantType
constructor
A new instance of DescendantType.
- #inspect ⇒ Object
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
#type ⇒ Object (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 |
#inspect ⇒ Object
13 14 15 |
# File 'lib/literal/types/descendant_type.rb', line 13 def inspect "_Descendant(#{@type})" end |