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
#initialize(fields) ⇒ Struct
Returns a new instance of Struct.
538 539 540 541 542 543 544 |
# File 'lib/polars/data_types.rb', line 538 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
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
536 537 538 |
# File 'lib/polars/data_types.rb', line 536 def fields @fields end |
Instance Method Details
#==(other) ⇒ Object
546 547 548 549 550 551 552 553 554 |
# File 'lib/polars/data_types.rb', line 546 def ==(other) if other.eql?(Struct) true elsif other.is_a?(Struct) fields == other.fields else false end end |
#to_s ⇒ Object
556 557 558 |
# File 'lib/polars/data_types.rb', line 556 def to_s "#{self.class.name}(#{fields.to_h { |f| [f.name, f.dtype] }})" end |
#to_schema ⇒ Object
560 561 562 |
# File 'lib/polars/data_types.rb', line 560 def to_schema @fields.to_h { |f| [f.name, f.dtype] } end |