Class: Arrolio::Output::Page
- Inherits:
-
Object
- Object
- Arrolio::Output::Page
- Defined in:
- lib/arrolio/output/page.rb
Instance Attribute Summary collapse
-
#footer_align ⇒ Object
readonly
Returns the value of attribute footer_align.
-
#footer_text ⇒ Object
readonly
Returns the value of attribute footer_text.
-
#footnotes ⇒ Object
readonly
Returns the value of attribute footnotes.
-
#header_align ⇒ Object
readonly
Returns the value of attribute header_align.
-
#header_text ⇒ Object
readonly
Returns the value of attribute header_text.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#regions ⇒ Object
readonly
Returns the value of attribute regions.
-
#static_regions ⇒ Object
readonly
Returns the value of attribute static_regions.
-
#template_name ⇒ Object
readonly
Returns the value of attribute template_name.
-
#template_role ⇒ Object
readonly
Returns the value of attribute template_role.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #body_region ⇒ Object
- #each_box(&block) ⇒ Object
- #hash ⇒ Object
- #height ⇒ Object
-
#initialize(number:, template_name:, page_size:, regions:, static_regions: {}, template_role: :body, header_text: nil, footer_text: nil, header_align: :right, footer_align: :center, footnotes: []) ⇒ Page
constructor
A new instance of Page.
- #width ⇒ Object
Constructor Details
#initialize(number:, template_name:, page_size:, regions:, static_regions: {}, template_role: :body, header_text: nil, footer_text: nil, header_align: :right, footer_align: :center, footnotes: []) ⇒ Page
Returns a new instance of Page.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/arrolio/output/page.rb', line 10 def initialize(number:, template_name:, page_size:, regions:, static_regions: {}, template_role: :body, header_text: nil, footer_text: nil, header_align: :right, footer_align: :center, footnotes: []) @number = number.to_i @template_name = template_name.to_sym @template_role = template_role.to_sym @page_size = [page_size[0].to_f, page_size[1].to_f].freeze @regions = regions.transform_keys(&:to_sym).freeze @static_regions = static_regions.transform_keys(&:to_sym).freeze @header_text = header_text @footer_text = @header_align = header_align.to_sym @footer_align = .to_sym @footnotes = Array(footnotes).freeze freeze end |
Instance Attribute Details
#footer_align ⇒ Object (readonly)
Returns the value of attribute footer_align.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def @footer_align end |
#footer_text ⇒ Object (readonly)
Returns the value of attribute footer_text.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def @footer_text end |
#footnotes ⇒ Object (readonly)
Returns the value of attribute footnotes.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def footnotes @footnotes end |
#header_align ⇒ Object (readonly)
Returns the value of attribute header_align.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def header_align @header_align end |
#header_text ⇒ Object (readonly)
Returns the value of attribute header_text.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def header_text @header_text end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def number @number end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def page_size @page_size end |
#regions ⇒ Object (readonly)
Returns the value of attribute regions.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def regions @regions end |
#static_regions ⇒ Object (readonly)
Returns the value of attribute static_regions.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def static_regions @static_regions end |
#template_name ⇒ Object (readonly)
Returns the value of attribute template_name.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def template_name @template_name end |
#template_role ⇒ Object (readonly)
Returns the value of attribute template_role.
6 7 8 |
# File 'lib/arrolio/output/page.rb', line 6 def template_role @template_role end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/arrolio/output/page.rb', line 48 def ==(other) other.is_a?(self.class) && number == other.number && template_name == other.template_name && template_role == other.template_role && page_size == other.page_size && regions == other.regions && static_regions == other.static_regions && header_text == other.header_text && == other. && footnotes == other.footnotes end |
#body_region ⇒ Object
29 30 31 |
# File 'lib/arrolio/output/page.rb', line 29 def body_region @regions[:body] end |
#each_box(&block) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/arrolio/output/page.rb', line 41 def each_box(&block) return enum_for(:each_box) unless block_given? @static_regions.each_value { |r| r.placed_boxes.each(&block) } @regions.each_value { |r| r.placed_boxes.each(&block) } end |
#hash ⇒ Object
63 64 65 66 |
# File 'lib/arrolio/output/page.rb', line 63 def hash [self.class, number, template_name, template_role, page_size, regions, static_regions, header_text, , footnotes].hash end |
#height ⇒ Object
37 38 39 |
# File 'lib/arrolio/output/page.rb', line 37 def height @page_size[1] end |
#width ⇒ Object
33 34 35 |
# File 'lib/arrolio/output/page.rb', line 33 def width @page_size[0] end |