Module: Cleaners::DigitsOnly
- Defined in:
- lib/data_cleansing/cleaners.rb
Overview
Remove Non-Digit Chars Returns nil if no digit characters present
Constant Summary collapse
- DIGITS =
Regexp.compile(/\D/)
Class Method Summary collapse
Class Method Details
.call(string) ⇒ Object
121 122 123 124 125 126 |
# File 'lib/data_cleansing/cleaners.rb', line 121 def self.call(string) return string unless string.is_a?(String) string.gsub!(DIGITS, '') string.length > 0 ? string : nil end |