Class: Pseudonymize::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/pseudonymize/email.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, **options) ⇒ Email

Returns a new instance of Email.



5
6
7
8
# File 'lib/pseudonymize/email.rb', line 5

def initialize(email, **options)
  @email   = email
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/pseudonymize/email.rb', line 3

def options
  @options
end

Instance Method Details

#resultObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pseudonymize/email.rb', line 10

def result
  user, host = @email.split('@')
  
  if user.length > 2
    user = user[0] + (options[:censor] * (user.length - 1))
  else
    user = (options[:censor] * user.length)
  end
  
  "#{user}@#{host}"
end