lib/wagon/address.rb in wagon-0.9.5 vs lib/wagon/address.rb in wagon-0.10.0
- old
+ new
@@ -1,10 +1,10 @@
module Wagon
class Address
CITY_STATE_ZIP = %r/^(\D+), (\D+)?\s*(\d+(-\d+)?)?$/
- attr_reader :street, :city, :state, :zip, :country
+ attr_reader :city, :state, :zip, :country
def self.extract_from_string(string)
parts = string.split("\n").collect(&:strip).delete_if(&:empty?)
street = city = state = zip = country = nil
@@ -16,9 +16,14 @@
self.new(parts.shift, city, state, zip, parts.shift)
end
def initialize(street, city, state, zip, country)
@street, @city, @state, @zip, @country = street, city, state, zip, country
+ end
+
+ def street
+ #601 N. Monterey Drive Apartment K
+ @street.to_s.gsub(/apartment/i, 'Apt.').gsub(/drive/i, 'Dr.')
end
def to_s
[street, [[city, state].compact.join(", "), zip, country.to_s.empty? ? nil : "(#{country})"].compact.join(" ")].compact.join("\n")
end
\ No newline at end of file