Method: Minute#parse_string

Defined in:
lib/minute.rb

#parse_string(text) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/minute.rb', line 60

def parse_string(text)
  patterns.keys.each do |pattern|
    begin
      if pattern.is_a?(Regexp) && text =~ pattern
        @now = patterns[pattern].call(current_time, Regexp.last_match)
      elsif pattern.is_a?(String) && text.include?(pattern)
        @now = patterns[pattern].call(current_time)
      end
    rescue
      @now
    end
  end
  @now
end