Class: Thinreports::BasicReport::Report::Base
- Inherits:
-
Object
- Object
- Thinreports::BasicReport::Report::Base
- Extended by:
- Forwardable
- Includes:
- Utils
- Defined in:
- lib/thinreports/basic_report/report/base.rb
Instance Attribute Summary collapse
Class Method Summary collapse
- .create(options = {}) {|report| ... } ⇒ Thinreports::BasicReport::Report::Base
- .generate(layout: nil, filename: nil, security: nil, title: nil, report: {}, generator: {}) {|report| ... } ⇒ String
Instance Method Summary collapse
- #add_blank_page(options = {}) ⇒ Thinreports::BasicReport::Report::BlankPage (also: #blank_page)
- #generate(filename: nil, security: nil, title: nil) ⇒ String
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #layout(id = nil) ⇒ Thinreports::BasicReport::Layout::Base
- #list(id = nil, &block) ⇒ Object
- #on_page_create {|page| ... } ⇒ Object
- #start_new_page(options = {}) {|page| ... } ⇒ Thinreports::BasicReport::Report::Page
- #start_page_number_from(page_number) ⇒ Object
- #use_layout(layout, options = {}) ⇒ Object
Methods included from Utils
#blank_value?, #call_block_in, #deep_copy, included
Constructor Details
Instance Attribute Details
#internal ⇒ Thinreports::BasicReport::Layout::Base (readonly)
53 54 55 |
# File 'lib/thinreports/basic_report/report/base.rb', line 53 def internal @internal end |
#start_page_number ⇒ Integer (readonly)
56 57 58 |
# File 'lib/thinreports/basic_report/report/base.rb', line 56 def start_page_number @start_page_number end |
Class Method Details
.create(options = {}) {|report| ... } ⇒ Thinreports::BasicReport::Report::Base
16 17 18 19 20 21 22 23 24 |
# File 'lib/thinreports/basic_report/report/base.rb', line 16 def create( = {}, &block) raise ArgumentError, '#create requires a block' unless block_given? report = new() call_block_in(report, &block) report.finalize report end |
.generate(layout: nil, filename: nil, security: nil, title: nil, report: {}, generator: {}) {|report| ... } ⇒ String
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/thinreports/basic_report/report/base.rb', line 35 def generate(layout: nil, filename: nil, security: nil, title: nil, report: {}, generator: {}, &block) raise ArgumentError, '#generate requires a block' unless block_given? if report.any? || generator.any? warn '[DEPRECATION] :report and :generator argument has been deprecated. ' \ 'Use :layout and :filename, :security argument instead.' end layout ||= report[:layout] filename ||= generator[:filename] security ||= generator[:security] report = create(layout: layout, &block) report.generate(filename: filename, security: security, title: title) end |
Instance Method Details
#add_blank_page(options = {}) ⇒ Thinreports::BasicReport::Report::BlankPage Also known as: blank_page
135 136 137 |
# File 'lib/thinreports/basic_report/report/base.rb', line 135 def add_blank_page( = {}) internal.add_page(Report::BlankPage.new([:count])) end |
#generate(filename: nil, security: nil, title: nil) ⇒ String
160 161 162 |
# File 'lib/thinreports/basic_report/report/base.rb', line 160 def generate(filename: nil, security: nil, title: nil) Thinreports::BasicReport::Generator::PDF.new(self, security: security, title: title).generate(filename) end |
#layout(id = nil) ⇒ Thinreports::BasicReport::Layout::Base
142 143 144 145 146 147 148 149 |
# File 'lib/thinreports/basic_report/report/base.rb', line 142 def layout(id = nil) if id internal.layout_registry[id] || raise(Thinreports::BasicReport::Errors::UnknownLayoutId) else internal.default_layout end end |
#list(id = nil, &block) ⇒ Object
165 166 167 168 |
# File 'lib/thinreports/basic_report/report/base.rb', line 165 def list(id = nil, &block) start_new_page if page.nil? || page.finalized? page.list(id, &block) end |
#on_page_create {|page| ... } ⇒ Object
83 84 85 |
# File 'lib/thinreports/basic_report/report/base.rb', line 83 def on_page_create(&block) internal.page_create_handler = block end |
#start_new_page(options = {}) {|page| ... } ⇒ Thinreports::BasicReport::Report::Page
123 124 125 126 127 128 129 130 |
# File 'lib/thinreports/basic_report/report/base.rb', line 123 def start_new_page( = {}, &block) layout = internal.load_layout(.delete(:layout)) raise Thinreports::BasicReport::Errors::NoRegisteredLayoutFound unless layout page = internal.add_page(Report::Page.new(self, layout, )) call_block_in(page, &block) end |
#start_page_number_from(page_number) ⇒ Object
88 89 90 |
# File 'lib/thinreports/basic_report/report/base.rb', line 88 def start_page_number_from(page_number) @start_page_number = page_number end |
#use_layout(layout, options = {}) ⇒ Object
100 101 102 |
# File 'lib/thinreports/basic_report/report/base.rb', line 100 def use_layout(layout, = {}) internal.register_layout(layout, ) end |