Class: Elegant::Document
- Inherits:
-
Prawn::Document
- Object
- Prawn::Document
- Elegant::Document
- Defined in:
- lib/elegant/document.rb
Overview
A wrapper around Prawn::Document that enforces an elegant layout, setting nice dimensions and margins so that each page can fit up to three sections of content properly aligned along the vertical axis.
Instance Method Summary collapse
-
#header_height ⇒ Object
Determines the total height occupied by the header.
-
#initialize(options = {}, &block) ⇒ Document
constructor
Creates a new Elegant Document.
-
#title(text, options = {}) ⇒ Object
An additional method provided by Elegant::Document to render a title with an elegant font and padding above and below.
Constructor Details
#initialize(options = {}, &block) ⇒ Document
Creates a new Elegant Document. available, plus the following extra options.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/elegant/document.rb', line 22 def initialize( = {}, &block) = .dup @header = Header.new self, .delete(:header) {{}} @footer = Footer.new self, .delete(:footer) {{}} super(with_elegant ) do Typography.new(self).set_fonts @header.render if block block.arity < 1 ? instance_eval(&block) : block[self] end @footer.render end end |
Instance Method Details
#header_height ⇒ Object
Determines the total height occupied by the header
53 54 55 |
# File 'lib/elegant/document.rb', line 53 def header_height 50 end |
#title(text, options = {}) ⇒ Object
An additional method provided by Elegant::Document to render a title with an elegant font and padding above and below.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/elegant/document.rb', line 41 def title(text, = {}) move_down 10 width = bounds.width - @header.title_padding title = .merge text: text.upcase, color: '556270', size: 14 = {width: width, height: 30, at: [0, cursor]} formatted_text_box [title], move_down 30 end |