weather-report 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/weather-report/day.rb +6 -0
- data/lib/weather-report/version.rb +1 -1
- data/lib/weather-report/weather.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 760746840f014f0120e729148e4f61516212875f
|
4
|
+
data.tar.gz: 1ceb9967c055c7b6a89fa90de5168eeef1f0ab91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae3d76979a77a7519ca8153b2a2706af9a7e65686bf1bb282801f1c4f6de8c9fbea9483f5fca14456990afa6f704166a9415fc3c900104fe4012c7a66e10d31
|
7
|
+
data.tar.gz: 52938d64da714d90db1e8dcf7aa52f360bff6e24c3446cf2703466cc7dac0a5f255e778e86c9cbe990942aed7f9a17a0703dbfa99d98420816950e60e9cc4c01
|
data/lib/weather-report/day.rb
CHANGED
@@ -8,21 +8,27 @@ module WeatherReport
|
|
8
8
|
@forecast = forecast(forecasts, dateLabel)
|
9
9
|
end
|
10
10
|
|
11
|
+
# @return [Date] the date
|
11
12
|
def date
|
12
13
|
year, month, day = @forecast["date"].split('-')
|
13
14
|
@date ||= Date.new(year.to_i, month.to_i, day.to_i)
|
14
15
|
end
|
15
16
|
|
17
|
+
# @return [String] the telop
|
16
18
|
def telop
|
17
19
|
@telop ||= @forecast["telop"]
|
18
20
|
end
|
19
21
|
|
22
|
+
# @return [Fixnum] the minimum temperature.
|
23
|
+
# Temperature of today could be nil.
|
20
24
|
def temperature_min
|
21
25
|
min = @forecast["temperature"]["min"]
|
22
26
|
@temperature ||=
|
23
27
|
min ? min["celsius"].to_i : nil
|
24
28
|
end
|
25
29
|
|
30
|
+
# @return [Fixnum] the maximum temperature.
|
31
|
+
# Temperature of today could be nil.
|
26
32
|
def temperature_max
|
27
33
|
max = @forecast["temperature"]["max"]
|
28
34
|
@temperature_max ||=
|
@@ -8,6 +8,7 @@ module WeatherReport
|
|
8
8
|
@uri = URI.parse("http://weather.livedoor.com/forecast/webservice/json/v1?city=#{city_id}")
|
9
9
|
end
|
10
10
|
|
11
|
+
# @return [String] the id of given city
|
11
12
|
def self.request_cityid(city)
|
12
13
|
doc = Nokogiri::XML(open("http://weather.livedoor.com/forecast/rss/primary_area.xml"))
|
13
14
|
doc.search("//city[@title='#{city}']").attr("id").value
|
@@ -15,14 +16,17 @@ module WeatherReport
|
|
15
16
|
raise WeatherReportError
|
16
17
|
end
|
17
18
|
|
19
|
+
# @return [Day] the today
|
18
20
|
def today
|
19
21
|
@today ||= Day.new(forecasts, "今日")
|
20
22
|
end
|
21
|
-
|
23
|
+
|
24
|
+
# @return [Day] the tomorrow
|
22
25
|
def tomorrow
|
23
26
|
@tomorrow ||= Day.new(forecasts, "明日")
|
24
27
|
end
|
25
28
|
|
29
|
+
# @return [Day] the day after tomorrow
|
26
30
|
def day_after_tomorrow
|
27
31
|
@day_after_tomorrow ||= Day.new(forecasts, "明後日")
|
28
32
|
end
|