Class: Clarus::Document
- Inherits:
-
Object
- Object
- Clarus::Document
- Defined in:
- lib/clarus/document.rb
Instance Method Summary collapse
- #image(uri) ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #link(destination, text) ⇒ Object
- #new_heading {|heading| ... } ⇒ Object
- #new_paragraph {|paragraph| ... } ⇒ Object
- #paragraph_break ⇒ Object
- #stream_document ⇒ Object
- #write_document(path) ⇒ Object
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
3 4 5 6 |
# File 'lib/clarus/document.rb', line 3 def initialize @doc = create_document @items = [] end |
Instance Method Details
#image(uri) ⇒ Object
35 36 37 |
# File 'lib/clarus/document.rb', line 35 def image(uri) @items << Clarus::Image.new(uri) end |
#link(destination, text) ⇒ Object
20 21 22 |
# File 'lib/clarus/document.rb', line 20 def link(destination, text) @items << Clarus::Link.new(destination, text) end |
#new_heading {|heading| ... } ⇒ Object
14 15 16 17 18 |
# File 'lib/clarus/document.rb', line 14 def new_heading heading = Clarus::Heading.new yield(heading) @items << heading end |
#new_paragraph {|paragraph| ... } ⇒ Object
8 9 10 11 12 |
# File 'lib/clarus/document.rb', line 8 def new_paragraph paragraph = Clarus::Paragraph.new yield(paragraph) @items << paragraph end |
#paragraph_break ⇒ Object
31 32 33 |
# File 'lib/clarus/document.rb', line 31 def paragraph_break @items << Clarus::ParagraphBreak.new end |
#stream_document ⇒ Object
39 40 41 |
# File 'lib/clarus/document.rb', line 39 def stream_document @doc.result(:items => @items) end |
#write_document(path) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/clarus/document.rb', line 24 def write_document(path) File.open(path, "w") do |f| result = stream_document f.write(result) end end |