Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/zenweb/extensions.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#deep_each(depth = 0, &b) ⇒ Object

:nodoc:



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/zenweb/extensions.rb', line 33

def deep_each(depth = 0, &b) # :nodoc:
  return self.to_enum(:deep_each) unless b

  each do |x|
    case x
    when Array then
      x.deep_each(depth + 1, &b)
    else
      # yield (depth-1)/2, x
      yield depth, x
    end
  end
end