weather-report 0.2.0 → 0.2.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.rb +3 -2
- data/lib/weather-report/version.rb +1 -1
- data/lib/weather-report/weather.rb +2 -2
- 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: 215e7ea53b6c80070765674a8b7c2af6c449dee4
|
4
|
+
data.tar.gz: f1b6bbb7511eead4d7ebcdfa41b6ce74f565d169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3534d9288839c83fc4765c7d32ac3fc19cbb601d7da6e3f43b34934c5c10f601c40f942c7f4ae858671bc55eb68943e6be63909b8bda21f17541e5ea5e824d9
|
7
|
+
data.tar.gz: cf458b6f5fefbad98af35dcaaeee64d6ef49a9c942171389913afb22a8d74d13b5c31724e4091ec2d839155bdfc3b16f62692078688989224271c07c0505bdba
|
data/lib/weather-report.rb
CHANGED
@@ -10,7 +10,8 @@ require 'weather-report/version'
|
|
10
10
|
module WeatherReport
|
11
11
|
class WeatherReportError < StandardError; end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# @return [Weather] get weather of the city
|
14
|
+
def self.get(city_name)
|
15
|
+
Weather.new(Weather.request_cityid(city_name))
|
15
16
|
end
|
16
17
|
end
|
@@ -9,9 +9,9 @@ module WeatherReport
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# @return [String] the id of given city
|
12
|
-
def self.request_cityid(
|
12
|
+
def self.request_cityid(city_name)
|
13
13
|
doc = Nokogiri::XML(open("http://weather.livedoor.com/forecast/rss/primary_area.xml"))
|
14
|
-
doc.search("//city[@title='#{
|
14
|
+
doc.search("//city[@title='#{city_name}']").attr("id").value
|
15
15
|
rescue => e
|
16
16
|
raise WeatherReportError
|
17
17
|
end
|