class DataAnon::Strategy::Field::RandomEmail
Generates email randomly using the given HOSTNAME and TLD. By defaults generates hostname randomly along with email id.
!!!ruby anonymize('Email').using FieldStrategy::RandomEmail.new('thoughtworks','com')
Constants
- TLDS
Public Class Methods
new(hostname = nil, tld = nil)
click to toggle source
# File lib/strategy/field/email/random_email.rb, line 17 def initialize hostname = nil, tld = nil @hostname = hostname @tld = tld end
Public Instance Methods
anonymize(field)
click to toggle source
# File lib/strategy/field/email/random_email.rb, line 22 def anonymize field username_length = DataAnon::Utils::RandomInt.generate(5,15) host_name_length = DataAnon::Utils::RandomInt.generate(2,10) username = DataAnon::Utils::RandomString.generate(username_length) hostname = @hostname || DataAnon::Utils::RandomString.generate(host_name_length) tld = @tld || TLDS[rand(TLDS.length)] return username + "@" + hostname + "." + tld end