class Mycrm::CoreExt::Address

Constants

FIELDS

Public Class Methods

new(formatted, locale = :en_au) click to toggle source
# File lib/mycrm/core_ext/address.rb, line 10
def initialize(formatted, locale = :en_au)
  @formatted = formatted
  expand(locale)
end

Public Instance Methods

to_h() click to toggle source
# File lib/mycrm/core_ext/address.rb, line 15
def to_h
  FIELDS.reject{ |f| f == :formatted }.each_with_object({}){ |f, out| out[f] = send(f) }
end

Private Instance Methods

expand(locale) click to toggle source
# File lib/mycrm/core_ext/address.rb, line 21
def expand(locale)
  @street, @suburb, @state, @postcode, @country = *formatted.split(',').map(&:strip)
end