weather-forecasts 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,55 +0,0 @@
1
- module WeatherForecasts
2
- class DWML
3
- class TimeLayout
4
- class << self
5
- def extract(elements)
6
- elements.map { |element| new(element) }
7
- end
8
- end
9
-
10
- attr_reader :element, :time_coordinate, :summarization, :layout_key, :valid_times
11
-
12
- def initialize(element)
13
- @element = element
14
- @valid_times = []
15
-
16
- extract_time_coordinate
17
- extract_summarization
18
- extract_layout_key
19
- extract_valid_times
20
- end
21
-
22
- protected
23
-
24
- def extract_time_coordinate
25
- @time_coordinate = element.attributes["time-coordinate"].text
26
- end
27
-
28
- def extract_summarization
29
- @summarization = element.attributes["summarization"].text
30
- end
31
-
32
- def extract_layout_key
33
- @layout_key = element.xpath("layout-key").first.text
34
- end
35
-
36
- def extract_valid_times
37
- start_times = element.xpath("start-valid-time")
38
- stop_times = element.xpath("end-valid-time")
39
-
40
- start_times.each_with_index do |start_time, index|
41
- @valid_times << ValidTime.new(start_time.text, stop_times[index].try(:text))
42
- end
43
- end
44
-
45
- class ValidTime
46
- attr_reader :start, :stop
47
-
48
- def initialize(start, stop)
49
- @start = Time.zone.parse(start.to_s)
50
- @stop = Time.zone.parse(stop.to_s)
51
- end
52
- end
53
- end
54
- end
55
- end