Class: Mascherari::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/mascherari/formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Formatter

Returns a new instance of Formatter.



3
4
5
6
# File 'lib/mascherari/formatter.rb', line 3

def initialize(options = {})
  @format_list = Array(options.fetch :format)
  @wildcard = options.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