Class: Undies::RootNode
- Inherits:
-
Object
- Object
- Undies::RootNode
- Defined in:
- lib/undies/root_node.rb
Instance Attribute Summary collapse
-
#cached ⇒ Object
readonly
RootNode is specifically used to handle root document markup.
-
#io ⇒ Object
readonly
RootNode is specifically used to handle root document markup.
Instance Method Summary collapse
- #attrs(*args) ⇒ Object
- #element_node(element_node) ⇒ Object
- #flush ⇒ Object
-
#initialize(io) ⇒ RootNode
constructor
A new instance of RootNode.
- #partial(partial) ⇒ Object
- #pop ⇒ Object
- #push ⇒ Object
- #text(raw) ⇒ Object
Constructor Details
#initialize(io) ⇒ RootNode
Returns a new instance of RootNode.
17 18 19 20 |
# File 'lib/undies/root_node.rb', line 17 def initialize(io) @io = io @cached = nil end |
Instance Attribute Details
#cached ⇒ Object (readonly)
RootNode is specifically used to handle root document markup.
15 16 17 |
# File 'lib/undies/root_node.rb', line 15 def cached @cached end |
#io ⇒ Object (readonly)
RootNode is specifically used to handle root document markup.
15 16 17 |
# File 'lib/undies/root_node.rb', line 15 def io @io end |
Instance Method Details
#attrs(*args) ⇒ Object
22 23 24 |
# File 'lib/undies/root_node.rb', line 22 def attrs(*args) raise RootAPIError, "can't call '__attrs' at the root node level" end |
#element_node(element_node) ⇒ Object
31 32 33 34 |
# File 'lib/undies/root_node.rb', line 31 def element_node(element_node) write_cached @cached = element_node end |
#flush ⇒ Object
40 41 42 43 44 |
# File 'lib/undies/root_node.rb', line 40 def flush write_cached @cached = nil self end |
#partial(partial) ⇒ Object
36 37 38 |
# File 'lib/undies/root_node.rb', line 36 def partial(partial) text(partial) end |
#pop ⇒ Object
51 52 53 |
# File 'lib/undies/root_node.rb', line 51 def pop flush end |
#push ⇒ Object
46 47 48 49 |
# File 'lib/undies/root_node.rb', line 46 def push @io.push(@cached) @cached = nil end |
#text(raw) ⇒ Object
26 27 28 29 |
# File 'lib/undies/root_node.rb', line 26 def text(raw) write_cached @cached = "#{@io.line_indent}#{raw.to_s}#{@io.newline}" end |