Class: Thinreports::BasicReport::Report::Internal
- Inherits:
-
Object
- Object
- Thinreports::BasicReport::Report::Internal
- Defined in:
- lib/thinreports/basic_report/report/internal.rb
Instance Attribute Summary collapse
-
#default_layout ⇒ Object
readonly
Returns the value of attribute default_layout.
-
#layout_registry ⇒ Object
readonly
Returns the value of attribute layout_registry.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#page_create_handler ⇒ Object
Returns the value of attribute page_create_handler.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
Instance Method Summary collapse
- #add_page(new_page) ⇒ Object
- #copy_page ⇒ Object
- #finalize ⇒ Object
- #finalized? ⇒ Boolean
-
#initialize(report, options) ⇒ Internal
constructor
A new instance of Internal.
- #load_layout(id_or_filename) ⇒ Object
- #register_layout(layout, options = {}) ⇒ Object
Constructor Details
#initialize(report, options) ⇒ Internal
Returns a new instance of Internal.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 17 def initialize(report, ) @report = report @default_layout = [:layout] ? init_layout([:layout]) : nil @layout_registry = {} @finalized = false @pages = [] @page = nil @page_count = 0 @page_create_handler = nil end |
Instance Attribute Details
#default_layout ⇒ Object (readonly)
Returns the value of attribute default_layout.
10 11 12 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 10 def default_layout @default_layout end |
#layout_registry ⇒ Object (readonly)
Returns the value of attribute layout_registry.
11 12 13 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 11 def layout_registry @layout_registry end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
8 9 10 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 8 def page @page end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
9 10 11 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 9 def page_count @page_count end |
#page_create_handler ⇒ Object
Returns the value of attribute page_create_handler.
13 14 15 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 13 def page_create_handler @page_create_handler end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
7 8 9 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 7 def pages @pages end |
Instance Method Details
#add_page(new_page) ⇒ Object
42 43 44 45 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 42 def add_page(new_page) finalize_current_page insert_page(new_page) end |
#copy_page ⇒ Object
47 48 49 50 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 47 def copy_page finalize_current_page(at: :copy) insert_page(page.copy) end |
#finalize ⇒ Object
52 53 54 55 56 57 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 52 def finalize return if finalized? finalize_current_page @finalized = true end |
#finalized? ⇒ Boolean
59 60 61 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 59 def finalized? @finalized end |
#load_layout(id_or_filename) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 63 def load_layout(id_or_filename) return @default_layout if id_or_filename.nil? layout = case id_or_filename when Symbol layout_registry[id_or_filename] when String init_layout(id_or_filename) else raise ArgumentError, 'Invalid argument for layout.' end @default_layout ||= layout layout end |
#register_layout(layout, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/thinreports/basic_report/report/internal.rb', line 31 def register_layout(layout, = {}) if .empty? || [:default] @default_layout = init_layout(layout) else id = [:id].to_sym raise ArgumentError, "Id :#{id} is already in use." if layout_registry.key?(id) layout_registry[id] = init_layout(layout, id) end end |