Class: FileRenamer
- Inherits:
-
Object
- Object
- FileRenamer
- Includes:
- Description
- Defined in:
- lib/android_file_sorter/file_renamer.rb
Instance Method Summary collapse
-
#initialize(current_directory) ⇒ FileRenamer
constructor
A new instance of FileRenamer.
- #process_files ⇒ Object
- #rename_files ⇒ Object
Methods included from Description
Constructor Details
#initialize(current_directory) ⇒ FileRenamer
Returns a new instance of FileRenamer.
4 5 6 7 8 9 |
# File 'lib/android_file_sorter/file_renamer.rb', line 4 def initialize(current_directory) @cwd = current_directory @user_files = Dir.entries(@cwd).select { |file| ![ ".", "..", ".DS_Store" ].include?(file) } @filesets = collect_filesets @file_dates = @filesets.keys end |
Instance Method Details
#process_files ⇒ Object
11 12 13 14 |
# File 'lib/android_file_sorter/file_renamer.rb', line 11 def process_files documentation rename_files end |
#rename_files ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/android_file_sorter/file_renamer.rb', line 16 def rename_files loop do date = @file_dates.first puts "Next file set: #{date}." print ">> " case gets.chomp when "l" @file_dates.shift when "a" @file_dates.shift automatic_renaming(date) when "d" documentation when "e" puts "Exiting program." exit when "r" @file_dates.shift puts "Enter a fileset name:" print ">> " user_filename = gets.chomp.gsub(/\s/, "_") user_renaming(date, user_filename) else puts "Enter one of the available options." end if @file_dates.empty? puts "All of your files are renamed." exit end end end |