Class: Literal::Types::ArrayType Private
- Inherits:
-
Object
- Object
- Literal::Types::ArrayType
- Includes:
- Literal::Type
- Defined in:
- lib/literal/types/array_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, context: nil) ⇒ Object private
-
#initialize(type) ⇒ ArrayType
constructor
private
A new instance of ArrayType.
- #inspect ⇒ Object private
- #map ⇒ Object private
- #record_literal_type_errors(context) ⇒ Object private
Methods included from Literal::Type
Constructor Details
#initialize(type) ⇒ ArrayType
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 ArrayType.
7 8 9 10 |
# File 'lib/literal/types/array_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/array_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.
23 24 25 |
# File 'lib/literal/types/array_type.rb', line 23 def ===(value) Array === value && value.all?(@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.
27 28 29 30 31 32 33 34 |
# File 'lib/literal/types/array_type.rb', line 27 def >=(other, context: nil) case other when Literal::Types::ArrayType Literal.subtype?(other.type, @type, context:) 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/array_type.rb', line 14 def inspect "_Array(#{@type.inspect})" end |
#map ⇒ 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 |
# File 'lib/literal/types/array_type.rb', line 18 def map(&) new_type = yield(@type) Literal::Types::ArrayType.new(new_type) 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.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/literal/types/array_type.rb', line 36 def record_literal_type_errors(context) unless Array === context.actual return end context.actual.each_with_index do |item, index| unless @type === item context.add_child(label: "[#{index}]", expected: @type, actual: item) end end end |