Class: Weatherman::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yahoo_weatherman.rb

Overview

Client

The weatherman client. Where it all begins.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Accepts a optional hash containing the client options.

Options:

+unit+: the unit used for the temperature (defaults to Celsius).
"f" => Fahrenheight
"c" => Celsius

+lang+: the language used in the response


39
40
41
42
# File 'lib/yahoo_weatherman.rb', line 39

def initialize(options = {})
  @options = options
  @uri = options[:url] || URI
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



26
27
28
# File 'lib/yahoo_weatherman.rb', line 26

def options
  @options
end

Instance Method Details

#lookup_by_city_code(city_code) ⇒ Object

Just pass in a woeid and it will return a Weatherman::Response object:w



47
48
49
50
# File 'lib/yahoo_weatherman.rb', line 47

def lookup_by_city_code(city_code)
  raw = get request_url(city_code)
  Response.new(raw, options[:lang])
end