Class: FileRenamer::PathProcessor
- Inherits:
-
Object
- Object
- FileRenamer::PathProcessor
- Defined in:
- lib/path_processor.rb
Instance Attribute Summary collapse
-
#counter ⇒ Object
Returns the value of attribute counter.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_alterer ⇒ Object
readonly
Returns the value of attribute name_alterer.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ PathProcessor
constructor
A new instance of PathProcessor.
- #rename_files! ⇒ Object
Constructor Details
#initialize(args) ⇒ PathProcessor
Returns a new instance of PathProcessor.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/path_processor.rb', line 21 def initialize(args) params = args[:corrected_params] || ParamsCorrector.new.corrected_params(args[:params]) @extension = params[:ext] @name = params[:name] @directory = params[:dir] @prefix = params[:prefix] @name_alterer = args.fetch(:name_alterer, NameAlterer.new) @paths = paths @counter = 0 end |
Instance Attribute Details
#counter ⇒ Object
Returns the value of attribute counter.
8 9 10 |
# File 'lib/path_processor.rb', line 8 def counter @counter end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
10 11 12 |
# File 'lib/path_processor.rb', line 10 def directory @directory end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
10 11 12 |
# File 'lib/path_processor.rb', line 10 def extension @extension end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/path_processor.rb', line 10 def name @name end |
#name_alterer ⇒ Object (readonly)
Returns the value of attribute name_alterer.
10 11 12 |
# File 'lib/path_processor.rb', line 10 def name_alterer @name_alterer end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/path_processor.rb', line 10 def prefix @prefix end |
Class Method Details
.run!(args = {}) ⇒ Object
17 18 19 |
# File 'lib/path_processor.rb', line 17 def self.run!(args = {}) self.new(args).rename_files! end |
Instance Method Details
#rename_files! ⇒ Object
34 35 36 37 38 |
# File 'lib/path_processor.rb', line 34 def rename_files! paths.each do |path| process_path(path) if should_be_renamed?(path) end end |