Class: FileRenamer::PathProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/path_processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#counterObject

Returns the value of attribute counter.



8
9
10
# File 'lib/path_processor.rb', line 8

def counter
  @counter
end

#directoryObject (readonly)

Returns the value of attribute directory.



10
11
12
# File 'lib/path_processor.rb', line 10

def directory
  @directory
end

#extensionObject (readonly)

Returns the value of attribute extension.



10
11
12
# File 'lib/path_processor.rb', line 10

def extension
  @extension
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/path_processor.rb', line 10

def name
  @name
end

#name_altererObject (readonly)

Returns the value of attribute name_alterer.



10
11
12
# File 'lib/path_processor.rb', line 10

def name_alterer
  @name_alterer
end

#prefixObject (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