Sha256: e554343b5668166bf7e45d81e73e317ad708729391273b56f87cf0b04572aaa1

Contents?: true

Size: 810 Bytes

Versions: 3

Compression:

Stored size: 810 Bytes

Contents

# encoding: utf-8

# WizRft:  A gem for exporting Word Documents in ruby
# using the Microsoft Rich Text Format (RTF) Specification
# Copyright (C) 2015 by sgzhe@163.com

module WizRtf
  class Table
    DEFAULT_COLUMN_WIDTH = 40
    attr_accessor :row_spans, :column_widths

    def initialize(rows = [], options = {}, &block)
      @rows = []
      @row_spans = {}
      @column_widths = options[:column_widths] || DEFAULT_COLUMN_WIDTH
      rows.each_index do |index|
        add_row rows[index]
      end
      block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
    end

    def add_row(cells = [])
      @rows << WizRtf::Row.new(self, cells)
    end

    def render(io)
      @rows.each do |row|
        row.render(io)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wiz_rtf-0.6.0 lib/wiz_rtf/table.rb
wiz_rtf-0.5.5 lib/wiz_rtf/table.rb
wiz_rtf-0.5.0 lib/wiz_rtf/table.rb