Method: String#to_time_lex

Defined in:
lib/ferret/number_tools.rb

#to_time_lexObject

Convert a string to a Time. This method will only work on strings that match the format %Y%m%d %H%M%S, otherwise the result will be unpredictable.



126
127
128
129
130
# File 'lib/ferret/number_tools.rb', line 126

def to_time_lex
  vals = []
  self.gsub(/(?:^|[- :])(\d+)/) {vals << $1.to_i; $&}
  Time.mktime(*vals)
end