Class: Wizport::Rtf::Document
- Defined in:
- lib/wizport/document/rtf/document.rb
Instance Method Summary collapse
-
#initialize(file = nil, &block) ⇒ Document
constructor
A new instance of Document.
- #line_break ⇒ Object
- #page_break ⇒ Object
- #save(file) ⇒ Object
- #table(rows = [], options = {}, &block) ⇒ Object
- #text(str, styles = {:align => :left}) ⇒ Object
- #to_doc ⇒ Object
- #to_s ⇒ Object
- #write(txt) ⇒ Object
Methods inherited from Element
Constructor Details
#initialize(file = nil, &block) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wizport/document/rtf/document.rb', line 10 def initialize(file = nil, &block) @rtf = StringIO.new group do cmd :rtf, 1 cmd :ansi cmd :ansicpg, 2052 block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given? end save file if file end |
Instance Method Details
#line_break ⇒ Object
33 34 35 |
# File 'lib/wizport/document/rtf/document.rb', line 33 def line_break cmd :par end |
#page_break ⇒ Object
37 38 39 |
# File 'lib/wizport/document/rtf/document.rb', line 37 def page_break cmd :page end |
#save(file) ⇒ Object
50 51 52 |
# File 'lib/wizport/document/rtf/document.rb', line 50 def save(file) File.open(file, 'w') { |file| file.write(to_doc) } end |
#table(rows = [], options = {}, &block) ⇒ Object
29 30 31 |
# File 'lib/wizport/document/rtf/document.rb', line 29 def table(rows = [], = {}, &block) Wizport::Rtf::Table.new(self, rows, , &block) end |
#text(str, styles = {:align => :left}) ⇒ Object
25 26 27 |
# File 'lib/wizport/document/rtf/document.rb', line 25 def text(str, styles = {:align => :left}) Wizport::Rtf::Text.new(self, str, styles) end |
#to_doc ⇒ Object
46 47 48 |
# File 'lib/wizport/document/rtf/document.rb', line 46 def to_doc @rtf.string end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/wizport/document/rtf/document.rb', line 42 def to_s end |
#write(txt) ⇒ Object
21 22 23 |
# File 'lib/wizport/document/rtf/document.rb', line 21 def write(txt) @rtf << txt end |