module Hizuke::DynamicPatternMatcher

def check_in_x_weeks_pattern(text)

Returns:
  • (Hizuke::Result, nil) - the result or nil if no match

Parameters:
  • text (String) -- the text to check
def check_in_x_weeks_pattern(text)
  if (match = text.match(IN_X_WEEKS_PATTERN))
    weeks = match[1].to_i
    date = Date.today + (weeks * 7)
    clean_text = text.gsub(match[0], '').strip
    return Result.new(clean_text, date)
  end
  nil
end