class Hizuke::Parser

Main parser class for the Hizuke library

def self.parse(text)

Returns:
  • (Hizuke::Result) - the parsing result with clean text and date

Parameters:
  • text (String) -- the text to parse
def self.parse(text)
  new.parse(text)
end

def self.parse_with_result(text)

Returns:
  • (Hizuke::Result) - the parsing result with clean text and date

Parameters:
  • text (String) -- the text to parse
def self.parse_with_result(text)
  new.parse_with_result(text)
end

def parse(text)

Returns:
  • (Hizuke::Result) - the parsing result with clean text and date

Parameters:
  • text (String) -- the text to parse
def parse(text)
  raise ParseError, 'Cannot parse nil input' if text.nil?
  raise ParseError, 'Cannot parse empty input' if text.empty?
  parse_with_result(text)
end

def parse_with_result(text)

Returns:
  • (Hizuke::Result) - the parsing result with clean text and date

Parameters:
  • text (String) -- the text to parse
def parse_with_result(text)
  raise ParseError, 'Cannot parse nil input' if text.nil?
  raise ParseError, 'Cannot parse empty input' if text.empty?
  # First we'll try to find a date
  result = try_parsing_strategies(text)
  if result
    # If we found a date, extract time references
    time, clean_text = extract_time_references(result.clean_text)
    Result.new(clean_text, result.date, time)
  else
    # If we didn't find a date, extract only time references
    time, clean_text = extract_time_references(text)
    Result.new(clean_text, nil, time)
  end
end