class WeatherSage::Weather::BaseObject

Base class for weather API objects.

Constants

API_URL

URL format string for API requests.

Attributes

cache[R]

Public Class Methods

new(ctx) click to toggle source

Create a new weather object.

# File lib/weather-sage/weather/base-object.rb, line 10
def initialize(ctx)
  @ctx = ctx
end

Protected Instance Methods

get(path) click to toggle source

Request given API endpoint, return response.

FIXME: should handle errors too.

# File lib/weather-sage/weather/base-object.rb, line 26
def get(path)
  # build full URL
  url = API_URL % [path]

  # log full URL
  @ctx.log.debug('BaseObject#get') { '%s' % [url] }

  # get URL from cache
  @ctx.cache.get(url)
end