Class: Polars::DataType

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

Overview

Base class for all Polars data types.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.==(other) ⇒ Boolean

Check if this DataType is the same as another DataType.

Returns:



31
32
33
# File 'lib/polars/data_types.rb', line 31

def self.==(other)
  eql?(other) || other.is_a?(self)
end

.base_typeClass

Return this DataType's fundamental/root type class.

Examples:

Polars::Datetime.new("ns").base_type
# => Polars::Datetime
Polars::List.new(Polars::Int32).base_type
# => Polars::List
Polars::Struct.new([Polars::Field.new("a", Polars::Int64), Polars::Field.new("b", Polars::Boolean)]).base_type
# => Polars::Struct

Returns:

  • (Class)


17
18
19
# File 'lib/polars/data_types.rb', line 17

def self.base_type
  self
end

.decimal?Boolean

Check whether the data type is a decimal type.

Returns:



56
57
58
# File 'lib/polars/data_types.rb', line 56

def self.decimal?
  self == Decimal
end

.float?Boolean

Check whether the data type is a float type.

Returns:



84
85
86
# File 'lib/polars/data_types.rb', line 84

def self.float?
  self < FloatType
end

.integer?Boolean

Check whether the data type is an integer type.

Returns:



63
64
65
# File 'lib/polars/data_types.rb', line 63

def self.integer?
  self < IntegerType
end

.nested?Boolean

Check whether the data type is a nested type.

Returns:



98
99
100
# File 'lib/polars/data_types.rb', line 98

def self.nested?
  self < NestedType
end

.numeric?Boolean

Check whether the data type is a numeric type.

Returns:



49
50
51
# File 'lib/polars/data_types.rb', line 49

def self.numeric?
  self < NumericType
end

.signed_integer?Boolean

Check whether the data type is a signed integer type.

Returns:



70
71
72
# File 'lib/polars/data_types.rb', line 70

def self.signed_integer?
  self < SignedIntegerType
end

.temporal?Boolean

Check whether the data type is a temporal type.

Returns:



91
92
93
# File 'lib/polars/data_types.rb', line 91

def self.temporal?
  self < TemporalType
end

.unsigned_integer?Boolean

Check whether the data type is an unsigned integer type.

Returns:



77
78
79
# File 'lib/polars/data_types.rb', line 77

def self.unsigned_integer?
  self < UnsignedIntegerType
end

Instance Method Details

#==(other) ⇒ Boolean

Check if this DataType is the same as another DataType.

Returns:



38
39
40
41
42
43
44
# File 'lib/polars/data_types.rb', line 38

def ==(other)
  if other.is_a?(Class)
    is_a?(other)
  else
    other.instance_of?(self.class)
  end
end

#base_typeClass

Return this DataType's fundamental/root type class.

Returns:

  • (Class)


24
25
26
# File 'lib/polars/data_types.rb', line 24

def base_type
  is_a?(DataType) ? self.class : self
end

#inspectString

Returns a string representing the data type.

Returns:



118
119
120
# File 'lib/polars/data_types.rb', line 118

def inspect
  to_s
end

#to_sString

Returns a string representing the data type.

Returns:



111
112
113
# File 'lib/polars/data_types.rb', line 111

def to_s
  self.class.name
end