Class: Literal::Types::SetType Private
- Inherits:
-
Object
- Object
- Literal::Types::SetType
- Includes:
- Literal::Type
- Defined in:
- lib/literal/types/set_type.rb
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.
Instance Attribute Summary collapse
- #type ⇒ Object readonly private
Instance Method Summary collapse
- #===(value) ⇒ Object private
- #>=(other) ⇒ Object private
-
#initialize(type) ⇒ SetType
constructor
private
A new instance of SetType.
- #inspect ⇒ Object private
- #record_literal_type_errors(context) ⇒ Object private
Constructor Details
#initialize(type) ⇒ SetType
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 SetType.
7 8 9 10 |
# File 'lib/literal/types/set_type.rb', line 7 def initialize(type) @type = type freeze end |
Instance Attribute Details
#type ⇒ Object (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.
12 13 14 |
# File 'lib/literal/types/set_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.
18 19 20 21 22 23 24 25 26 |
# File 'lib/literal/types/set_type.rb', line 18 def ===(value) return false unless Set === value value.each do |v| return false unless @type === v end true end |
#>=(other) ⇒ 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.
38 39 40 41 42 43 44 45 |
# File 'lib/literal/types/set_type.rb', line 38 def >=(other) case other when Literal::Types::SetType Literal.subtype?(other.type, @type) else false end end |
#inspect ⇒ 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.
14 15 16 |
# File 'lib/literal/types/set_type.rb', line 14 def inspect "_Set(#{@type.inspect})" end |
#record_literal_type_errors(context) ⇒ 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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/literal/types/set_type.rb', line 28 def record_literal_type_errors(context) return unless Set === context.actual context.actual.each do |actual| unless @type === actual context.add_child(label: "[]", expected: @type, actual:) end end end |