Class: CWB::Rain
- Inherits:
-
Object
- Object
- CWB::Rain
- Defined in:
- lib/weatai/cwb_rain.rb
Overview
Class to parse the rain data
Instance Attribute Summary collapse
-
#dataid ⇒ Object
readonly
Returns the value of attribute dataid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dataid:) ⇒ Rain
constructor
A new instance of Rain.
- #weather_test ⇒ Object
Constructor Details
#initialize(dataid:) ⇒ Rain
Returns a new instance of Rain.
8 9 10 |
# File 'lib/weatai/cwb_rain.rb', line 8 def initialize(dataid:) @dataid = dataid end |
Instance Attribute Details
#dataid ⇒ Object (readonly)
Returns the value of attribute dataid.
6 7 8 |
# File 'lib/weatai/cwb_rain.rb', line 6 def dataid @dataid end |
Class Method Details
.instant_rain ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/weatai/cwb_rain.rb', line 12 def self.instant_rain raw_info = CWB::CWBApi.raw_info2(@dataid) all_location2 = {} keys = CWB::Weather.instant_weather.keys raw_info['cwbopendata']['location'].each do |item| location = {} if(item['locationName'].in?(keys)) place = item['locationName'] location['time'] = item['time']['obsTime'] location['city'] = item['parameter'][0]['parameterValue'] location['town'] = item['parameter'][2]['parameterValue'] location['MIN_10'] = item['weatherElement'][2]['elementValue']['value'] location['MIN_10'] = '0.00' if location['MIN_10'].to_f<0 location['Daily Accumulated Rainfall'] = item['weatherElement'][7]['elementValue']['value'] all_location2.store(place, location) end end all_location2 end |
Instance Method Details
#weather_test ⇒ Object
32 33 34 |
# File 'lib/weatai/cwb_rain.rb', line 32 def weather_test return 'weather_test_yes' end |