Class: Wizport::Rtf::Document
- Defined in:
- lib/wizport/document/rtf/document.rb
Instance Method Summary collapse
- #image(file) ⇒ Object
-
#initialize(file = nil, &block) ⇒ Document
constructor
A new instance of Document.
- #line_break ⇒ Object
-
#page_break ⇒ Object
writes a page interruption (new page).
- #save(file) ⇒ Object
-
#table(rows = [], options = {}, &block) ⇒ Object
creates a new table.
- #text(str, styles = {:align => :left}) ⇒ Object
- #to_doc ⇒ Object
- #to_s ⇒ Object
Methods inherited from Element
#cmd, #delimit, #group, #txt, #write
Constructor Details
#initialize(file = nil, &block) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wizport/document/rtf/document.rb', line 10 def initialize(file = nil, &block) super group do cmd :rtf, 1 cmd :ansi cmd :ansicpg, 2052 cmd :deff, 0 group do cmd :fonttbl group do delimit do cmd :f, 0 cmd :fcharset, 0 write " Courier" end end end group do cmd :colortbl delimit delimit do cmd :red, 0 cmd :green, 0 cmd :blue, 0 end delimit do cmd :red, 255 cmd :green, 0 cmd :blue,0 end end block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given? end save file if file end |
Instance Method Details
#image(file) ⇒ Object
55 56 57 |
# File 'lib/wizport/document/rtf/document.rb', line 55 def image(file) Wizport::Rtf::Image.new(self, file) end |
#line_break ⇒ Object
59 60 61 |
# File 'lib/wizport/document/rtf/document.rb', line 59 def line_break cmd :par end |
#page_break ⇒ Object
writes a page interruption (new page)
64 65 66 |
# File 'lib/wizport/document/rtf/document.rb', line 64 def page_break cmd :page end |
#save(file) ⇒ Object
77 78 79 |
# File 'lib/wizport/document/rtf/document.rb', line 77 def save(file) File.open(file, 'w') { |file| file.write(to_doc) } end |
#table(rows = [], options = {}, &block) ⇒ Object
creates a new table.
51 52 53 |
# File 'lib/wizport/document/rtf/document.rb', line 51 def table(rows = [], = {}, &block) Wizport::Rtf::Table.new(self, rows, , &block) end |
#text(str, styles = {:align => :left}) ⇒ Object
46 47 48 |
# File 'lib/wizport/document/rtf/document.rb', line 46 def text(str, styles = {:align => :left}) Wizport::Rtf::Text.new(self, str, styles) end |
#to_doc ⇒ Object
73 74 75 |
# File 'lib/wizport/document/rtf/document.rb', line 73 def to_doc @rtf.string end |
#to_s ⇒ Object
69 70 71 |
# File 'lib/wizport/document/rtf/document.rb', line 69 def to_s end |