Class: TnPDF::PageSection
- Inherits:
-
Object
- Object
- TnPDF::PageSection
- Defined in:
- lib/tn_pdf/box.rb,
lib/tn_pdf/page_section.rb
Defined Under Namespace
Classes: Box
Instance Attribute Summary collapse
- #bottom ⇒ Object
-
#center ⇒ Object
Returns the value of attribute center.
-
#center_box ⇒ Object
readonly
Returns the value of attribute center_box.
-
#height ⇒ Object
Returns the value of attribute height.
-
#left ⇒ Object
Returns the value of attribute left.
-
#left_box ⇒ Object
readonly
Returns the value of attribute left_box.
-
#right ⇒ Object
Returns the value of attribute right.
-
#right_box ⇒ Object
readonly
Returns the value of attribute right_box.
- #top ⇒ Object
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
Instance Attribute Details
#bottom ⇒ Object
38 39 40 |
# File 'lib/tn_pdf/page_section.rb', line 38 def bottom @bottom ||= 0 end |
#center ⇒ Object
Returns the value of attribute center.
3 4 5 |
# File 'lib/tn_pdf/page_section.rb', line 3 def center @center end |
#center_box ⇒ Object (readonly)
Returns the value of attribute center_box.
4 5 6 |
# File 'lib/tn_pdf/page_section.rb', line 4 def center_box @center_box end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/tn_pdf/page_section.rb', line 6 def height @height end |
#left ⇒ Object
Returns the value of attribute left.
3 4 5 |
# File 'lib/tn_pdf/page_section.rb', line 3 def left @left end |
#left_box ⇒ Object (readonly)
Returns the value of attribute left_box.
4 5 6 |
# File 'lib/tn_pdf/page_section.rb', line 4 def left_box @left_box end |
#right ⇒ Object
Returns the value of attribute right.
3 4 5 |
# File 'lib/tn_pdf/page_section.rb', line 3 def right @right end |
#right_box ⇒ Object (readonly)
Returns the value of attribute right_box.
4 5 6 |
# File 'lib/tn_pdf/page_section.rb', line 4 def right_box @right_box end |
#top ⇒ Object
34 35 36 |
# File 'lib/tn_pdf/page_section.rb', line 34 def top @top ||= 0 end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/tn_pdf/page_section.rb', line 6 def width @width end |
Instance Method Details
#boxes ⇒ Object
30 31 32 |
# File 'lib/tn_pdf/page_section.rb', line 30 def boxes [left_box, center_box, right_box] end |
#render(document, position) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tn_pdf/page_section.rb', line 42 def render(document, position) width ||= document.bounds.width box_width = width/(boxes.compact.count) boxes.each do |box| box.width ||= box_width end boxes_with_positions = [ boxes, [position[0], (width-boxes[1].width)/2, width-boxes[2].width], [position[1]-top]*3 ].transpose boxes_with_positions.each do |box, x_pos, y_pos| box.render(document, [x_pos, y_pos], height ) end end |
#total_height ⇒ Object
26 27 28 |
# File 'lib/tn_pdf/page_section.rb', line 26 def total_height height + top + bottom end |