class Geocoder::Result::GeocoderCa

Public Class Methods

response_attributes() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 41
def self.response_attributes
  %w[latt longt inlatt inlongt distance stnumber staddress prov
    NearRoad NearRoadDistance betweenRoad1 betweenRoad2
    intersection major_intersection]
end

Public Instance Methods

address(format = :full) click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 10
def address(format = :full)
  "#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
end
city() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 18
def city
  @data['city'] or (@data['standard'] and @data['standard']['city']) or ""
end
coordinates() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 6
def coordinates
  [@data['latt'].to_f, @data['longt'].to_f]
end
country() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 32
def country
  country_code == 'CA' ? 'Canada' : 'United States'
end
country_code() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 36
def country_code
  return nil if state.nil? || state == ""
  canadian_province_abbreviations.include?(state) ? "CA" : "US"
end
postal_code() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 28
def postal_code
  @data['postal'] or (@data['standard'] and @data['standard']['postal']) or ""
end
state() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 22
def state
  @data['prov'] or (@data['standard'] and @data['standard']['prov']) or ""
end
Also aliased as: state_code
state_code()
Alias for: state
street_address() click to toggle source
# File lib/geocoder/results/geocoder_ca.rb, line 14
def street_address
  "#{@data['stnumber']} #{@data['staddress']}"
end