Class: Prawn::Document::Text::Box

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/document/text/box.rb

Overview

FIXME: requires documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

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,options={})
  @document  = options[:for]
  @text      = text
  @at        = options[:at] || [0, @document.y - @document.bounds.absolute_bottom]
  @width     = options[:width] || @document.bounds.width
  @height    = options[:height]
  @overflow  = options[:overflow] || :truncate
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



38
39
40
# File 'lib/prawn/document/text/box.rb', line 38

def height
  @height
end

#overflowObject (readonly)

Returns the value of attribute overflow.



38
39
40
# File 'lib/prawn/document/text/box.rb', line 38

def overflow
  @overflow
end

#textObject (readonly)

Returns the value of attribute text.



38
39
40
# File 'lib/prawn/document/text/box.rb', line 38

def text
  @text
end

#widthObject (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

#renderObject



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