Class: JDX::Geocoder::IpApi
- Inherits:
-
Object
- Object
- JDX::Geocoder::IpApi
- Includes:
- Base
- Defined in:
- lib/jdx/geocoder/ip_api.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
- #address ⇒ Object
- #city ⇒ Object
-
#coordinates ⇒ Object
coordinate order is longitude, latitude.
- #country ⇒ Object
- #country_code ⇒ Object
-
#initialize(term) ⇒ IpApi
constructor
A new instance of IpApi.
- #latitude ⇒ Object
- #longitude ⇒ Object
- #postal_code ⇒ Object
- #state ⇒ Object
- #state_code ⇒ Object
Methods included from Base
Constructor Details
#initialize(term) ⇒ IpApi
Returns a new instance of IpApi.
8 9 10 |
# File 'lib/jdx/geocoder/ip_api.rb', line 8 def initialize(term) @term = term end |
Instance Method Details
#address ⇒ Object
24 25 26 |
# File 'lib/jdx/geocoder/ip_api.rb', line 24 def address "#{city}, #{state_code} #{postal_code}, #{country}".sub(/^[ ,]*/, '') end |
#city ⇒ Object
12 13 14 |
# File 'lib/jdx/geocoder/ip_api.rb', line 12 def city data['city'] end |
#coordinates ⇒ Object
coordinate order is longitude, latitude
49 50 51 |
# File 'lib/jdx/geocoder/ip_api.rb', line 49 def coordinates [longitude, latitude] end |
#country ⇒ Object
16 17 18 |
# File 'lib/jdx/geocoder/ip_api.rb', line 16 def country data['country'] end |
#country_code ⇒ Object
20 21 22 |
# File 'lib/jdx/geocoder/ip_api.rb', line 20 def country_code data['countryCode'] end |
#latitude ⇒ Object
36 37 38 |
# File 'lib/jdx/geocoder/ip_api.rb', line 36 def latitude data['lat'] end |
#longitude ⇒ Object
40 41 42 |
# File 'lib/jdx/geocoder/ip_api.rb', line 40 def longitude data['lon'] end |
#postal_code ⇒ Object
44 45 46 |
# File 'lib/jdx/geocoder/ip_api.rb', line 44 def postal_code data['zip'] end |
#state ⇒ Object
28 29 30 |
# File 'lib/jdx/geocoder/ip_api.rb', line 28 def state data['regionName'] end |
#state_code ⇒ Object
32 33 34 |
# File 'lib/jdx/geocoder/ip_api.rb', line 32 def state_code data['region'] end |