Class: Walk
- Inherits:
-
Object
- Object
- Walk
- Defined in:
- lib/dnode/walk.rb
Instance Method Summary collapse
- #clone(obj) ⇒ Object
-
#initialize(obj) ⇒ Walk
constructor
A new instance of Walk.
- #walk(&block) ⇒ Object
Constructor Details
#initialize(obj) ⇒ Walk
Returns a new instance of Walk.
2 3 4 5 |
# File 'lib/dnode/walk.rb', line 2 def initialize obj @path = [] @object = obj end |
Instance Method Details
#clone(obj) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dnode/walk.rb', line 7 def clone obj _walk(obj, proc do |node| unless @object.is_a? Array or @object.is_a? Hash then node.value = node.value.clone end end) end |
#walk(&block) ⇒ Object
15 16 17 |
# File 'lib/dnode/walk.rb', line 15 def walk &block _walk(clone(@object), block) end |