Class: GeoMagic::Location

Inherits:
MapPoint show all
Defined in:
lib/geo_magic/location.rb

Defined Under Namespace

Classes: City, Country, Region

Instance Attribute Summary collapse

Attributes inherited from MapPoint

#dist, #latitude, #longitude

Instance Method Summary collapse

Methods inherited from MapPoint

#move_distance, #move_within, #within

Constructor Details

#initialize(arg) ⇒ Location

TODO



16
17
18
# File 'lib/geo_magic/location.rb', line 16

def initialize arg
  create_from_raw arg
end

Instance Attribute Details

#cityObject



78
79
80
# File 'lib/geo_magic/location.rb', line 78

def city
  @city ||= City.new city_name, zipcode, metrocode
end

#countryObject



86
87
88
# File 'lib/geo_magic/location.rb', line 86

def country
  @country ||= Country.new country_name, country_code
end

#ipObject

Returns the value of attribute ip.



5
6
7
# File 'lib/geo_magic/location.rb', line 5

def ip
  @ip
end

#regionObject



82
83
84
# File 'lib/geo_magic/location.rb', line 82

def region
  @region ||= Region.new region_name, region_code
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
# File 'lib/geo_magic/location.rb', line 20

def [] key
  send key
end

#create_from_raw(raw_location) ⇒ Object



8
9
10
11
12
13
# File 'lib/geo_magic/location.rb', line 8

def create_from_raw raw_location
  raw_location.each_pair do |key, value|
    @city_name = value and next if key == 'city'
    send :"#{key}=", value
  end
end

#map_pointObject



74
75
76
# File 'lib/geo_magic/location.rb', line 74

def map_point
  @map_point ||= GeoMagic::Point.new latitude, longitude
end

#to_hash(mode = :long) ⇒ Object



90
91
# File 'lib/geo_magic/location.rb', line 90

def to_hash mode= :long
end

#to_sObject



93
94
95
# File 'lib/geo_magic/location.rb', line 93

def to_s
  "latitude: #{latitude}, longitude #{longitude}#{ip_str}\n#{city}\n#{region}\n#{country}"
end