Class: Pseudonymize::Telephone
- Inherits:
-
Object
- Object
- Pseudonymize::Telephone
- Defined in:
- lib/pseudonymize/telephone.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(telephone, **options) ⇒ Telephone
constructor
A new instance of Telephone.
- #result ⇒ Object
Constructor Details
#initialize(telephone, **options) ⇒ Telephone
Returns a new instance of Telephone.
5 6 7 8 |
# File 'lib/pseudonymize/telephone.rb', line 5 def initialize(telephone, **) @telephone = telephone @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/pseudonymize/telephone.rb', line 3 def @options end |
Instance Method Details
#result ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pseudonymize/telephone.rb', line 10 def result characters = @telephone.chars unhidden = (characters.length / 2) last = (unhidden.to_f / 2).ceil first = unhidden - last [ characters[0..first], ([:censor] * (characters.length - first - last - 1)), characters[-last, last] ].flatten.join end |