Class: PDFGen::Caption
- Inherits:
-
BaseRegion
- Object
- BaseRegion
- PDFGen::Caption
- Defined in:
- lib/caption.rb
Instance Attribute Summary collapse
-
#bold ⇒ Object
readonly
Returns the value of attribute bold.
-
#font_size ⇒ Object
readonly
Returns the value of attribute font_size.
-
#justification ⇒ Object
readonly
Returns the value of attribute justification.
-
#text ⇒ Object
Returns the value of attribute text.
-
#text_color ⇒ Object
readonly
Returns the value of attribute text_color.
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) ⇒ Caption
constructor
A new instance of Caption.
-
#render(pos, av_height, test = false) ⇒ Object
renders specified text at the specified position returns real position that caption was generated on.
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) ⇒ Caption
Returns a new instance of Caption.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/caption.rb', line 8 def initialize(parent) super @text = "" @template = @text @justification = :left @bold = false @font_size = document.pdf.font_size self.paddings = 0.2.cm end |
Instance Attribute Details
#bold ⇒ Object (readonly)
Returns the value of attribute bold.
30 31 32 |
# File 'lib/caption.rb', line 30 def bold @bold end |
#font_size ⇒ Object (readonly)
Returns the value of attribute font_size.
30 31 32 |
# File 'lib/caption.rb', line 30 def font_size @font_size end |
#justification ⇒ Object (readonly)
Returns the value of attribute justification.
30 31 32 |
# File 'lib/caption.rb', line 30 def justification @justification end |
#text ⇒ Object
Returns the value of attribute text.
19 20 21 |
# File 'lib/caption.rb', line 19 def text @text end |
#text_color ⇒ Object (readonly)
Returns the value of attribute text_color.
30 31 32 |
# File 'lib/caption.rb', line 30 def text_color @text_color end |
Instance Method Details
#calculate_minimal_height ⇒ Object
34 35 36 |
# File 'lib/caption.rb', line 34 def calculate_minimal_height add_text_wrap end |
#render(pos, av_height, test = false) ⇒ Object
renders specified text at the specified position returns real position that caption was generated on
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/caption.rb', line 63 def render(pos, av_height, test=false) self.check_fit_in_height if av_height >= self.height super add_text_wrap(pos,test) used_height = [add_text_wrap(pos),self.height].max [used_height, true] else [0, false] end end |