Class: AtlasEngine::Si::ValidationTranscriber::AddressParser

Inherits:
ValidationTranscriber::AddressParserBase show all
Defined in:
app/countries/atlas_engine/si/validation_transcriber/address_parser.rb

Constant Summary collapse

STREET =

the .+ is non-greedy to allow for optional building number prefixes

"(?<street>.+?)"
BUILDING_NUM =
"(?<building_num>[0-9]+(\s?[[:alpha:]]*))"

Constants inherited from ValidationTranscriber::AddressParserBase

ValidationTranscriber::AddressParserBase::AddressComponents, ValidationTranscriber::AddressParserBase::BUILDING_NAME, ValidationTranscriber::AddressParserBase::NON_NUMERIC_STREET, ValidationTranscriber::AddressParserBase::NUMERIC_ONLY_BUILDING_NUM, ValidationTranscriber::AddressParserBase::PO_BOX, ValidationTranscriber::AddressParserBase::STREET_NO_COMMAS, ValidationTranscriber::AddressParserBase::UNIT_NUM, ValidationTranscriber::AddressParserBase::UNIT_NUM_NO_HYPHEN, ValidationTranscriber::AddressParserBase::UNIT_TYPE

Instance Method Summary collapse

Methods inherited from ValidationTranscriber::AddressParserBase

#initialize

Methods included from ValidationTranscriber::Formatter

#build_address, #strip_trailing_punctuation, #strip_word

Constructor Details

This class inherits a constructor from AtlasEngine::ValidationTranscriber::AddressParserBase

Instance Method Details

#parseObject



13
14
15
16
17
18
19
20
21
# File 'app/countries/atlas_engine/si/validation_transcriber/address_parser.rb', line 13

def parse
  # addressses sometimes follow an abbreviation with a period and no space afterward
  super.each do |components|
    components[:street]&.gsub!(
      /\A(?<prefix>.+?)(?<dot>\.)(?<non_space>\S)/i,
      "\\k<prefix> \\k<non_space>",
    )
  end
end