Sha256: 235d0f7f2de699d5d9a8b30d1b58bb947d6a10aae36f600c9497e2cf8901dc12

Contents?: true

Size: 500 Bytes

Versions: 3

Compression:

Stored size: 500 Bytes

Contents

module Tabulo

  class Row
    include Enumerable

    def initialize(table, source, options = { with_header: true })
      @table = table
      @source = source
      @with_header = options[:with_header]
    end

    def each
      @table.columns.each do |column|
        yield column.body_cell_value(@source)
      end
    end

    def to_s
      @table.formatted_body_row(@source, with_header: @with_header)
    end

    def to_h
      @table.columns.map(&:label).zip(to_a).to_h
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tabulo-0.2.1 lib/tabulo/row.rb
tabulo-0.2.0 lib/tabulo/row.rb
tabulo-0.1.0 lib/tabulo/row.rb