Class: LIVR::Rules::Modifiers::Remove

Inherits:
LIVR::Rule
  • Object
show all
Defined in:
lib/livr/rules/modifiers.rb

Instance Method Summary collapse

Constructor Details

#initialize(chars) ⇒ Remove

Returns a new instance of Remove.


42
43
44
45
# File 'lib/livr/rules/modifiers.rb', line 42

def initialize(chars)
  @chars = chars
  @re = Regexp.compile("[#{Regexp.quote(@chars)}]")
end

Instance Method Details

#call(value, user_data, field_results) ⇒ Object


47
48
49
50
51
# File 'lib/livr/rules/modifiers.rb', line 47

def call(value, user_data, field_results)
  return if is_no_value(value) || value.is_a?(Hash)
  field_results << value.to_s.gsub(@re, '')
  return
end