strans-client 0.0.12 → 0.0.13
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/lib/linha.rb +20 -7
- data/lib/parada.rb +11 -0
- data/lib/response.rb +2 -5
- data/lib/token.rb +7 -0
- data/lib/veiculo.rb +11 -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: e0af28f3e39d5cccca4929deb3a0f136653caf91
|
|
4
|
+
data.tar.gz: 5c10fe18328b93b8ea1969e29de29868aaf28457
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 711ac8a3396984ce49953cbd963dc2df53f89537fae73b5c89e8c3342fb6aebee8e63e6a705b4a43ee123063696f8f20d8501e6c5420cbcc9ffdc37a3b9133e9
|
|
7
|
+
data.tar.gz: 83de6a6874e6a261b1e97c29da647a3707f4f1043c4ceb8168346bf90db72b85e601c8d90b552a2b8b59ef47621e07e40e5b9a04723bb8c7d1f0079e3f4ce8d4
|
data/lib/linha.rb
CHANGED
|
@@ -6,13 +6,15 @@ class Linha
|
|
|
6
6
|
:retorno, :circular, :veiculos, :paradas
|
|
7
7
|
|
|
8
8
|
def initialize(fields)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if(fields)
|
|
10
|
+
@codigoLinha = fields['CodigoLinha'] || fields[:codigoLinha]
|
|
11
|
+
@denomicao = fields['Denomicao'] || fields[:denomicao]
|
|
12
|
+
@origem = fields['Origem'] || fields[:origem]
|
|
13
|
+
@retorno = fields['Retorno'] || fields[:retorno]
|
|
14
|
+
@circular = fields['Circular'] || fields[:circular]
|
|
15
|
+
@veiculos = load_objs(fields['Veiculos'], Veiculo)
|
|
16
|
+
@paradas = load_objs(fields['Paradas'], Parada)
|
|
17
|
+
end
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def load_objs(objs, k)
|
|
@@ -26,4 +28,15 @@ class Linha
|
|
|
26
28
|
return map
|
|
27
29
|
end
|
|
28
30
|
|
|
31
|
+
def to_json(*a)
|
|
32
|
+
{
|
|
33
|
+
'codigoLinha' => @codigoLinha,
|
|
34
|
+
'denomicao' => @denominacao,
|
|
35
|
+
'origem' => @origem,
|
|
36
|
+
'retorno' => @retorno,
|
|
37
|
+
'Circular' => @circular,
|
|
38
|
+
'veiculos' => @veiculos,
|
|
39
|
+
'paradas' => @paradas
|
|
40
|
+
}.to_json(*a)
|
|
41
|
+
end
|
|
29
42
|
end
|
data/lib/parada.rb
CHANGED
|
@@ -16,4 +16,15 @@ class Parada
|
|
|
16
16
|
@long = fields['Long'] || fields[:long]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def to_json(*a)
|
|
20
|
+
{
|
|
21
|
+
'codigoParada' => @codigoParada,
|
|
22
|
+
'denominacao' => @denominacao,
|
|
23
|
+
'endereco' => @endereco,
|
|
24
|
+
'lat' => @lat,
|
|
25
|
+
'long' => @long
|
|
26
|
+
}.to_json(*a)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
19
30
|
end
|
data/lib/response.rb
CHANGED
|
@@ -7,11 +7,9 @@ class Response
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def model(path)
|
|
10
|
-
#
|
|
11
10
|
@resp = JSON.parse(@resp.body)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
raise @resp['message']
|
|
11
|
+
if(@resp[0] == 'code')
|
|
12
|
+
raise @resp[1]
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
case path
|
|
@@ -47,7 +45,6 @@ class Response
|
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
def veiculos_linha()
|
|
50
|
-
puts @resp
|
|
51
48
|
linha = Linha.new(@resp['Linha'])
|
|
52
49
|
linha.veiculos
|
|
53
50
|
end
|
data/lib/token.rb
CHANGED
data/lib/veiculo.rb
CHANGED
|
@@ -2,6 +2,8 @@ require 'require_models'
|
|
|
2
2
|
|
|
3
3
|
class Veiculo
|
|
4
4
|
|
|
5
|
+
attr_accessor :codigoVeiculo, :hora, :lat, :long, :linha
|
|
6
|
+
|
|
5
7
|
def initialize(fields)
|
|
6
8
|
@codigoVeiculo = fields['CodigoVeiculo'] || fields[:codigoVeiculo]
|
|
7
9
|
@hora = fields['Hora'] || fields[:hora]
|
|
@@ -9,6 +11,14 @@ class Veiculo
|
|
|
9
11
|
@long = fields['Long'] || fields[:long]
|
|
10
12
|
end
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
#def to_json()
|
|
15
|
+
def to_json(*a)
|
|
16
|
+
{
|
|
17
|
+
'codigoVeiculo' => @codigoVeiculo,
|
|
18
|
+
'hora' => @hora,
|
|
19
|
+
'lat' => @lat,
|
|
20
|
+
'long' => @long,
|
|
21
|
+
}.to_json(*a)
|
|
22
|
+
end
|
|
13
23
|
|
|
14
24
|
end
|