Class: Arrow::Scalar
- Inherits:
-
Object
- Object
- Arrow::Scalar
- Defined in:
- lib/arrow/scalar.rb
Class Method Summary collapse
-
.resolve(value, data_type = nil) ⇒ Object
Ensure returning suitable Scalar.
- .try_convert(value) ⇒ Object private
Instance Method Summary collapse
-
#equal_scalar?(other, options = nil) ⇒ Boolean
‘true` if both of them have the same data, `false` otherwise.
Class Method Details
.resolve(scalar) ⇒ Arrow::Scalar .resolve(value) ⇒ Arrow::Scalar .resolve(value, data_type) ⇒ Arrow::Scalar
Ensure returning suitable Arrow::Scalar.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/arrow/scalar.rb', line 73 def resolve(value, data_type=nil) return try_convert(value) if data_type.nil? data_type = DataType.resolve(data_type) scalar_class = data_type.scalar_class case value when Scalar return value if value.class == scalar_class value = value.value end scalar_class.new(value) end |
.try_convert(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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/arrow/scalar.rb', line 22 def try_convert(value) case value when self value when true, false BooleanScalar.new(value) when Symbol, String StringScalar.new(value.to_s) when Integer Int64Scalar.new(value) when Float DoubleScalar.new(value) else nil end end |
Instance Method Details
#equal_scalar?(other, options = nil) ⇒ Boolean
Returns ‘true` if both of them have the same data, `false` otherwise.
95 96 97 |
# File 'lib/arrow/scalar.rb', line 95 def equal_scalar?(other, =nil) (other, ) end |