Class: Prawn::Text::Box
- Inherits:
-
Formatted::Box
- Object
- Formatted::Box
- Prawn::Text::Box
- Defined in:
- lib/prawn/text/box.rb
Overview
Experimental API collapse
-
#initialize(string, options = {}) ⇒ Box
constructor
A new instance of Box.
-
#render(flags = {}) ⇒ String
Render text to the document based on the settings defined in constructor.
Constructor Details
#initialize(string, options = {}) ⇒ Box
Returns a new instance of Box.
165 166 167 |
# File 'lib/prawn/text/box.rb', line 165 def initialize(string, = {}) super([{ text: string }], ) end |
Instance Method Details
#render(flags = {}) ⇒ String
Render text to the document based on the settings defined in constructor.
In order to facilitate look-ahead calculations, this method accepts a ‘dry_run: true` option. If provided, then everything is executed as if rendering, with the exception that nothing is drawn on the page. Useful for look-ahead computations of height, unprinted text, etc.
186 187 188 189 |
# File 'lib/prawn/text/box.rb', line 186 def render(flags = {}) leftover = super(flags) leftover.map { |hash| hash[:text] }.join end |