Class: YahooWeather::Wind

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Wind

Returns a new instance of Wind.



4
5
6
7
8
# File 'lib/yahoo_weather/wind.rb', line 4

def initialize(payload)
  @chill     = payload['chill'].to_i
  @direction = payload['direction'].to_i
  @speed     = payload['speed'].to_f
end

Instance Attribute Details

#chillObject (readonly)

Returns the value of attribute chill.



2
3
4
# File 'lib/yahoo_weather/wind.rb', line 2

def chill
  @chill
end

#speedObject (readonly)

Returns the value of attribute speed.



2
3
4
# File 'lib/yahoo_weather/wind.rb', line 2

def speed
  @speed
end

Instance Method Details

#direction(u = 'integer') ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/yahoo_weather/wind.rb', line 10

def direction(u='integer')
  return @direction if u == 'integer'

  case @direction
  when 0..11
    direction_string(:n)
  when 12..33
    direction_string(:nne)
  when 34..56
    direction_string(:ne)
  when 57..78
    direction_string(:ene)
  when 79..101
    direction_string(:e)
  when 102..123
    direction_string(:ese)
  when 124..146
    direction_string(:se)
  when 147..168
    direction_string(:sse)
  when 169..191
    direction_string(:s)
  when 192..213
    direction_string(:ssw)
  when 214..236
    direction_string(:sw)
  when 237..258
    direction_string(:wsw)
  when 259..281
    direction_string(:w)
  when 282..303
    direction_string(:wnw)
  when 304..326
    direction_string(:nw)
  when 327..348
    direction_string(:nnw)
  when 349..360
    direction_string(:n)
  end
end