Class: Xmlish::Walker
- Inherits:
-
Object
- Object
- Xmlish::Walker
- Defined in:
- lib/xmlish.rb
Instance Method Summary collapse
-
#initialize(nodes, callbacks) ⇒ Walker
constructor
A new instance of Walker.
- #walk(nodes = @nodes) ⇒ String
Constructor Details
#initialize(nodes, callbacks) ⇒ Walker
Returns a new instance of Walker.
157 158 159 160 |
# File 'lib/xmlish.rb', line 157 def initialize nodes, callbacks @nodes = nodes @callbacks = callbacks end |
Instance Method Details
#walk(nodes = @nodes) ⇒ String
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/xmlish.rb', line 163 def walk nodes=@nodes nodes.collect do |node| if Node === node callback = callback_for_tag node.attr_name if callback callback.call(Proc.new{walk node.nodes}) else walk node.nodes end else callback = callback_for_tag 'text' if callback callback.call(Proc.new{node}) else node end end end.join('') end |