Class: OpenWeatherAPI::Resources::Current

Inherits:
Base
  • Object
show all
Defined in:
lib/open-weather-api/resources/current.rb

Instance Attribute Summary

Attributes inherited from Base

#api_obj

Instance Method Summary collapse

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from OpenWeatherAPI::Resources::Base

Instance Method Details

#base_urlObject



5
6
7
8
9
10
# File 'lib/open-weather-api/resources/current.rb', line 5

def base_url
  return super + 'group/'    if city_id.multiple?
  return super + 'weather/'  if [city, city_id, geolocation, zipcode].any? { |h| h.can? }
  return super + 'box/city/' if bbox.can?
  return super + 'find/'     if circle.can?
end

#bboxObject

Other handlers




35
36
37
# File 'lib/open-weather-api/resources/current.rb', line 35

def bbox
  Handlers::BoundingBox.new @api_obj, @parameters
end

#build_params(parameters = {}) ⇒ Object



12
13
14
# File 'lib/open-weather-api/resources/current.rb', line 12

def build_params(parameters = {})
  super [city, city_id, geolocation, zipcode, bbox, circle].each{ |h| break h.handle if h.can? }
end

#circleObject



39
40
41
# File 'lib/open-weather-api/resources/current.rb', line 39

def circle
  Handlers::Circle.new @api_obj, @parameters
end

#cityObject

Simple handlers



17
18
19
# File 'lib/open-weather-api/resources/current.rb', line 17

def city
  Handlers::City.new @api_obj, @parameters
end

#city_idObject



21
22
23
# File 'lib/open-weather-api/resources/current.rb', line 21

def city_id
  Handlers::CityID.new @api_obj, @parameters
end

#geolocationObject



25
26
27
# File 'lib/open-weather-api/resources/current.rb', line 25

def geolocation
  Handlers::Geolocation.new @api_obj, @parameters
end

#zipcodeObject



29
30
31
# File 'lib/open-weather-api/resources/current.rb', line 29

def zipcode
  Handlers::Zipcode.new @api_obj, @parameters
end