Sha256: 11f40ee017ff90dd131cf9fb4a66712920e357445b378e23c49083f8e83b4027

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module OpenWeatherAPI
  module Resources
    class Current < Base

      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

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

      # Simple handlers
      def city
        City.new @api_obj, @parameters
      end

      def city_id
        CityID.new @api_obj, @parameters
      end

      def geolocation
        Geolocation.new @api_obj, @parameters
      end

      def zipcode
        Zipcode.new @api_obj, @parameters
      end

      # Other handlers
      # ------------------
      def bbox
        BoundingBox.new @api_obj, @parameters
      end
      
      def circle
        Circle.new @api_obj, @parameters
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
open-weather-api-0.0.5 lib/open-weather-api/resources/current.rb
open-weather-api-0.0.4 lib/open-weather-api/resources/current.rb