Class: Arrolio::LayoutSpec::PageTemplate
- Inherits:
-
Object
- Object
- Arrolio::LayoutSpec::PageTemplate
- Defined in:
- lib/arrolio/layout_spec/page_template.rb
Overview
Page geometry template ("fo:simple-page-master" in XSL-FO).
Coordinates are PDF-default user space: origin at the
bottom-left of the page, y grows upward. Region y is the
bottom edge of the region.
Constant Summary collapse
- LETTER =
[612.0, 792.0].freeze
- A4 =
[595.276, 841.89].freeze
Instance Attribute Summary collapse
-
#margins ⇒ Object
readonly
Returns the value of attribute margins.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#region_extents ⇒ Object
readonly
Returns the value of attribute region_extents.
-
#regions ⇒ Object
readonly
Returns the value of attribute regions.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #body_region ⇒ Object
- #hash ⇒ Object
- #height ⇒ Object
-
#initialize(name:, page_size: LETTER, margins: 72, region_extents: {}) ⇒ PageTemplate
constructor
A new instance of PageTemplate.
- #region(name) ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(name:, page_size: LETTER, margins: 72, region_extents: {}) ⇒ PageTemplate
Returns a new instance of PageTemplate.
15 16 17 18 19 20 21 22 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 15 def initialize(name:, page_size: LETTER, margins: 72, region_extents: {}) @name = name.to_sym @page_size = resolve_page_size(page_size) @margins = normalise_margins(margins) @region_extents = default_region_extents.merge(region_extents.to_h) @regions = compute_regions.freeze freeze end |
Instance Attribute Details
#margins ⇒ Object (readonly)
Returns the value of attribute margins.
13 14 15 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 13 def margins @margins end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 13 def name @name end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
13 14 15 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 13 def page_size @page_size end |
#region_extents ⇒ Object (readonly)
Returns the value of attribute region_extents.
13 14 15 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 13 def region_extents @region_extents end |
#regions ⇒ Object (readonly)
Returns the value of attribute regions.
13 14 15 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 13 def regions @regions end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
40 41 42 43 44 45 46 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 40 def ==(other) other.is_a?(self.class) && name == other.name && page_size == other.page_size && margins == other.margins && region_extents == other.region_extents end |
#body_region ⇒ Object
24 25 26 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 24 def body_region @regions[:body] end |
#hash ⇒ Object
50 51 52 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 50 def hash [self.class, name, page_size, margins, region_extents].hash end |
#height ⇒ Object
36 37 38 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 36 def height @page_size[1] end |
#region(name) ⇒ Object
28 29 30 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 28 def region(name) @regions[name.to_sym] end |
#width ⇒ Object
32 33 34 |
# File 'lib/arrolio/layout_spec/page_template.rb', line 32 def width @page_size[0] end |