Class: Sundown::Location

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

Overview

Main class to accomodate core-features, saves weather instance once called.

Instance Method Summary collapse

Constructor Details

#initialize(location) ⇒ Location

Returns a new instance of Location.



4
5
6
# File 'lib/sundown/location.rb', line 4

def initialize(location)
  @location = location
end

Instance Method Details

#refreshObject



22
23
24
# File 'lib/sundown/location.rb', line 22

def refresh
  @weather = nil
end

#temperature(degree = 'f') ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/sundown/location.rb', line 8

def temperature(degree = 'f')
  if degree == 'c'
    (weather['query']['results']['channel']['item']['condition']['temp']
                                                       .to_f - 32) * 0.5556
  else
    weather['query']['results']['channel']['item']['condition']['temp']
                                                       .to_f
  end
end

#timestampObject



18
19
20
# File 'lib/sundown/location.rb', line 18

def timestamp
  weather['query']['results']['channel']['item']['condition']['date']
end