Class: Polars::Struct
- Inherits:
-
NestedType
- Object
- DataType
- NestedType
- Polars::Struct
- Defined in:
- lib/polars/data_types.rb
Overview
Struct composite type.
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(fields) ⇒ Struct
constructor
A new instance of Struct.
- #to_s ⇒ Object
- #to_schema ⇒ Object
Constructor Details
permalink #initialize(fields) ⇒ Struct
Returns a new instance of Struct.
446 447 448 449 450 451 452 |
# File 'lib/polars/data_types.rb', line 446 def initialize(fields) if fields.is_a?(Hash) @fields = fields.map { |n, d| Field.new(n, d) } else @fields = fields end end |
Instance Attribute Details
Instance Method Details
permalink #==(other) ⇒ Object
[View source]
454 455 456 457 458 459 460 461 462 |
# File 'lib/polars/data_types.rb', line 454 def ==(other) if other.eql?(Struct) true elsif other.is_a?(Struct) fields == other.fields else false end end |
permalink #to_s ⇒ Object
[View source]
464 465 466 |
# File 'lib/polars/data_types.rb', line 464 def to_s "#{self.class.name}(#{fields.to_h { |f| [f.name, f.dtype] }})" end |
permalink #to_schema ⇒ Object
[View source]
468 469 470 |
# File 'lib/polars/data_types.rb', line 468 def to_schema @fields.to_h { |f| [f.name, f.dtype] } end |