Class: DataAnon::Strategy::Field::RandomUserName

Inherits:
Object
  • Object
show all
Defined in:
lib/strategy/field/name/random_user_name.rb

Overview

Generates random user name of same length as original user name.

anonymize('Username').using FieldStrategy::RandomUserName.new

Constant Summary collapse

DEFAULT_MIN_LENGTH =
5
DEFAULT_MAX_LENGTH =
10

Instance Method Summary collapse

Constructor Details

#initialize(min_length = DEFAULT_MIN_LENGTH, max_length = DEFAULT_MAX_LENGTH) ⇒ RandomUserName

Returns a new instance of RandomUserName.


15
16
17
18
# File 'lib/strategy/field/name/random_user_name.rb', line 15

def initialize min_length = DEFAULT_MIN_LENGTH, max_length = DEFAULT_MAX_LENGTH
  @min_length = min_length
  @max_length = max_length
end

Instance Method Details

#anonymize(field) ⇒ Object


20
21
22
23
24
# File 'lib/strategy/field/name/random_user_name.rb', line 20

def anonymize field
  username_length = DataAnon::Utils::RandomInt.generate(@min_length,@max_length)
  return DataAnon::Utils::RandomString.generate(username_length)

end