Class: ThousandIsland::TableSettings
- Inherits:
-
Object
- Object
- ThousandIsland::TableSettings
- 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
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
-
#pdf ⇒ Object
readonly
Returns the value of attribute pdf.
Instance Method Summary collapse
- #cell_styles ⇒ Object
- #default_options ⇒ Object
- #footer_format ⇒ Object
- #header_format ⇒ Object
-
#initialize(pdf, overrides = {}) ⇒ TableSettings
constructor
A new instance of TableSettings.
- #settings ⇒ Object
- #table_settings ⇒ Object
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
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
6 7 8 |
# File 'lib/thousand_island/table_settings.rb', line 6 def overrides @overrides end |
#pdf ⇒ Object (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_styles ⇒ Object
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_options ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/thousand_island/table_settings.rb', line 22 def { width: pdf.bounds.width, cell_style: cell_styles, position: :center, header_format: header_format, header_repeat: true, footer_format: } end |
#footer_format ⇒ Object
50 51 52 53 54 |
# File 'lib/thousand_island/table_settings.rb', line 50 def { font_style: :bold } end |
#header_format ⇒ Object
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 |
#settings ⇒ Object
18 19 20 |
# File 'lib/thousand_island/table_settings.rb', line 18 def settings .merge(table_settings.merge(overrides)) end |
#table_settings ⇒ Object
14 15 16 |
# File 'lib/thousand_island/table_settings.rb', line 14 def table_settings {} end |