Class: DumpCleaner::Cleanup::CleaningSteps::AddRepetitionSuffix

Inherits:
Base
  • Object
show all
Includes:
BytesizeHelpers
Defined in:
lib/dump_cleaner/cleanup/cleaning_steps/add_repetition_suffix.rb

Instance Attribute Summary

Attributes inherited from Base

#step_context

Instance Method Summary collapse

Methods included from BytesizeHelpers

#replace_suffix, #set_to_bytesize, #truncate_to_bytesize

Methods inherited from Base

#crc32, #initialize, #raise_params_error

Constructor Details

This class inherits a constructor from DumpCleaner::Cleanup::CleaningSteps::Base

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dump_cleaner/cleanup/cleaning_steps/add_repetition_suffix.rb', line 9

def run
  step_context.current_value = if repetition.zero?
                                 current_value
                               elsif current_value.bytesize > repetition.to_s.bytesize
                                 replace_suffix(current_value, suffix: repetition.to_s, padding: "0")
                               else
                                 GenerateRandomString.new(StepContext.new_from(step_context))
                                                     .run.current_value
                               end
  step_context
end