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 an 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

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

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


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

def options
  @options
end

Instance Method Details

#lookup_by_location(location) ⇒ Object

Looks up weather by location.


54
55
56
57
58
# File 'lib/yahoo_weatherman.rb', line 54

def lookup_by_location(location)
  lookup = WoeidLookup.new
  woeid = lookup.get_woeid(location)
  lookup_by_woeid(woeid)
end

#lookup_by_woeid(woeid) ⇒ Object

Looks up weather by woeid.


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

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