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