module HG::Weather

Constants

HOST_NAME
VERSION

Attributes

api_key[RW]

API Key

api_key_status[R]

API Key status

cid[RW]
city_name[RW]
client_ip[RW]
latitude[RW]
locale[RW]
longitude[RW]
speed[RW]

Default speed format

temperature[RW]

Default temperature format

use_rails_cache[RW]

Use Rails cache for recieved data (realy recommended)

use_ssl[RW]

Use SSL to access the API

woeid[RW]

Public Class Methods

defaults() click to toggle source
# File lib/hg/weather.rb, line 73
def self.defaults
  {
    lat: self.latitude,
    lon: self.longitude,
    user_ip: self.client_ip,
    cid: self.cid,
    woeid: self.woeid,
    city_name: self.city_name,
    key: self.api_key,
    locale: self.locale,
    format: :json,
    sdk_version: "ruby_#{HG::Weather::VERSION}"
  }
end
get(options = {}) click to toggle source
# File lib/hg/weather.rb, line 57
def self.get(options = {})
  to_request = {
    lat: options[:latitude], lon: options[:longitude],
    cid: options[:cid], city_name: options[:city_name],
    user_ip: options[:client_ip], woeid: options[:woeid]
  }.delete_if{|k,v| v.nil?}

  process(to_request)
end
process(params) click to toggle source
# File lib/hg/weather.rb, line 67
def self.process params
  params = defaults.merge(params).delete_if{|k,v| v.nil?}

  return HG::Weather::Data.new(params, HOST_NAME, self.use_ssl)
end
setup() { |self| ... } click to toggle source
# File lib/hg/weather.rb, line 53
def self.setup(&block)
  yield self
end