Class: Wee::HtmlDocument
- Inherits:
-
HtmlWriter
- Object
- HtmlWriter
- Wee::HtmlDocument
- Defined in:
- lib/wee/html_document.rb
Overview
Represents a complete HTML document.
Constant Summary
Constants inherited from HtmlWriter
Wee::HtmlWriter::CLOSING, Wee::HtmlWriter::SINGLE_CLOSING
Instance Attribute Summary
Attributes inherited from HtmlWriter
Instance Method Summary collapse
- #divert(tag, txt = nil, &block) ⇒ Object
-
#initialize ⇒ HtmlDocument
constructor
A new instance of HtmlDocument.
- #set ⇒ Object
- #to_s ⇒ Object
Methods inherited from HtmlWriter
#encode_text, #end_tag, #single_tag, #start_tag, #text, #write
Constructor Details
#initialize ⇒ HtmlDocument
Returns a new instance of HtmlDocument.
9 10 11 |
# File 'lib/wee/html_document.rb', line 9 def initialize super([]) end |
Instance Method Details
#divert(tag, txt = nil, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wee/html_document.rb', line 17 def divert(tag, txt=nil, &block) raise ArgumentError if txt and block @divert ||= {} unless divert = @divert[tag] @divert[tag] = divert = [] @port << divert end if txt divert << txt end if block old_port = @port begin @port = divert block.call ensure @port = old_port end end end |
#set ⇒ Object
13 14 15 |
# File 'lib/wee/html_document.rb', line 13 def set @set ||= {} end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/wee/html_document.rb', line 41 def to_s @port.join end |