Sha256: e5a7101e7ed90a2dfdb61c0c543f5cf57856a15154a1acf4a2f57dc3c644dc13
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
# frozen_string_literal: true require_relative 'file_handler' require_relative 'file_order' module OrganizeFiles # organizer.rb class Organizer attr_reader :directory def initialize(directory) @directory = directory @file_handler = FileHandler.new(directory) end def organize @file_handler.scan_files.each do |file| next if file_directory?(file) categorize_file = OrganizeFiles::FileOrder.new(file).categorize @file_handler.move_file(file, categorize_file) @file_handler.remove_empty_folders end end private def file_directory?(file) directory = [] expanded_file_path = File.expand_path(file, @directory) File.directory?(expanded_file_path) && directory << expanded_file_path !directory.empty? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
organize_files-1.0.8 | lib/organize_files/organizer.rb |