Class: Cycromatic::FileEnumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/cycromatic/file_enumerator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths:) ⇒ FileEnumerator

Returns a new instance of FileEnumerator.



5
6
7
# File 'lib/cycromatic/file_enumerator.rb', line 5

def initialize(paths:)
  @paths = paths
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



3
4
5
# File 'lib/cycromatic/file_enumerator.rb', line 3

def paths
  @paths
end

Instance Method Details

#each(&block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cycromatic/file_enumerator.rb', line 9

def each(&block)
  if block_given?
    paths.each do |path|
      case
      when path.file?
        yield path
      when path.directory?
        enumerate_files_in_dir(path, &block)
      end
    end
  else
    self.enum_for :each
  end
end