jma_feed 0.0.2 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jma_feed/atom/eqvol.rb +7 -0
- data/lib/jma_feed/atom/extra.rb +7 -0
- data/lib/jma_feed/atom/other.rb +7 -0
- data/lib/jma_feed/atom/regular.rb +7 -0
- data/lib/jma_feed/atom.rb +70 -0
- data/lib/jma_feed/entity/weather_alert/metrics_item.rb +14 -0
- data/lib/jma_feed/entity/weather_alert.rb +348 -0
- data/lib/jma_feed/node/base_node.rb +4 -0
- data/lib/jma_feed/report.rb +14 -1
- data/lib/jma_feed/report_entry/jmx/discharge.rb +4 -0
- data/lib/jma_feed/report_entry/jmx/earthquake.rb +22 -0
- data/lib/jma_feed/report_entry/jmx/earthquake_intensity.rb +14 -0
- data/lib/jma_feed/report_entry/jmx/humidity.rb +20 -0
- data/lib/jma_feed/report_entry/jmx/precipitation.rb +13 -0
- data/lib/jma_feed/report_entry/jmx/significancy.rb +14 -0
- data/lib/jma_feed/report_entry/jmx/snow_fall_depth.rb +20 -0
- data/lib/jma_feed/report_entry/jmx/tidal_level.rb +20 -0
- data/lib/jma_feed/report_entry/jmx/time_define.rb +18 -0
- data/lib/jma_feed/report_entry/jmx/visibility.rb +20 -0
- data/lib/jma_feed/report_entry/jmx/water_level.rb +4 -0
- data/lib/jma_feed/report_entry/jmx/wave_height.rb +20 -0
- data/lib/jma_feed/report_entry/jmx/wind_direction.rb +20 -0
- data/lib/jma_feed/report_entry/jmx/wind_speed.rb +20 -0
- data/lib/jma_feed/report_entry/vphw50.rb +4 -4
- data/lib/jma_feed/report_entry/vprn50.rb +5 -4
- data/lib/jma_feed/report_entry/vpww54.rb +221 -32
- data/lib/jma_feed/report_entry/vxse53.rb +135 -0
- data/lib/jma_feed/report_entry.rb +19 -2
- data/lib/jma_feed/result.rb +21 -22
- data/lib/jma_feed/result_doc.rb +53 -0
- data/lib/jma_feed/result_entry.rb +24 -1
- data/lib/jma_feed/version.rb +1 -1
- data/lib/jma_feed.rb +10 -3
- metadata +26 -8
- data/lib/jma_feed/api.rb +0 -48
- data/lib/jma_feed/entity/alert.rb +0 -176
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f2d20e3b5f31fc0cb5726f48dceb280e6b49110da4dc110ec3df67b888cf4ad
|
4
|
+
data.tar.gz: 188051f02027907aec84fd0e8f58c1223daa46b4c4da6b3074f87252837cefd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ca0c27158b6111371e3b2111f8d2041f77ad0f8708828216bc569745ccfd0493da0d94a30cb83ae8faba62216cc2d044ce989b67ff92b7b6393674f9a5e4e3
|
7
|
+
data.tar.gz: 94fd7457b4471845cff5f3d9542344da3de9962e8376581770d06562d304c5f6c06b857eef70aa938fd2a0ab333e42326f293df2d03b5390cf38b9def8b03026
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module JMAFeed::Atom
|
4
|
+
|
5
|
+
def self.type(feed_type, **args)
|
6
|
+
feed_type = feed_type.to_sym
|
7
|
+
if feed_type == :regular
|
8
|
+
JMAFeed::Regular.new(**args)
|
9
|
+
elsif feed_type == :extra
|
10
|
+
JMAFeed::Extra.new(**args)
|
11
|
+
elsif feed_type == :eqvol
|
12
|
+
JMAFeed::Eqvol.new(**args)
|
13
|
+
elsif feed_type == :other
|
14
|
+
JMAFeed::Other.new(**args)
|
15
|
+
else
|
16
|
+
raise "feed_type=#{feed_type} not supported"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(if_modified_since: nil, &block)
|
21
|
+
res = execute(:get, "https://www.data.jma.go.jp/developer/xml/feed/#{feed_type}.xml", headers: {
|
22
|
+
"If-Modified-Since" => if_modified_since ?
|
23
|
+
if_modified_since.httpdate :
|
24
|
+
nil
|
25
|
+
}, &block)
|
26
|
+
JMAFeed::Result.new(res)
|
27
|
+
end
|
28
|
+
|
29
|
+
# def get_feed_regular(if_modified_since: nil, &block)
|
30
|
+
# res = execute(:get, "https://www.data.jma.go.jp/developer/xml/feed/regular.xml", headers: {
|
31
|
+
# "If-Modified-Since" => if_modified_since ?
|
32
|
+
# if_modified_since.httpdate :
|
33
|
+
# nil
|
34
|
+
# }, &block)
|
35
|
+
# JMAFeed::Result.new(res)
|
36
|
+
# end
|
37
|
+
|
38
|
+
# def get_feed_extra(if_modified_since: nil, &block)
|
39
|
+
# res = execute(:get, "https://www.data.jma.go.jp/developer/xml/feed/extra.xml", headers: {
|
40
|
+
# "If-Modified-Since" => if_modified_since ?
|
41
|
+
# if_modified_since.httpdate :
|
42
|
+
# nil
|
43
|
+
# }, &block)
|
44
|
+
# JMAFeed::Result.new(res)
|
45
|
+
# end
|
46
|
+
|
47
|
+
def execute(verb, uri, query: nil, body: nil, headers: {})
|
48
|
+
uri = uri.is_a?(URI::HTTP) ? uri : URI.parse(uri)
|
49
|
+
request = build_request(verb, uri, query: query, body: body)
|
50
|
+
headers.each {|k,v| request[k] = v}
|
51
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
52
|
+
yield(request, http) if block_given?
|
53
|
+
# http.read_timeout = 30 # sec
|
54
|
+
http.request(request)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_request(verb, uri, query: nil, body: nil, headers: {})
|
59
|
+
if query
|
60
|
+
uri.query = URI.encode_www_form(query)
|
61
|
+
end
|
62
|
+
request = "Net::HTTP::#{verb.to_s.camelize}".constantize.new(uri)
|
63
|
+
|
64
|
+
if body
|
65
|
+
request.body = body
|
66
|
+
end
|
67
|
+
|
68
|
+
request
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class JMAFeed::WeatherAlert::MetricsItem < Struct.new(
|
2
|
+
:name, :value, :description, :time_define,
|
3
|
+
keyword_init: true
|
4
|
+
)
|
5
|
+
|
6
|
+
def to_h
|
7
|
+
{
|
8
|
+
name: name,
|
9
|
+
value: value,
|
10
|
+
description: description,
|
11
|
+
time_define: time_define.to_h,
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,348 @@
|
|
1
|
+
class JMAFeed::WeatherAlert < Struct.new(:code, :name, :risk_level, :cluster, keyword_init: true)
|
2
|
+
# 気象警報・注意(H27)_解説資料.pdf > 別表1
|
3
|
+
# https://www.jma.go.jp/jma/kishou/know/bosai/warning_kind.html
|
4
|
+
LIST = {
|
5
|
+
"00" => {
|
6
|
+
name: "解除",
|
7
|
+
risk_level: :level5,
|
8
|
+
cluster: :clear,
|
9
|
+
},
|
10
|
+
"02" => {
|
11
|
+
name: "暴風雪警報",
|
12
|
+
risk_level: :level3,
|
13
|
+
cluster: :snowstorm,
|
14
|
+
},
|
15
|
+
"03" => {
|
16
|
+
name: "大雨警報",
|
17
|
+
risk_level: :level3,
|
18
|
+
cluster: :heavy_rain,
|
19
|
+
},
|
20
|
+
"04" => {
|
21
|
+
name: "洪水警報",
|
22
|
+
risk_level: :level3,
|
23
|
+
cluster: :flood,
|
24
|
+
},
|
25
|
+
"05" => {
|
26
|
+
name: "暴風警報",
|
27
|
+
risk_level: :level3,
|
28
|
+
cluster: :storm,
|
29
|
+
},
|
30
|
+
"06" => {
|
31
|
+
name: "大雪警報",
|
32
|
+
risk_level: :level3,
|
33
|
+
cluster: :heavy_snow,
|
34
|
+
},
|
35
|
+
"07" => {
|
36
|
+
name: "波浪警報",
|
37
|
+
risk_level: :level3,
|
38
|
+
cluster: :high_wave,
|
39
|
+
},
|
40
|
+
"08" => {
|
41
|
+
name: "高潮警報",
|
42
|
+
risk_level: :level3,
|
43
|
+
cluster: :storm_surge,
|
44
|
+
},
|
45
|
+
"10" => {
|
46
|
+
name: "大雨注意報",
|
47
|
+
risk_level: :level2,
|
48
|
+
cluster: :heavy_rain,
|
49
|
+
},
|
50
|
+
"12" => {
|
51
|
+
name: "大雪注意報",
|
52
|
+
risk_level: :level2,
|
53
|
+
cluster: :heavy_snow,
|
54
|
+
},
|
55
|
+
"13" => {
|
56
|
+
name: "風雪注意報",
|
57
|
+
risk_level: :level2,
|
58
|
+
cluster: :snowstorm,
|
59
|
+
},
|
60
|
+
"14" => {
|
61
|
+
name: "雷注意報",
|
62
|
+
risk_level: :level2,
|
63
|
+
cluster: :thunderstorm,
|
64
|
+
},
|
65
|
+
"15" => {
|
66
|
+
name: "強風注意報",
|
67
|
+
risk_level: :level2,
|
68
|
+
cluster: :storm,
|
69
|
+
},
|
70
|
+
"16" => {
|
71
|
+
name: "波浪注意報",
|
72
|
+
risk_level: :level2,
|
73
|
+
cluster: :high_wave,
|
74
|
+
},
|
75
|
+
"17" => {
|
76
|
+
name: "融雪注意報",
|
77
|
+
risk_level: :level2,
|
78
|
+
cluster: :snow_melting,
|
79
|
+
},
|
80
|
+
"18" => {
|
81
|
+
name: "洪水注意報",
|
82
|
+
risk_level: :level2,
|
83
|
+
cluster: :flood,
|
84
|
+
},
|
85
|
+
"19" => {
|
86
|
+
name: "高潮注意報",
|
87
|
+
risk_level: :level2,
|
88
|
+
cluster: :storm_surge,
|
89
|
+
},
|
90
|
+
"20" => {
|
91
|
+
name: "濃霧注意報",
|
92
|
+
risk_level: :level2,
|
93
|
+
cluster: :dense_fog,
|
94
|
+
},
|
95
|
+
"21" => {
|
96
|
+
name: "乾燥注意報",
|
97
|
+
risk_level: :level2,
|
98
|
+
cluster: :dry_air,
|
99
|
+
},
|
100
|
+
|
101
|
+
"22" => {
|
102
|
+
name: "なだれ注意報",
|
103
|
+
risk_level: :level2,
|
104
|
+
cluster: :avalanche,
|
105
|
+
},
|
106
|
+
"23" => {
|
107
|
+
name: "低温注意報",
|
108
|
+
risk_level: :level2,
|
109
|
+
cluster: :low_temperature,
|
110
|
+
},
|
111
|
+
"24" => {
|
112
|
+
name: "霜注意報",
|
113
|
+
risk_level: :level2,
|
114
|
+
cluster: :frost,
|
115
|
+
},
|
116
|
+
"25" => {
|
117
|
+
name: "着氷注意報",
|
118
|
+
risk_level: :level2,
|
119
|
+
cluster: :ice_accretion,
|
120
|
+
},
|
121
|
+
"26" => {
|
122
|
+
name: "着雪注意報",
|
123
|
+
risk_level: :level2,
|
124
|
+
cluster: :snow_accretion,
|
125
|
+
},
|
126
|
+
"27" => {
|
127
|
+
name: "その他の注意",
|
128
|
+
risk_level: :level2,
|
129
|
+
cluster: :other,
|
130
|
+
},
|
131
|
+
|
132
|
+
"32" => {
|
133
|
+
name: "暴風雪特別警報",
|
134
|
+
risk_level: :level5,
|
135
|
+
cluster: :snowstorm,
|
136
|
+
},
|
137
|
+
"33" => {
|
138
|
+
name: "大雨特別警報",
|
139
|
+
risk_level: :level5,
|
140
|
+
cluster: :heavy_rain,
|
141
|
+
},
|
142
|
+
"35" => {
|
143
|
+
name: "暴風特別警報",
|
144
|
+
risk_level: :level5,
|
145
|
+
cluster: :storm,
|
146
|
+
},
|
147
|
+
"36" => {
|
148
|
+
name: "大雪特別警報",
|
149
|
+
risk_level: :level5,
|
150
|
+
cluster: :heavy_snow,
|
151
|
+
},
|
152
|
+
"37" => {
|
153
|
+
name: "波浪特別警報",
|
154
|
+
risk_level: :level5,
|
155
|
+
cluster: :high_wave,
|
156
|
+
},
|
157
|
+
"38" => {
|
158
|
+
name: "高潮特別警報",
|
159
|
+
risk_level: :level5,
|
160
|
+
cluster: :storm_surge,
|
161
|
+
},
|
162
|
+
}
|
163
|
+
|
164
|
+
# 気象警報・注意(H27)_解説資料.pdf > 別表4
|
165
|
+
METRICS = {
|
166
|
+
storm_metrics: {
|
167
|
+
"風危険度" => {
|
168
|
+
name: :significancy,
|
169
|
+
property_type: "危険度",
|
170
|
+
},
|
171
|
+
"風向" => {
|
172
|
+
name: :wind_direction,
|
173
|
+
property_type: "風",
|
174
|
+
},
|
175
|
+
"最大風速" => {
|
176
|
+
name: :wind_speed,
|
177
|
+
property_type: "風",
|
178
|
+
},
|
179
|
+
},
|
180
|
+
rain_metrics: {
|
181
|
+
"土砂災害危険度" => {
|
182
|
+
name: :significancy,
|
183
|
+
property_type: "危険度",
|
184
|
+
},
|
185
|
+
"浸水害危険度" => {
|
186
|
+
name: :significancy,
|
187
|
+
property_type: "危険度",
|
188
|
+
},
|
189
|
+
"1時間最大雨量" => {
|
190
|
+
name: :precipitation,
|
191
|
+
property_type: "雨",
|
192
|
+
},
|
193
|
+
"3時間最大雨量" => {
|
194
|
+
name: :precipitation,
|
195
|
+
property_type: "雨",
|
196
|
+
},
|
197
|
+
},
|
198
|
+
flood_metrics: {
|
199
|
+
"洪水害危険度" => {
|
200
|
+
name: :significancy,
|
201
|
+
property_type: "危険度",
|
202
|
+
},
|
203
|
+
},
|
204
|
+
snow_metrics: {
|
205
|
+
"雪危険度" => {
|
206
|
+
name: :significancy,
|
207
|
+
property_type: "危険度",
|
208
|
+
},
|
209
|
+
"6時間最大降雪量" => {
|
210
|
+
name: :snow_fall_depth,
|
211
|
+
property_type: "雪",
|
212
|
+
},
|
213
|
+
"12時間最大降雪量" => {
|
214
|
+
name: :snow_fall_depth,
|
215
|
+
property_type: "雪",
|
216
|
+
},
|
217
|
+
"24時間最大降雪量" => {
|
218
|
+
name: :snow_fall_depth,
|
219
|
+
property_type: "雪",
|
220
|
+
},
|
221
|
+
},
|
222
|
+
wave_metrics: {
|
223
|
+
"波危険度" => {
|
224
|
+
name: :significancy,
|
225
|
+
property_type: "危険度",
|
226
|
+
},
|
227
|
+
"波高" => {
|
228
|
+
name: :wave_height,
|
229
|
+
property_type: "波",
|
230
|
+
},
|
231
|
+
},
|
232
|
+
tide_metrics: {
|
233
|
+
"高潮危険度" => {
|
234
|
+
name: :significancy,
|
235
|
+
property_type: "危険度",
|
236
|
+
},
|
237
|
+
"最高潮位" => {
|
238
|
+
name: :tidal_level,
|
239
|
+
property_type: "高",
|
240
|
+
},
|
241
|
+
},
|
242
|
+
thunder_metrics: {
|
243
|
+
"雷危険度" => {
|
244
|
+
name: :significancy,
|
245
|
+
property_type: "危険度",
|
246
|
+
},
|
247
|
+
},
|
248
|
+
snow_melting_metrics: {
|
249
|
+
"融雪危険度" => {
|
250
|
+
name: :significancy,
|
251
|
+
property_type: "危険度",
|
252
|
+
},
|
253
|
+
},
|
254
|
+
fog_metrics: {
|
255
|
+
"濃霧危険度" => {
|
256
|
+
name: :significancy,
|
257
|
+
property_type: "危険度",
|
258
|
+
},
|
259
|
+
"視程" => {
|
260
|
+
name: :visibility,
|
261
|
+
property_type: "濃霧",
|
262
|
+
},
|
263
|
+
},
|
264
|
+
dry_air_metrics: {
|
265
|
+
"乾燥危険度" => {
|
266
|
+
name: :significancy,
|
267
|
+
property_type: "危険度",
|
268
|
+
},
|
269
|
+
"実効湿度" => {
|
270
|
+
name: :humidity,
|
271
|
+
property_type: "乾燥",
|
272
|
+
},
|
273
|
+
"最小湿度" => {
|
274
|
+
name: :humidity,
|
275
|
+
property_type: "乾燥",
|
276
|
+
},
|
277
|
+
},
|
278
|
+
avalanche_metrics: {
|
279
|
+
"なだれ危険度" => {
|
280
|
+
name: :significancy,
|
281
|
+
property_type: "危険度",
|
282
|
+
},
|
283
|
+
},
|
284
|
+
low_temperature_metrics: {
|
285
|
+
"低温危険度" => {
|
286
|
+
name: :significancy,
|
287
|
+
property_type: "危険度",
|
288
|
+
},
|
289
|
+
},
|
290
|
+
frost_metrics: {
|
291
|
+
"霜危険度" => {
|
292
|
+
name: :significancy,
|
293
|
+
property_type: "危険度",
|
294
|
+
},
|
295
|
+
},
|
296
|
+
ice_accretion_metrics: {
|
297
|
+
"着氷危険度" => {
|
298
|
+
name: :significancy,
|
299
|
+
property_type: "危険度",
|
300
|
+
},
|
301
|
+
},
|
302
|
+
snow_accretion_metrics: {
|
303
|
+
"着雪危険度" => {
|
304
|
+
name: :significancy,
|
305
|
+
property_type: "危険度",
|
306
|
+
},
|
307
|
+
},
|
308
|
+
}
|
309
|
+
|
310
|
+
CLUSTER_METRICS = {
|
311
|
+
storm: METRICS[:storm_metrics],
|
312
|
+
snowstorm: METRICS[:storm_metrics],
|
313
|
+
heavy_rain: METRICS[:rain_metrics],
|
314
|
+
flood: METRICS[:flood_metrics],
|
315
|
+
heavy_snow: METRICS[:snow_metrics],
|
316
|
+
high_wave: METRICS[:wave_metrics],
|
317
|
+
storm_surge: METRICS[:tide_metrics],
|
318
|
+
thunderstorm: METRICS[:thunder_metrics],
|
319
|
+
snow_melting: METRICS[:snow_melting_metrics],
|
320
|
+
dense_fog: METRICS[:fog_metrics],
|
321
|
+
dry_air: METRICS[:dry_air_metrics],
|
322
|
+
avalanche: METRICS[:avalanche_metrics],
|
323
|
+
low_temperature: METRICS[:low_temperature_metrics],
|
324
|
+
frost: METRICS[:frost_metrics],
|
325
|
+
ice_accretion: METRICS[:ice_accretion_metrics],
|
326
|
+
snow_accretion: METRICS[:snow_accretion_metrics],
|
327
|
+
}
|
328
|
+
|
329
|
+
def self.clusters
|
330
|
+
all.group_by(&:cluster)
|
331
|
+
end
|
332
|
+
|
333
|
+
def self.all
|
334
|
+
@all ||= LIST.map{|k,v| new(v.merge(code: k.to_s))}
|
335
|
+
end
|
336
|
+
|
337
|
+
def self.metrics_properties
|
338
|
+
METRICS.values.reduce(&:merge)
|
339
|
+
end
|
340
|
+
|
341
|
+
def self.metrics_components
|
342
|
+
metrics_properties.values.uniq
|
343
|
+
end
|
344
|
+
|
345
|
+
def metrics
|
346
|
+
CLUSTER_METRICS[cluster.to_sym] || {}
|
347
|
+
end
|
348
|
+
end
|
data/lib/jma_feed/report.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
1
3
|
class JMAFeed::Report < Struct.new(
|
2
4
|
:name, :title, :kind, :category, :code_represented, :codes, keyword_init: true
|
3
5
|
)
|
@@ -34,6 +36,10 @@ class JMAFeed::Report < Struct.new(
|
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
39
|
+
def get
|
40
|
+
@data ||= load
|
41
|
+
end
|
42
|
+
|
37
43
|
def build_by_csv_row(row)
|
38
44
|
codes = build_codes(row[:code])
|
39
45
|
code_represented = build_code_represented(row[:code])
|
@@ -43,7 +49,7 @@ class JMAFeed::Report < Struct.new(
|
|
43
49
|
kind: row[:kind].split('/'),
|
44
50
|
category: row[:category],
|
45
51
|
code_represented: code_represented,
|
46
|
-
|
52
|
+
codes: codes,
|
47
53
|
)
|
48
54
|
end
|
49
55
|
|
@@ -89,4 +95,11 @@ class JMAFeed::Report < Struct.new(
|
|
89
95
|
def has_kind?(k)
|
90
96
|
Array(kind).include?(k)
|
91
97
|
end
|
98
|
+
|
99
|
+
def report_entry_class
|
100
|
+
return nil unless code_represented
|
101
|
+
JMAFeed.const_get(code_represented)
|
102
|
+
rescue NameError => e
|
103
|
+
JMAFeed::ReportEntry
|
104
|
+
end
|
92
105
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# jmx_eb
|
2
|
+
class JMAFeed::JMX::Earthquake < Giri::BaseNode
|
3
|
+
date_time_node :origin_time
|
4
|
+
date_time_node :arrival_time
|
5
|
+
|
6
|
+
xml_node :hypocenter do
|
7
|
+
xml_node :area do
|
8
|
+
text_node :name
|
9
|
+
text_node :code do
|
10
|
+
xml_attribute :type
|
11
|
+
end
|
12
|
+
text_node :coordinate do
|
13
|
+
text_node :description
|
14
|
+
text_node :datum
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
big_decimal_node :magnitude do
|
19
|
+
xml_attribute :type
|
20
|
+
xml_attribute :description
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class JMAFeed::JMX::EarthquakeIntensity < Giri::TextNodeString
|
2
|
+
# self:
|
3
|
+
# 1, 2, 3, 4, 5-, 5+, 6-, 6+, 7, 震度5弱以上未入電
|
4
|
+
|
5
|
+
def intensity
|
6
|
+
value = self.sub(/\-\z/, '').sub(/\+\z/, '.5').to_f
|
7
|
+
value > 0 ? value : nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def title
|
11
|
+
return self unless intensity
|
12
|
+
"震度" + self.sub(/\-\z/, '弱').sub(/\+\z/, '強')
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class JMAFeed::JMX::Humidity < Giri::TextNodeInteger
|
2
|
+
xml_attribute :type
|
3
|
+
xml_attribute :unit
|
4
|
+
xml_attribute :ref_id, with_name: "refID"
|
5
|
+
# xml_attribute :condition
|
6
|
+
xml_attribute :description
|
7
|
+
|
8
|
+
def time_define
|
9
|
+
(context.time_define_list || []).find{ref_id && ref_id == _1.time_id}
|
10
|
+
end
|
11
|
+
|
12
|
+
def metrics_item
|
13
|
+
@metrics_item ||= JMAFeed::WeatherAlert::MetricsItem.new(
|
14
|
+
name: type,
|
15
|
+
value: self,
|
16
|
+
description: description,
|
17
|
+
time_define: time_define,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
@@ -4,4 +4,17 @@ class JMAFeed::JMX::Precipitation < Giri::TextNodeInteger
|
|
4
4
|
xml_attribute :ref_id, with_name: "refID"
|
5
5
|
xml_attribute :condition
|
6
6
|
xml_attribute :description
|
7
|
+
|
8
|
+
def time_define
|
9
|
+
(context.time_define_list || []).find{ref_id && ref_id == _1.time_id}
|
10
|
+
end
|
11
|
+
|
12
|
+
def metrics_item
|
13
|
+
@metrics_item ||= JMAFeed::WeatherAlert::MetricsItem.new(
|
14
|
+
name: type,
|
15
|
+
value: self,
|
16
|
+
description: description,
|
17
|
+
time_define: time_define,
|
18
|
+
)
|
19
|
+
end
|
7
20
|
end
|
@@ -1,7 +1,21 @@
|
|
1
1
|
# jmx_mete
|
2
2
|
class JMAFeed::JMX::Significancy < Giri::BaseNode
|
3
3
|
xml_attribute :type
|
4
|
+
xml_attribute :ref_id, with_name: "refID"
|
4
5
|
text_node :name
|
5
6
|
text_node :code
|
6
7
|
text_node :condition
|
8
|
+
|
9
|
+
def time_define
|
10
|
+
(context.time_define_list || []).find{ref_id && ref_id == _1.time_id}
|
11
|
+
end
|
12
|
+
|
13
|
+
def metrics_item
|
14
|
+
@metrics_item ||= JMAFeed::WeatherAlert::MetricsItem.new(
|
15
|
+
name: type,
|
16
|
+
value: code,
|
17
|
+
description: name,
|
18
|
+
time_define: time_define,
|
19
|
+
)
|
20
|
+
end
|
7
21
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class JMAFeed::JMX::SnowFallDepth < Giri::TextNodeInteger
|
2
|
+
xml_attribute :type
|
3
|
+
xml_attribute :unit
|
4
|
+
xml_attribute :ref_id, with_name: "refID"
|
5
|
+
# xml_attribute :condition
|
6
|
+
xml_attribute :description
|
7
|
+
|
8
|
+
def time_define
|
9
|
+
(context.time_define_list || []).find{ref_id && ref_id == _1.time_id}
|
10
|
+
end
|
11
|
+
|
12
|
+
def metrics_item
|
13
|
+
@metrics_item ||= JMAFeed::WeatherAlert::MetricsItem.new(
|
14
|
+
name: type,
|
15
|
+
value: self,
|
16
|
+
description: description,
|
17
|
+
time_define: time_define,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class JMAFeed::JMX::TidalLevel < Giri::TextNodeBigDecimal
|
2
|
+
xml_attribute :type
|
3
|
+
xml_attribute :unit
|
4
|
+
xml_attribute :ref_id, with_name: "refID"
|
5
|
+
# xml_attribute :condition
|
6
|
+
xml_attribute :description
|
7
|
+
|
8
|
+
def time_define
|
9
|
+
(context.time_define_list || []).find{ref_id && ref_id == _1.time_id}
|
10
|
+
end
|
11
|
+
|
12
|
+
def metrics_item
|
13
|
+
@metrics_item ||= JMAFeed::WeatherAlert::MetricsItem.new(
|
14
|
+
name: type,
|
15
|
+
value: self,
|
16
|
+
description: description,
|
17
|
+
time_define: time_define,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class JMAFeed::JMX::TimeDefine < Giri::BaseNode
|
2
|
+
xml_attribute :time_id, with_name: :lower_camelcase
|
3
|
+
date_time_node :date_time
|
4
|
+
duration_node :duration
|
5
|
+
text_node :name
|
6
|
+
|
7
|
+
def start_at
|
8
|
+
date_time
|
9
|
+
end
|
10
|
+
|
11
|
+
def end_at
|
12
|
+
start_at + duration.duration_time
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_h
|
16
|
+
{name: name, start_at: start_at, end_at: end_at, duration: duration}
|
17
|
+
end
|
18
|
+
end
|