Class: Metacrunch::File::FileSource

Inherits:
Object
  • Object
show all
Defined in:
lib/metacrunch/file/file_source.rb

Direct Known Subclasses

Source

Instance Method Summary collapse

Constructor Details

#initialize(filenames) ⇒ FileSource

Returns a new instance of FileSource.



7
8
9
# File 'lib/metacrunch/file/file_source.rb', line 7

def initialize(filenames)
  @filenames = [*filenames].map{|f| f.presence}.compact
end

Instance Method Details

#each(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/metacrunch/file/file_source.rb', line 11

def each(&block)
  return enum_for(__method__) unless block_given?

  @filenames.each do |filename|
    if is_archive?(filename)
     read_archive(filename, &block)
    else
     read_regular_file(filename, &block)
    end
  end
end