Class: AbsoluteRenamer::InteractivePlugin

Inherits:
IPlugin show all
Defined in:
lib/absolute_renamer/external/plugins/interactive/plugin.rb

Instance Method Summary collapse

Methods inherited from IPlugin

symbol

Methods inherited from WithChildren

inherited

Methods included from UseConfig

#conf

Instance Method Details

#before_batch_renamingObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/absolute_renamer/external/plugins/interactive/plugin.rb', line 3

def before_batch_renaming
    if conf[:options][:interactive] == :once
        conf[:files].each do |file|
            file.display_change
        end
        print "Do you want to rename this files ? [y/N] "
        begin
            resp = STDIN.readline.chomp.downcase
        rescue Exception => e
            puts "\nExiting renamer"
            exit(0)
        end
        return resp == "y"
    end
    true
end

#before_file_renaming(params) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/absolute_renamer/external/plugins/interactive/plugin.rb', line 20

def before_file_renaming(params)
    if conf[:options][:interactive] == :always
        params[:file].display_change
        print "Do you want to rename this file ? [y/N] "
        begin
            resp = STDIN.readline.chomp.downcase
        rescue Exception => e
            puts "\nExiting renamer"
            exit(0)
        end
        return resp == "y"
    end
    true
end