Class: Polars::Decimal

Inherits:
NumericType show all
Defined in:
lib/polars/data_types.rb

Overview

Decimal 128-bit type with an optional precision and non-negative scale.

NOTE: this is an experimental work-in-progress feature and may not work as expected.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(precision = nil, scale = 0) ⇒ Decimal

Returns a new instance of Decimal.



230
231
232
233
234
235
236
237
# File 'lib/polars/data_types.rb', line 230

def initialize(precision = nil, scale = 0)
  if precision.nil?
    precision = 38
  end

  @precision = precision
  @scale = scale
end

Instance Attribute Details

#precisionObject (readonly)

Returns the value of attribute precision.



228
229
230
# File 'lib/polars/data_types.rb', line 228

def precision
  @precision
end

#scaleObject (readonly)

Returns the value of attribute scale.



228
229
230
# File 'lib/polars/data_types.rb', line 228

def scale
  @scale
end

Instance Method Details

#==(other) ⇒ Object



239
240
241
242
243
244
245
246
247
# File 'lib/polars/data_types.rb', line 239

def ==(other)
  if other.eql?(Decimal)
    true
  elsif other.is_a?(Decimal)
    precision == other.precision && scale == other.scale
  else
    false
  end
end

#to_sObject



249
250
251
# File 'lib/polars/data_types.rb', line 249

def to_s
  "#{self.class.name}(precision: #{precision.inspect}, scale: #{scale.inspect})"
end