Class: NauktisUtils::Duplicate::HandlingStrategy::OriginalFrom
- Inherits:
-
KeepOne
- Object
- BaseHandlingStrategy
- KeepOne
- NauktisUtils::Duplicate::HandlingStrategy::OriginalFrom
- Defined in:
- lib/nauktis_utils/duplicate.rb
Instance Attribute Summary
Attributes inherited from BaseHandlingStrategy
Instance Method Summary collapse
- #handle(files) ⇒ Object
-
#initialize(deleting_strategy, directory) ⇒ OriginalFrom
constructor
A new instance of OriginalFrom.
Constructor Details
#initialize(deleting_strategy, directory) ⇒ OriginalFrom
Returns a new instance of OriginalFrom.
41 42 43 44 |
# File 'lib/nauktis_utils/duplicate.rb', line 41 def initialize(deleting_strategy, directory) super(deleting_strategy) @directory = File.(directory) end |
Instance Method Details
#handle(files) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nauktis_utils/duplicate.rb', line 46 def handle(files) files = files.sort i = files.find_index do |f| f.start_with?(@directory) end unless i.nil? file_kept = files.delete_at(i) files.each do |duplicate| @deleting_strategy.delete_duplicate(duplicate, file_kept) end end end |