Class: ThousandIsland::TableSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/thousand_island/table_settings.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf, overrides = {}) ⇒ TableSettings

Returns a new instance of TableSettings.



8
9
10
11
# File 'lib/thousand_island/table_settings.rb', line 8

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

Instance Attribute Details

#overridesObject (readonly)

Returns the value of attribute overrides.



6
7
8
# File 'lib/thousand_island/table_settings.rb', line 6

def overrides
  @overrides
end

#pdfObject (readonly)

Returns the value of attribute pdf.



6
7
8
# File 'lib/thousand_island/table_settings.rb', line 6

def pdf
  @pdf
end

Instance Method Details

#cell_stylesObject



33
34
35
36
37
38
39
40
# File 'lib/thousand_island/table_settings.rb', line 33

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

#default_optionsObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/thousand_island/table_settings.rb', line 22

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


50
51
52
53
54
# File 'lib/thousand_island/table_settings.rb', line 50

def footer_format
  {
      font_style: :bold
  }
end

#header_formatObject



42
43
44
45
46
47
48
# File 'lib/thousand_island/table_settings.rb', line 42

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

end

#settingsObject



18
19
20
# File 'lib/thousand_island/table_settings.rb', line 18

def settings
  deep_merger.merge_options(overrides, table_settings, default_options)
end

#table_settingsObject



14
15
16
# File 'lib/thousand_island/table_settings.rb', line 14

def table_settings
  {}
end