Module: Nrename::Utils

Defined in:
lib/nrename/utils.rb

Class Method Summary collapse

Class Method Details

.all_subdirs_of(dir) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/nrename/utils.rb', line 5

def all_subdirs_of(dir)
  children = []

  each_subdir(dir) do |subdir|
    children << subdir
    children.concat all_subdirs_of subdir
  end

  children
end

.each_subdir(dir, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/nrename/utils.rb', line 17

def each_subdir(dir, &block)
  dir = Pathname.new dir

  subdirs = dir.children.select &:directory?

  subdirs.each do |subdir|
    block.call subdir.to_s
  end
end