Sha256: da06ec387da74a4531b81e84c6a508e2548082b919ee0da2a0fb740e5f1dd548

Contents?: true

Size: 690 Bytes

Versions: 6

Compression:

Stored size: 690 Bytes

Contents

module XlsxWriter
  class Row
    attr_reader :sheet
    attr_reader :cells
    attr_reader :width
    
    def initialize(sheet, columns)
      @width = {}
      @sheet = sheet
      @cells = columns.map do |column|
        Cell.new self, column
      end
    end
    
    def ndx
      sheet.rows.index(self) + 1
    end
    
    def length
      cells.length
    end
    
    def cell_width(x)
      @width[x] ||= if (cell = cells[x])
        cell.pixel_width
      else
        0
      end
    end
    
    def to_xml
      ary = []
      ary << %{<row r="#{ndx}">}
      cells.each do |cell|
        ary << cell.to_xml
      end
      ary << %{</row>}
      ary.join
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xlsx_writer-0.3.2 lib/xlsx_writer/row.rb
xlsx_writer-0.3.1 lib/xlsx_writer/row.rb
xlsx_writer-0.3.0 lib/xlsx_writer/row.rb
xlsx_writer-0.2.2 lib/xlsx_writer/row.rb
xlsx_writer-0.2.1 lib/xlsx_writer/row.rb
xlsx_writer-0.2.0 lib/xlsx_writer/row.rb