Module: Arrow::RecordContainable
- Included in:
- RecordBatch, Table
- Defined in:
- lib/arrow/record-containable.rb
Instance Method Summary collapse
- #each_column(&block) ⇒ Object
- #each_record(reuse_record: false) ⇒ Object
- #find_column(name_or_index) ⇒ Object
Instance Method Details
#each_column(&block) ⇒ Object
20 21 22 23 24 |
# File 'lib/arrow/record-containable.rb', line 20 def each_column(&block) return to_enum(__method__) unless block_given? columns.each(&block) end |
#each_record(reuse_record: false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/arrow/record-containable.rb', line 26 def each_record(reuse_record: false) unless block_given? return to_enum(__method__, reuse_record: reuse_record) end if reuse_record record = Record.new(self, nil) n_rows.times do |i| record.index = i yield(record) end else n_rows.times do |i| yield(Record.new(self, i)) end end end |
#find_column(name_or_index) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/arrow/record-containable.rb', line 44 def find_column(name_or_index) case name_or_index when String, Symbol name = name_or_index.to_s index = resolve_column_name(name) return nil if index.nil? columns[index] when Integer index = name_or_index columns[index] else = "column name or index must be String, Symbol or Integer" raise ArgumentError, end end |