Class: Postal::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_postal/parser.rb

Class Method Summary collapse

Class Method Details

.parse_address(address, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/ruby_postal/parser.rb', line 5

def self.parse_address(address, options={})
    if not address
        return []
    end
    parse_result = CParser.parse_address address, options
    if address.respond_to?(:encode)
        address = address.encode("UTF-8")
    end
    parse_result.map{|s, c| {:label => c, :value => s.force_encoding("UTF-8")}}
end