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.



389
390
391
392
393
394
395
# File 'lib/polars/data_types.rb', line 389

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.



387
388
389
# File 'lib/polars/data_types.rb', line 387

def inner
  @inner
end

#widthObject (readonly)

Returns the value of attribute width.



387
388
389
# File 'lib/polars/data_types.rb', line 387

def width
  @width
end

Instance Method Details

#==(other) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/polars/data_types.rb', line 397

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



413
414
415
# File 'lib/polars/data_types.rb', line 413

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