Class: Polars::Array

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

Overview

Nested list/array type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inner, width) ⇒ Array

Returns a new instance of Array.



468
469
470
471
472
473
474
# File 'lib/polars/data_types.rb', line 468

def initialize(inner, width)
  if width.is_a?(DataType) || (width.is_a?(Class) && width < DataType)
    inner, width = width, inner
  end
  @inner = Utils.rb_type_to_dtype(inner) if inner
  @width = width
end

Instance Attribute Details

#innerObject (readonly)

Returns the value of attribute inner.



466
467
468
# File 'lib/polars/data_types.rb', line 466

def inner
  @inner
end

#widthObject (readonly)

Returns the value of attribute width.



466
467
468
# File 'lib/polars/data_types.rb', line 466

def width
  @width
end

Instance Method Details

#==(other) ⇒ Object



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/polars/data_types.rb', line 476

def ==(other)
  if other.eql?(Array)
    true
  elsif other.is_a?(Array)
    if @width != other.width
      false
    elsif @inner.nil? || other.inner.nil?
      true
    else
      @inner == other.inner
    end
  else
    false
  end
end

#to_sObject



492
493
494
# File 'lib/polars/data_types.rb', line 492

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