Class: EarthTools::Result::Base

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

Overview

The base result object.

Contains shared domain fields. Extended by different results.

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.



15
16
17
# File 'lib/earth_tools/result/base.rb', line 15

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/earth_tools/result/base.rb', line 10

def data
  @data
end

Instance Method Details

#latitudeFloat



30
31
32
# File 'lib/earth_tools/result/base.rb', line 30

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

#locationArray

Get the geographical location



22
23
24
# File 'lib/earth_tools/result/base.rb', line 22

def location
  [latitude, longitude]
end

#longitudeObject



38
39
40
# File 'lib/earth_tools/result/base.rb', line 38

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

#versionFloat

The version of the response format



45
46
47
# File 'lib/earth_tools/result/base.rb', line 45

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