Class: Prawn::Document::Text::Box
- Inherits:
-
Object
- Object
- Prawn::Document::Text::Box
- Defined in:
- lib/prawn/document/text/box.rb
Overview
FIXME: requires documentation
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#overflow ⇒ Object
readonly
Returns the value of attribute overflow.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ Box
constructor
:nodoc:.
- #render ⇒ Object
Constructor Details
#initialize(text, options = {}) ⇒ Box
:nodoc:
29 30 31 32 33 34 35 36 |
# File 'lib/prawn/document/text/box.rb', line 29 def initialize(text,={}) @document = [:for] @text = text @at = [:at] || [0, @document.y - @document.bounds.absolute_bottom] @width = [:width] || @document.bounds.width @height = [:height] @overflow = [:overflow] || :truncate end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
38 39 40 |
# File 'lib/prawn/document/text/box.rb', line 38 def height @height end |
#overflow ⇒ Object (readonly)
Returns the value of attribute overflow.
38 39 40 |
# File 'lib/prawn/document/text/box.rb', line 38 def overflow @overflow end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
38 39 40 |
# File 'lib/prawn/document/text/box.rb', line 38 def text @text end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
38 39 40 |
# File 'lib/prawn/document/text/box.rb', line 38 def width @width end |
Instance Method Details
#render ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/prawn/document/text/box.rb', line 40 def render x,y = @at if @overflow == :expand @text = naive_wrap_text else original_y = @document.y fit_text_to_box end @document.bounding_box([x,@document.bounds.top], :width => @width, :height => @document.bounds.height) do @document.y = @document.bounds.absolute_bottom + y @document.text @text end unless @overflow == :expand @document.y = y + @document.bounds.absolute_bottom - @height end @excess_text end |