Sha256: 1a73aeb204ac6682d55371db379ba7513522a550a03fa5c1122b8582c4be9158

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module ThousandIsland
  # The TableSettings class is where you set up styling rules that can be used by your Table class. You may create a class that inherits from TableSettings, and then use it in any of your tables. You can sub-class your TableStyles so you may define a master style for your app, but then have derived styles for special situations.
  #
  class TableSettings

    attr_reader :pdf, :overrides

    def initialize(pdf, overrides={})
      @pdf = pdf
      @overrides = overrides
    end

    #@TODO override this one!!! Do the docs...
    def table_settings
      {}
    end

    def settings
      default_options.merge(table_settings.merge(overrides))
    end

    def default_options
      {
          width: pdf.bounds.width,
          cell_style: cell_styles,
          position: :center,
          header_format: header_format,
          header_repeat: true,
          footer_format: footer_format
      }
    end

    def cell_styles
      {
          borders: [:top, :bottom],
          border_width: 0.5,
          inline_format: true,
          size: 10
      }
    end

    def header_format
      {
          align: :center,
          font_style: :bold
      }

    end

    def footer_format
      {
          font_style: :bold
      }
    end


  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thousand_island-0.1.1 lib/thousand_island/table_settings.rb
thousand_island-0.1.0 lib/thousand_island/table_settings.rb