Class: Prawn::Text::Box

Inherits:
Formatted::Box show all
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

Instance Method Summary collapse

Methods inherited from Formatted::Box

#available_width, #draw_fragment, #everything_printed?, extensions, #height, inherited, #line_gap, #nothing_printed?, #valid_options

Methods included from Core::Text::Formatted::Wrap

#wrap

Constructor Details

#initialize(string, options = {}) ⇒ Box

Returns a new instance of Box.



129
130
131
# File 'lib/prawn/text/box.rb', line 129

def initialize(string, options={})
  super([{ :text => string }], options)
end

Instance Method Details

#render(flags = {}) ⇒ Object



133
134
135
136
# File 'lib/prawn/text/box.rb', line 133

def render(flags={})
  leftover = super(flags)
  leftover.collect { |hash| hash[:text] }.join
end