Method: StringNumericHelper#get_float

Defined in:
lib/rubyhelper/string_numeric.rb

#get_float(sign = true) ⇒ String

get every digits and + - . , symbols in the string you can also see #to_fi to turn the String into a Float see als #get_1float #get_floats and #get_int

Parameters:

  • sign (true or false or :less) (defaults to: true)

    if true, keep the - and + signs, if :less, only keep -

Returns:



98
99
100
101
102
# File 'lib/rubyhelper/string_numeric.rb', line 98

def get_float(sign = true)
  return self.gsub(/[^\-\+\d\.\,]/, '') if sign == true
  return self.gsub(/[^\-\d\.\,]/, '') if sign == :less
  return self.gsub(/[^\d\.\,]/, '')
end