Sha256: aec7ec9c1580a0481dd8da13a9eb416522e361294c57d48cbe4dcfb51f59c967
Contents?: true
Size: 1.13 KB
Versions: 18
Compression:
Stored size: 1.13 KB
Contents
require 'geocoder/results/base' module Geocoder::Result class Ipgeolocation < Base def coordinates [@data['latitude'].to_f, @data['longitude'].to_f] end def address(format = :full) "#{city}, #{state} #{postal_code}, #{country_name}".sub(/^[ ,]*/, "") end def state @data['state_prov'] end def state_code @data['state_prov'] end def country @data['country_name'] end def country_code @data['country_code2'] end def postal_code @data['zipcode'] end def self.response_attributes [ ['ip', ''], ['hostname', ''], ['continent_code', ''], ['continent_name', ''], ['country_code2', ''], ['country_code3', ''], ['country_name', ''], ['country_capital',''], ['district',''], ['state_prov',''], ['city', ''], ['zipcode', ''], ['time_zone', {}], ['currency', {}] ] end response_attributes.each do |attr, default| define_method attr do @data[attr] || default end end end end
Version data entries
18 entries across 18 versions & 1 rubygems