Class: GoogleWeather

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/google_weather.rb,
lib/google_weather/data.rb,
lib/google_weather/version.rb

Defined Under Namespace

Classes: CurrentConditions, Data, ForecastCondition, ForecastInformation

Constant Summary collapse

Path =
"/ig/api"
VERSION =
"0.3.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, options = {}) ⇒ GoogleWeather

Returns a new instance of GoogleWeather.



11
12
13
14
# File 'lib/google_weather.rb', line 11

def initialize(value, options={})
  @param   = prep_param(value)
  @options = options
end

Instance Attribute Details

#paramObject (readonly)

Returns the value of attribute param.



9
10
11
# File 'lib/google_weather.rb', line 9

def param
  @param
end

Instance Method Details

#current_conditionsObject



28
29
30
# File 'lib/google_weather.rb', line 28

def current_conditions
  @current_conditions ||= CurrentConditions.new(weather['current_conditions'])
end

#forecast_conditionsObject



32
33
34
# File 'lib/google_weather.rb', line 32

def forecast_conditions
  @forecast_conditions ||= weather['forecast_conditions'].map { |cond| ForecastCondition.new(cond) }
end

#forecast_informationObject



24
25
26
# File 'lib/google_weather.rb', line 24

def forecast_information
  @forecast_information ||= ForecastInformation.new(weather['forecast_information'])
end

#localeObject



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

def locale
  @options[:locale] || :en
end

#weatherObject



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

def weather
  @weather ||= self.class.get(Path, weather_options)['xml_api_reply']['weather']
end