Class: DataAnon::Strategy::Field::FormattedStringNumber
- Inherits:
-
Object
- Object
- DataAnon::Strategy::Field::FormattedStringNumber
- Defined in:
- lib/strategy/field/string/formatted_string_numbers.rb
Overview
Keeping the format same it changes each digit in the string with random digit.
anonymize('CreditCardNumber').using FieldStrategy::FormattedStringNumber.new
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#anonymize(field) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/strategy/field/string/formatted_string_numbers.rb', line 12 def anonymize field @original_string = field.value @anonymized_string = "" @original_string.each_char do |char| if /\d/.match(char).nil? @anonymized_string += char else @anonymized_string += DataAnon::Utils::RandomInt.generate(0,9).to_s end end @anonymized_string end |