Class: EarthTools::Result::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/earth_tools/result/base.rb

Direct Known Subclasses

Height, SunriseSunset, TimeZone

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Base

Takes a hash of result data from a parsed Google result document.



13
14
15
# File 'lib/earth_tools/result/base.rb', line 13

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/earth_tools/result/base.rb', line 8

def data
  @data
end

Instance Method Details

#latitudeObject



28
29
30
# File 'lib/earth_tools/result/base.rb', line 28

def latitude
  @data['latitude'].to_f
end

#locationObject

Get the geographical location



20
21
22
# File 'lib/earth_tools/result/base.rb', line 20

def location
  [latitude, longitude]
end

#longitudeObject



36
37
38
# File 'lib/earth_tools/result/base.rb', line 36

def longitude
  @data['longitude'].to_f
end

#versionObject

The version of the response format



43
44
45
# File 'lib/earth_tools/result/base.rb', line 43

def version
  @data['version'].to_f
end