Class: Ruumba::Iterators::DirectoryIterator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruumba/iterators.rb

Overview

Iterator which returns matching files from the given directory or file list

Instance Method Summary collapse

Constructor Details

#initialize(files_or_dirs, temp_dir) ⇒ DirectoryIterator

Returns a new instance of DirectoryIterator.



29
30
31
32
# File 'lib/ruumba/iterators.rb', line 29

def initialize(files_or_dirs, temp_dir)
  @files_or_dirs = files_or_dirs
  @temp_dir = temp_dir
end

Instance Method Details

#each(&block) ⇒ Object



34
35
36
37
38
# File 'lib/ruumba/iterators.rb', line 34

def each(&block)
  files.map do |file|
    [file, File.read(file)]
  end.each(&block)
end