Class: CWB::Weather
- Inherits:
-
Object
- Object
- CWB::Weather
- Defined in:
- lib/weatai/cwb.rb
Overview
Class to organize raw_data, finding the data we need
Instance Attribute Summary collapse
-
#dataid ⇒ Object
readonly
Returns the value of attribute dataid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dataid:) ⇒ Weather
constructor
A new instance of Weather.
- #weather_test ⇒ Object
Constructor Details
#initialize(dataid:) ⇒ Weather
Returns a new instance of Weather.
7 8 9 |
# File 'lib/weatai/cwb.rb', line 7 def initialize(dataid:) @dataid = dataid end |
Instance Attribute Details
#dataid ⇒ Object (readonly)
Returns the value of attribute dataid.
5 6 7 |
# File 'lib/weatai/cwb.rb', line 5 def dataid @dataid end |
Class Method Details
.instant_weather ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/weatai/cwb.rb', line 11 def self.instant_weather raw_info = CWB::CWBApi.raw_info1(@dataid) all_location1 = {} raw_info['cwbopendata']['location'].each do |item| location = {} place = item['locationName'] location['time'] = item['time']['obsTime'] location['city'] = item['parameter'][0]['parameterValue'] location['town'] = item['parameter'][2]['parameterValue'] location['TEMP'] = item['weatherElement'][4]['elementValue']['value'] location['HUMD'] = item['weatherElement'][5]['elementValue']['value'] all_location1.store(place, location) end all_location1 end |
Instance Method Details
#weather_test ⇒ Object
27 28 29 |
# File 'lib/weatai/cwb.rb', line 27 def weather_test return 'weather_test_yes' end |