Class: PDFGen::Span
- Inherits:
-
BaseRegion
- Object
- BaseRegion
- PDFGen::Span
- Includes:
- CaptionContainer, Composite, DivContainer, ImageContainer, SpanContainer, TableContainer
- Defined in:
- lib/span.rb
Overview
Horizontal captions line
Instance Attribute Summary collapse
-
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
-
#vertical_interval ⇒ Object
Returns the value of attribute vertical_interval.
Attributes inherited from BaseRegion
Attributes included from BaseAttributes
#background_color, #border_bottom, #border_color, #border_left, #border_right, #border_style, #border_top, #border_width, #height, #is_breakable, #pad_bottom, #pad_left, #pad_right, #pad_top, #page_pad_top, #width
Instance Method Summary collapse
- #calculate_minimal_height ⇒ Object
-
#initialize(parent) ⇒ Span
constructor
A new instance of Span.
- #render(pos, av_height, test = false) ⇒ Object
-
#render_regions(x = 0, y = document.y, test = true) ⇒ Object
renders inner regions returns height of the region content.
Methods included from Composite
#[], #add_region, #apply_values, #elements, #page_pad_top=, #regions
Methods included from CaptionContainer
Methods included from ImageContainer
Methods included from SpanContainer
Methods included from DivContainer
Methods included from TableContainer
Methods inherited from BaseRegion
#check_fit_in_height, #document, #minimal_height, #set_properties, #value
Methods included from BaseAttributes
#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init
Methods included from BaseAttributes::ClassMethods
Constructor Details
#initialize(parent) ⇒ Span
Returns a new instance of Span.
18 19 20 21 22 23 |
# File 'lib/span.rb', line 18 def initialize(parent) super @vertical_interval = 0 @vertical_align = false end |
Instance Attribute Details
#vertical_align ⇒ Object
Returns the value of attribute vertical_align.
25 26 27 |
# File 'lib/span.rb', line 25 def vertical_align @vertical_align end |
#vertical_interval ⇒ Object
Returns the value of attribute vertical_interval.
25 26 27 |
# File 'lib/span.rb', line 25 def vertical_interval @vertical_interval end |
Instance Method Details
#calculate_minimal_height ⇒ Object
27 28 29 30 |
# File 'lib/span.rb', line 27 def calculate_minimal_height render_regions (regions.collect{|region| region.height}.max || 0) + pad_top + pad_bottom end |
#render(pos, av_height, test = false) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/span.rb', line 60 def render(pos, av_height, test=false) self.check_fit_in_height fill(pos) unless test add_border(pos) unless test super end |
#render_regions(x = 0, y = document.y, test = true) ⇒ Object
renders inner regions returns height of the region content
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/span.rb', line 34 def render_regions(x=0, y=document.y, test=true) content_width = pad_left last = regions.last regions.each do |region| if region.breakable? region.check_fit_in_height end if (content_width + region.width) > self.width regions[regions.index(region), regions.size].each do |item| regions.delete(item) end else if vertical_align && !test region.height = self.height - self.pad_top - self.pad_bottom end region.render([(x + content_width), (y - pad_top)], y-pad_top) unless test content_width += region.width content_width += vertical_interval unless region == last end end content_width + pad_right end |