Class: Mascherari::Formatter
- Inherits:
-
Object
- Object
- Mascherari::Formatter
- Defined in:
- lib/mascherari/formatter.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Formatter
constructor
A new instance of Formatter.
- #mask(raw_value) ⇒ Object
- #unmask(raw_value) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Formatter
Returns a new instance of Formatter.
3 4 5 6 |
# File 'lib/mascherari/formatter.rb', line 3 def initialize( = {}) @format_list = Array(.fetch :format) @wildcard = .fetch :wildcard, "#" end |
Instance Method Details
#mask(raw_value) ⇒ Object
8 9 10 11 12 |
# File 'lib/mascherari/formatter.rb', line 8 def mask(raw_value) prepare_value raw_value formatted? ? value : add_mask end |
#unmask(raw_value) ⇒ Object
14 15 16 17 18 |
# File 'lib/mascherari/formatter.rb', line 14 def unmask(raw_value) prepare_value raw_value formatted? ? remove_mask : value end |