module OcrChallenge::BasicLandAndCellNumberParser

This module attempts to parse phone numbers which I w ill define as BOTH land lines and cell phone numbers. It will attempt to filter out fax numbers NOTE: This assumes the including class will have a ‘lines’ instance variable

Constants

FAX_REGEX

Public Instance Methods

parse_phone_numbers() click to toggle source
# File lib/ocr_challenge/basic_land_and_cell_number_parser.rb, line 9
def parse_phone_numbers
  matching_lines = get_matches

  phone_number_lines = matching_lines.reject do |line|
    is_fax_number?(line)
  end

  phone_number_lines.map do |line|
    format(line, '-')
  end.sort
end

Private Instance Methods

is_fax_number?(line) click to toggle source
# File lib/ocr_challenge/basic_land_and_cell_number_parser.rb, line 23
def is_fax_number?(line)
  line =~ FAX_REGEX
end