Class: Xmlish::Reconstructor
- Inherits:
-
Object
- Object
- Xmlish::Reconstructor
- Defined in:
- lib/xmlish.rb
Instance Method Summary collapse
-
#initialize(nodes, callbacks) ⇒ Reconstructor
constructor
A new instance of Reconstructor.
- #reconstruct(nodes = @nodes) ⇒ String
Constructor Details
#initialize(nodes, callbacks) ⇒ Reconstructor
Returns a new instance of Reconstructor.
112 113 114 115 |
# File 'lib/xmlish.rb', line 112 def initialize nodes, callbacks @nodes = nodes @callbacks = callbacks end |
Instance Method Details
#reconstruct(nodes = @nodes) ⇒ String
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/xmlish.rb', line 118 def reconstruct nodes=@nodes nodes.collect do |node| if Node === node callback = callback_for_tag node.attr_name if callback callback.call(reconstruct node.nodes) else reconstruct node.nodes end else callback = callback_for_tag 'text' if callback callback.call(node) else node end end end.join('') end |