Class: Prawn::Text::Box
- Inherits:
-
Formatted::Box
- Object
- Formatted::Box
- Prawn::Text::Box
- Defined in:
- lib/prawn/text/box.rb
Overview
Generally, one would use the Prawn::Text#text_box convenience method. However, using Text::Box.new in conjunction with #render(:dry_run=> true) enables one to do look-ahead calculations prior to placing text on the page, or to determine how much vertical space was consumed by the printed text
Instance Attribute Summary
Attributes inherited from Formatted::Box
#ascender, #at, #descender, #leading, #line_height, #text
Experimental API collapse
-
#initialize(string, options = {}) ⇒ Box
constructor
A new instance of Box.
- #render(flags = {}) ⇒ Object
Methods inherited from Formatted::Box
#available_width, #draw_fragment, #everything_printed?, extensions, #height, #line_gap, #nothing_printed?, #valid_options
Constructor Details
#initialize(string, options = {}) ⇒ Box
Returns a new instance of Box.
132 133 134 |
# File 'lib/prawn/text/box.rb', line 132 def initialize(string, = {}) super([{ text: string }], ) end |
Instance Method Details
#render(flags = {}) ⇒ Object
136 137 138 139 |
# File 'lib/prawn/text/box.rb', line 136 def render(flags = {}) leftover = super(flags) leftover.map { |hash| hash[:text] }.join end |