Class: Pdf::Layout
- Inherits:
-
Object
- Object
- Pdf::Layout
- Defined in:
- lib/pdf/layout.rb
Class Attribute Summary collapse
-
.footer_blueprint ⇒ Object
readonly
Returns the value of attribute footer_blueprint.
-
.header_blueprint ⇒ Object
readonly
Returns the value of attribute header_blueprint.
Instance Attribute Summary collapse
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
- .footer(&block) ⇒ Object
- .header(&block) ⇒ Object
- .inherited(subclass) ⇒ Object
- .margins(**options) ⇒ Object
- .margins_config ⇒ Object
Instance Method Summary collapse
-
#initialize(view) ⇒ Layout
constructor
A new instance of Layout.
- #render(renderer) ⇒ Object
Constructor Details
#initialize(view) ⇒ Layout
Returns a new instance of Layout.
37 38 39 |
# File 'lib/pdf/layout.rb', line 37 def initialize(view) @view = view end |
Class Attribute Details
.footer_blueprint ⇒ Object (readonly)
Returns the value of attribute footer_blueprint.
28 29 30 |
# File 'lib/pdf/layout.rb', line 28 def @footer_blueprint end |
.header_blueprint ⇒ Object (readonly)
Returns the value of attribute header_blueprint.
28 29 30 |
# File 'lib/pdf/layout.rb', line 28 def header_blueprint @header_blueprint end |
Instance Attribute Details
#view ⇒ Object (readonly)
Returns the value of attribute view.
35 36 37 |
# File 'lib/pdf/layout.rb', line 35 def view @view end |
Class Method Details
.footer(&block) ⇒ Object
18 19 20 21 22 |
# File 'lib/pdf/layout.rb', line 18 def (&block) builder = Builders::FooterBuilder.new builder.instance_eval(&block) @footer_blueprint = builder.blueprint end |
.header(&block) ⇒ Object
12 13 14 15 16 |
# File 'lib/pdf/layout.rb', line 12 def header(&block) builder = Builders::HeaderBuilder.new builder.instance_eval(&block) @header_blueprint = builder.blueprint end |
.inherited(subclass) ⇒ Object
6 7 8 9 10 |
# File 'lib/pdf/layout.rb', line 6 def inherited(subclass) subclass.instance_variable_set(:@header_blueprint, nil) subclass.instance_variable_set(:@footer_blueprint, nil) subclass.instance_variable_set(:@margins_config, Pdf::DEFAULT_MARGINS.dup) end |
.margins(**options) ⇒ Object
24 25 26 |
# File 'lib/pdf/layout.rb', line 24 def margins(**) @margins_config = Pdf::DEFAULT_MARGINS.merge() end |
.margins_config ⇒ Object
30 31 32 |
# File 'lib/pdf/layout.rb', line 30 def margins_config @margins_config || Pdf::DEFAULT_MARGINS end |
Instance Method Details
#render(renderer) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/pdf/layout.rb', line 41 def render(renderer) renderer.setup(margins: self.class.margins_config) render_header(renderer) if self.class.header_blueprint view.render_content(renderer) (renderer) if self.class. end |