class MediaArchiver::MediaFileUtils

Public Class Methods

new(path) click to toggle source
# File lib/media_archiver/media_file_utils.rb, line 3
def initialize(path)
  @path = path
end

Public Instance Methods

each(recursive) { |file| ... } click to toggle source
# File lib/media_archiver/media_file_utils.rb, line 7
def each(recursive)
  scan_path(recursive)
    .reject { |path| File.directory? path }
    .each_with_object([]) do |file_path, acc|
      file = MediaFile.new(file_path)

      if file.valid?
        yield(file)
        acc << file
      end
    end
end

Protected Instance Methods

scan_path(recursive) click to toggle source
# File lib/media_archiver/media_file_utils.rb, line 22
def scan_path(recursive)
  if recursive
    Dir.glob(File.join(@path, '**', '*'))
  else
    Dir.glob(File.join(@path, '*'))
  end
end