Sha256: 732ac9697b1a45bb2195f141eacef4c0e3b0297ccfc4b0f6a00b417551dc80e4

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

module TablePal
  class Row

    attr_reader :table, :formatter, :heading, :subheading, :section_end, :justification, :colour

    def initialize(table:, formatter: nil, heading: false, subheading: false, section_end: false, justification: nil, colour: nil)
      @table         = table
      @formatter     = formatter
      @heading       = heading
      @subheading    = subheading
      @section_end   = section_end
      @justification = justification
      @colour        = colour
    end

    def cells_including_empty
      table.columns.map do |column|
        find_cell(column) || create_cell(column)
      end
    end

    def underline_cells
      table.columns.map do |column|
        table.create_cell(row: self, column: column, content: '-' * column.width)
      end
    end

    def empty_cells
      table.columns.map do |column|
        table.create_cell(row: self, column: column)
      end
    end

    private

    def find_cell(column)
      table.find_cell(row: self, column: column)
    end

    def create_cell(column)
      table.create_cell(row: self, column: column)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
table_pal-0.3.3 lib/row.rb
table_pal-0.3.2 lib/row.rb
table_pal-0.3.1 lib/row.rb
table_pal-0.3.0 lib/row.rb