cptec_inpe 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/cptec_inpe.rb +24 -11
- data/lib/cptec_inpe/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc4fb963b8a32b07c6f2aed87bf305789a617b5a
|
4
|
+
data.tar.gz: 1d5816dd0a22e13549caf5d7bb279e228cf27bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe5c79ace5fec704819c52a6a58740df58325c21348978db8d417fc9f778b9faf8a13fc87951d890b601c87167f82cdb773999fdac2ed67f102b9d715b2484f8
|
7
|
+
data.tar.gz: d4194737f3b41221251fa4f28179c214f24fa34ca474b339b5e6d2faa9dfeddd8bf6e53aa0803d1f875323dbbd9509c8a8ba7817d47bc5e1afd1d73b97c76fa6
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# CPTEC/INPE forecast
|
2
2
|
|
3
3
|
[](https://travis-ci.org/t4deu/cptec_inpe)
|
4
4
|
[](https://coveralls.io/github/t4deu/cptec_inpe?branch=master)
|
@@ -25,6 +25,8 @@ Or install it yourself as:
|
|
25
25
|
## Usage
|
26
26
|
|
27
27
|
```ruby
|
28
|
+
require 'cptec_inpe'
|
29
|
+
|
28
30
|
client = CptecInpe.new "Rio de janeiro"
|
29
31
|
|
30
32
|
client.location = "São Paulo" # Change current location
|
data/lib/cptec_inpe.rb
CHANGED
@@ -14,10 +14,12 @@ class CptecInpe
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def location=(location)
|
17
|
+
@location_code = nil
|
18
|
+
|
17
19
|
city = find_location(location)
|
18
20
|
|
19
21
|
unless city.nil?
|
20
|
-
@location_code = city[
|
22
|
+
@location_code = city["id"]
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -28,34 +30,45 @@ class CptecInpe
|
|
28
30
|
}
|
29
31
|
}
|
30
32
|
|
31
|
-
path = "
|
32
|
-
cities = self.class.get(path, options)[
|
33
|
+
path = build_path "/listaCidades"
|
34
|
+
cities = self.class.get(path, options)["cidades"]
|
33
35
|
|
34
36
|
return if cities.nil?
|
35
|
-
return cities.first if cities[
|
37
|
+
return cities["cidade"].first if cities["cidade"].is_a?(Array)
|
36
38
|
|
37
39
|
cities["cidade"]
|
38
40
|
end
|
39
41
|
|
40
42
|
def waves_today
|
41
|
-
get
|
43
|
+
response = get("/cidade/%s/dia/0/ondas.xml")
|
44
|
+
response["cidade"] if response
|
42
45
|
end
|
43
46
|
|
44
47
|
def waves_next_days
|
45
|
-
get
|
48
|
+
response = get("/cidade/%s/todos/tempos/ondas.xml")
|
49
|
+
get_forecast(response) if response
|
46
50
|
end
|
47
51
|
|
48
52
|
def forecast
|
49
|
-
get
|
53
|
+
response = get("/cidade/%s/previsao.xml")
|
54
|
+
get_forecast(response) if response
|
50
55
|
end
|
51
56
|
|
52
57
|
private
|
53
58
|
|
54
|
-
def
|
55
|
-
|
59
|
+
def get(path_format)
|
60
|
+
unless @location_code.nil?
|
61
|
+
path = build_path(path_format % @location_code)
|
62
|
+
response = self.class.get(path)
|
63
|
+
response if response.success?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_path(path)
|
68
|
+
"/XML#{path}"
|
56
69
|
end
|
57
70
|
|
58
|
-
def
|
59
|
-
|
71
|
+
def get_forecast(response)
|
72
|
+
response["cidade"]["previsao"]
|
60
73
|
end
|
61
74
|
end
|
data/lib/cptec_inpe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cptec_inpe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tadeu Valentt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|