Class: Noaaweather
- Inherits:
-
CachedGeocode
- Object
- CachedGeocode
- Noaaweather
- Defined in:
- lib/noaa-weather.rb
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Attribute Summary collapse
-
#lattitude ⇒ Object
Returns the value of attribute lattitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Attributes inherited from CachedGeocode
Instance Method Summary collapse
- #cached? ⇒ Boolean
- #current_conditions(ashash = false) ⇒ Object
- #current_icon ⇒ Object
- #current_temp ⇒ Object
- #fetch ⇒ Object
-
#initialize(site, as_address = false) ⇒ Noaaweather
constructor
A new instance of Noaaweather.
- #location ⇒ Object
Methods inherited from CachedGeocode
Constructor Details
#initialize(site, as_address = false) ⇒ Noaaweather
Returns a new instance of Noaaweather.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/noaa-weather.rb', line 48 def initialize(site,as_address=false) if as_address self.address = site _z = geocode self.lattitude = _z[:lat] self.longitude = _z[:lon] @site = _z[:site] else self.lattitude = 41.190856 self.longitude = -81.446962 @site = site end @logger = Logger.new(STDOUT) self.start_time = Time.now() @is_cached = false end |
Instance Attribute Details
#lattitude ⇒ Object
Returns the value of attribute lattitude.
46 47 48 |
# File 'lib/noaa-weather.rb', line 46 def lattitude @lattitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
46 47 48 |
# File 'lib/noaa-weather.rb', line 46 def longitude @longitude end |
#start_time ⇒ Object
Returns the value of attribute start_time.
46 47 48 |
# File 'lib/noaa-weather.rb', line 46 def start_time @start_time end |
Instance Method Details
#cached? ⇒ Boolean
92 93 94 |
# File 'lib/noaa-weather.rb', line 92 def cached? @is_cached end |
#current_conditions(ashash = false) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/noaa-weather.rb', line 76 def current_conditions(ashash=false) self.fetch unless @fetched _c = @doc.find('/dwml/data/parameters/weather/weather-conditions/value')[0] if ashash {:coverage => _c['coverage'],:weathertype => _c['weather-type']} else @ccond ||= sprintf("%s %s",_c['coverage'],_c['weather-type']) end end |
#current_icon ⇒ Object
87 88 89 90 |
# File 'lib/noaa-weather.rb', line 87 def current_icon self.fetch unless @fetched @cicon ||= @doc.find('/dwml/data/parameters/conditions-icon/icon-link')[0].content end |
#current_temp ⇒ Object
67 68 69 70 |
# File 'lib/noaa-weather.rb', line 67 def current_temp self.fetch unless @fetched @ctemp ||= @doc.find('/dwml/data/parameters/temperature/value')[0].content.to_i end |
#fetch ⇒ Object
96 97 98 |
# File 'lib/noaa-weather.rb', line 96 def fetch @doc = fetch_from_noaa end |
#location ⇒ Object
72 73 74 |
# File 'lib/noaa-weather.rb', line 72 def location @site.to_s end |