Class: Address
Class Method Summary collapse
- .address_fields ⇒ Object
- .all_geo_address_fields ⇒ Object
- .geo_address_fields ⇒ Object
- .type_of(name) ⇒ Object
Instance Method Summary collapse
- #floor ⇒ Object
- #geolocatable? ⇒ Boolean
- #perform_geocoding ⇒ Object (also: #perform_geocoding!)
- #region ⇒ Object
- #to_s ⇒ Object
- #xtra_fields ⇒ Object
Class Method Details
.address_fields ⇒ Object
16 17 18 |
# File 'lib/address.rb', line 16 def self.address_fields %w{street number floor_adr} + geo_address_fields end |
.all_geo_address_fields ⇒ Object
12 13 14 |
# File 'lib/address.rb', line 12 def self.all_geo_address_fields geo_address_fields + %w{latitude longitude} end |
.geo_address_fields ⇒ Object
8 9 10 |
# File 'lib/address.rb', line 8 def self.geo_address_fields %w{city state state_code province province_code postal_code country country_code} end |
.type_of(name) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/address.rb', line 20 def self.type_of name case name.to_sym when :latitude, :longitude, :postal_code :int else :string end end |
Instance Method Details
#floor ⇒ Object
41 42 43 |
# File 'lib/address.rb', line 41 def floor floor_adr.to_i end |
#geolocatable? ⇒ Boolean
59 60 61 |
# File 'lib/address.rb', line 59 def geolocatable? !full.blank? end |
#perform_geocoding ⇒ Object Also known as: perform_geocoding!
63 64 65 66 |
# File 'lib/address.rb', line 63 def perform_geocoding return unless geolocatable? addressable.perform_geocoding if addressable.respond_to? :perform_geocoding end |
#region ⇒ Object
45 46 47 |
# File 'lib/address.rb', line 45 def region state || province end |
#to_s ⇒ Object
53 54 55 56 57 |
# File 'lib/address.rb', line 53 def to_s Address.address_fields.inject("") do |res, name| res << "#{name}: #{send(name)}\n" end end |
#xtra_fields ⇒ Object
49 50 51 |
# File 'lib/address.rb', line 49 def xtra_fields [:floor_adr] end |