Class: Geocoder::Result::Mapbox
  
  
  
  
  
    - Inherits:
 
    - 
      Base
      
        
          - Object
 
          
            - Base
 
          
            - Geocoder::Result::Mapbox
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/geocoder/results/mapbox.rb
 
  
  
 
  Instance Attribute Summary
  
  Attributes inherited from Base
  #cache_hit, #data
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Base
  #initialize, #latitude, #longitude, #province, #province_code
  
    Instance Method Details
    
      
  
  
    #address  ⇒ Object 
  
  
  
  
    
      
58
59
60 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 58
def address
  data['place_name']
end 
     | 
  
 
    
      
  
  
    #city  ⇒ Object 
  
  
  
  
    
      
18
19
20 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 18
def city
  data_part('place') || context_part('place')
end
     | 
  
 
    
      
  
  
    #coordinates  ⇒ Object 
  
  
  
  
    
      
6
7
8 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 6
def coordinates
  data['geometry']['coordinates'].reverse.map(&:to_f)
end 
     | 
  
 
    
      
  
  
    #country  ⇒ Object 
  
  
  
  
    
      
40
41
42 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 40
def country
  data_part('country') || context_part('country')
end
     | 
  
 
    
      
  
  
    #country_code  ⇒ Object 
  
  
  
  
    
      
44
45
46
47
48
49
50
51
52 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 44
def country_code
  if id_matches_name?(data['id'], 'country')
    value = data['properties']['short_code']
  else
    value = context_part('country', 'short_code')
  end
  value.upcase unless value.nil?
end
     | 
  
 
    
      
  
  
    #neighborhood  ⇒ Object 
  
  
  
  
    
      
54
55
56 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 54
def neighborhood
  data_part('neighborhood') || context_part('neighborhood')
end
     | 
  
 
    
      
  
  
    #place_name  ⇒ Object 
  
  
  
  
    
      
10
11
12 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 10
def place_name
  data['place_name']
end 
     | 
  
 
    
      
  
  
    #postal_code  ⇒ Object 
  
  
  
  
    
      
36
37
38 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 36
def postal_code
  data_part('postcode') || context_part('postcode')
end
     | 
  
 
    
      
  
  
    #state  ⇒ Object 
  
  
  
  
    
      
22
23
24 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 22
def state
  data_part('region') || context_part('region')
end
     | 
  
 
    
      
  
  
    #state_code  ⇒ Object 
  
  
  
  
    
      
26
27
28
29
30
31
32
33
34 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 26
def state_code
  if id_matches_name?(data['id'], 'region')
    value = data['properties']['short_code']
  else
    value = context_part('region', 'short_code')
  end
  value.split('-').last unless value.nil?
end
     | 
  
 
    
      
  
  
    #street  ⇒ Object 
  
  
  
  
    
      
14
15
16 
     | 
    
      # File 'lib/geocoder/results/mapbox.rb', line 14
def street
  data['properties']['address']
end 
     |