Method: ZK::Client::Unixisms#find

Defined in:
lib/zk/client/unixisms.rb

#find(*paths, &block) ⇒ Object

Acts in a similar way to ruby's Find class. Performs a depth-first traversal of every node under the given paths, and calls the given block with each path found. Like the ruby Find class, you can call Find.prune to avoid descending further into a given sub-tree

Examples:

list the paths under a given node


zk = ZK.new

paths = %w[
  /root
  /root/alpha
  /root/bravo
  /root/charlie
  /root/charlie/rose
  /root/charlie/manson
  /root/charlie/manson/family
  /root/charlie/manson/murders
  /root/charlie/brown
  /root/delta
  /root/delta/blues
  /root/delta/force
  /root/delta/burke
]

paths.each { |p| zk.create(p) }

zk.find('/root') do |path|
  puts path

  ZK::Find.prune if path == '/root/charlie/manson'
end

# this produces the output:

# /root
# /root/alpha
# /root/bravo
# /root/charlie
# /root/charlie/brown
# /root/charlie/manson
# /root/charlie/rose
# /root/delta
# /root/delta/blues
# /root/delta/burke
# /root/delta/force

Parameters:

  • paths (Array[String])

    a list of paths to recursively yield the sub-paths of

See Also:

  • Find#find


115
116
117
# File 'lib/zk/client/unixisms.rb', line 115

def find(*paths, &block)
  ZK::Find.find(self, *paths, &block)
end