Class: RGhost::Text
- Defined in:
- lib/rghost/text.rb
Overview
Wraps the text so as the it fits on the page(:area_x). Wrapping happens at whitespace characters without hyphenation. Additionally you can make use of predefined tag and the special tag <br/> to break row. You can disable the parse with second parameter tag_parse=false.
Examples
doc=Document.new
doc. do
tag :font1, :name => 'Helvetica', :size => 10, :color => '#F34811'
tag :font2, :name => 'Times', :size => 11, :color => '#A4297A'
tag :font3, :name => 'TimesBold', :size => 12, :color => '#AA3903'
end
my_text="<font1>foo, bar, baz</font1>,<font2>qux, quux</font2>, corge, grault, garply, waldo, <font3>fred, plugh,</font3> xyzzy,<br/> thud, bing"
doc.text my_text
Without parse
text="<font1>foo, bar, baz</font1>,<font2>qux, quux</font2>, corge, grault, garply, waldo, <font3>fred, plugh,</font3> xyzzy,<br/> thud, bing"
doc.text text,false
Constant Summary
Constants included from RubyToPs
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(text, tag_parse = true) ⇒ Text
constructor
A new instance of Text.
- #ps ⇒ Object
Methods included from ParseText
Methods included from RubyToPs
#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array
Methods inherited from PsObject
#<<, #call, #graphic_scope, #raw, #set, #to_s
Constructor Details
#initialize(text, tag_parse = true) ⇒ Text
29 30 31 32 33 34 |
# File 'lib/rghost/text.rb', line 29 def initialize(text,tag_parse=true) super("") @text=text @tag_parse=tag_parse ={:text_align => :left} end |
Instance Attribute Details
#rows ⇒ Object (readonly)
Returns the value of attribute rows
27 28 29 |
# File 'lib/rghost/text.rb', line 27 def rows @rows end |
Instance Method Details
#ps ⇒ Object
36 37 38 |
# File 'lib/rghost/text.rb', line 36 def ps text_to_ps #from RGhost::ParseText end |