Method: Visor::Common::Util#parse_value

Defined in:
lib/common/util.rb

#parse_value(string) ⇒ Object

Find if a string value is an integer, a float or a date. If it matches a type, then it is converted to that type and returned.

Parameters:

  • string (String)

    The string to be parsed.

Returns:

  • (Object)

    The already converted string value.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/common/util.rb', line 50

def parse_value(string)
  if is_integer?(string) then
    Integer(string)
  elsif is_float?(string) then
    Float(object)
  elsif is_date?(string) then
    Time.parse(string)
  else
    string
  end
end