Module: Normalizy::Filters::Percent
- Defined in:
- lib/normalizy/filters/percent.rb
Class Method Summary collapse
Class Method Details
.call(input, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/normalizy/filters/percent.rb', line 7 def call(input, = {}) return input unless input.is_a?(String) value = input.gsub(/[^[0-9]#{separator()}]/, '') return nil if value.blank? if cents?() value = precisioned(value, ).delete('.') if value.include? separator() else value = precisioned(value, ) end return value.send([:cast]) if [:cast] value end |