Class: Gitlab::Utils::Email::Masker
- Inherits:
-
Object
- Object
- Gitlab::Utils::Email::Masker
- Defined in:
- lib/gitlab/utils/email.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#at ⇒ Object
readonly
Returns the value of attribute at.
-
#dot ⇒ Object
readonly
Returns the value of attribute dot.
-
#local_part ⇒ Object
readonly
Returns the value of attribute local_part.
-
#sub_domain ⇒ Object
readonly
Returns the value of attribute sub_domain.
-
#toplevel_domain ⇒ Object
readonly
Returns the value of attribute toplevel_domain.
Instance Method Summary collapse
-
#initialize(original) ⇒ Masker
constructor
A new instance of Masker.
- #masked ⇒ Object
Constructor Details
#initialize(original) ⇒ Masker
Returns a new instance of Masker.
20 21 22 23 24 25 26 27 |
# File 'lib/gitlab/utils/email.rb', line 20 def initialize(original) @original = original @local_part, @at, domain = original.rpartition('@') @sub_domain, @dot, @toplevel_domain = domain.rpartition('.') @at = nil if @at.empty? @dot = nil if @dot.empty? end |
Instance Attribute Details
#at ⇒ Object (readonly)
Returns the value of attribute at.
18 19 20 |
# File 'lib/gitlab/utils/email.rb', line 18 def at @at end |
#dot ⇒ Object (readonly)
Returns the value of attribute dot.
18 19 20 |
# File 'lib/gitlab/utils/email.rb', line 18 def dot @dot end |
#local_part ⇒ Object (readonly)
Returns the value of attribute local_part.
18 19 20 |
# File 'lib/gitlab/utils/email.rb', line 18 def local_part @local_part end |
#sub_domain ⇒ Object (readonly)
Returns the value of attribute sub_domain.
18 19 20 |
# File 'lib/gitlab/utils/email.rb', line 18 def sub_domain @sub_domain end |
#toplevel_domain ⇒ Object (readonly)
Returns the value of attribute toplevel_domain.
18 19 20 |
# File 'lib/gitlab/utils/email.rb', line 18 def toplevel_domain @toplevel_domain end |
Instance Method Details
#masked ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab/utils/email.rb', line 29 def masked masked = [ local_part, at, sub_domain, dot, toplevel_domain ].compact.join('') masked = mask(@original, visible_length: 1) if masked == @original masked end |