mvg 0.0.3 → 0.0.5
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/bin/mvg +3 -3
- data/lib/mvg.rb +85 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9d03bf932c832a39d5c63316d4c603462a5e51e
|
4
|
+
data.tar.gz: 292635b7674c67feef0e0767ce2277b04d6f9c34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a4489187c6a1eecb70a3791c0165e86ee90d2590c04a96c0c4f9e089c2446bf046cd4ac9fdeb4699ac5cf0eeb6177a7a9d554ca81a2334fe52337662326cb04
|
7
|
+
data.tar.gz: c035b7383ae963c1fdc65dccabe91596727d28b47f8e67d4e82fba71319910f9ad612d2c9256678dd4e41a34f63a3a7c2cb588163afbea4e90f882bbc1f5ba79
|
data/bin/mvg
CHANGED
data/lib/mvg.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mechanize'
|
3
|
+
require 'colorize'
|
4
|
+
|
5
|
+
class Ride
|
6
|
+
def initialize(line, destination, minutes)
|
7
|
+
@line=line
|
8
|
+
@destination=destination
|
9
|
+
@minutes=minutes
|
10
|
+
end
|
11
|
+
|
12
|
+
def display_info
|
13
|
+
puts @line + ' - in ' + @minutes + ' minutes - to ' + @destination.red
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Display
|
18
|
+
def initialize(station)
|
19
|
+
@station_url = station
|
20
|
+
end
|
21
|
+
|
22
|
+
def getRides
|
23
|
+
agent = Mechanize.new
|
24
|
+
agent.get('http://www.mvg-live.de/ims/dfiStaticAuswahl.svc') do |page|
|
25
|
+
|
26
|
+
form = page.forms.first
|
27
|
+
form['haltestelle'] = @station_url
|
28
|
+
result = form.submit
|
29
|
+
|
30
|
+
ubahn_ary = []
|
31
|
+
sbahn_ary = []
|
32
|
+
bus_ary = []
|
33
|
+
|
34
|
+
res_table = result.search('table.departureTable')
|
35
|
+
|
36
|
+
res_table.search('tr').each do |entry|
|
37
|
+
|
38
|
+
line = entry.search('.lineColumn').text
|
39
|
+
station = entry.search('.stationColumn').text.gsub(/\r?\n?\t/, '')
|
40
|
+
minutes = entry.search('.inMinColumn').text
|
41
|
+
|
42
|
+
if line != '' && station != '' && minutes != ''
|
43
|
+
if line[0] == 'U'
|
44
|
+
single_ride = Ride.new(line, station, minutes)
|
45
|
+
ubahn_ary.push(single_ride)
|
46
|
+
elsif line[0] == 'S'
|
47
|
+
single_ride = Ride.new(line, station, minutes)
|
48
|
+
sbahn_ary.push(single_ride)
|
49
|
+
else
|
50
|
+
single_ride = Ride.new(line, station, minutes)
|
51
|
+
bus_ary.push(single_ride)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
puts 'U-Bahn'.colorize(:color => :white, :background => :blue)
|
57
|
+
if(ubahn_ary.length == 0)
|
58
|
+
puts "Keine Einträge gefunden".colorize(:color => :white, :background => :red)
|
59
|
+
else
|
60
|
+
ubahn_ary.each do |entry|
|
61
|
+
puts entry.display_info
|
62
|
+
end
|
63
|
+
end
|
64
|
+
puts '----------------------------------'
|
65
|
+
puts 'S-Bahn'.colorize(:color => :white, :background => :yellow)
|
66
|
+
if(ubahn_ary.length == 0)
|
67
|
+
puts "Keine Einträge gefunden".colorize(:color => :white, :background => :red)
|
68
|
+
else
|
69
|
+
sbahn_ary.each do |entry|
|
70
|
+
puts entry.display_info
|
71
|
+
end
|
72
|
+
end
|
73
|
+
puts '----------------------------------'
|
74
|
+
puts 'Bus'.colorize(:color => :white, :background => :green)
|
75
|
+
if(ubahn_ary.length == 0)
|
76
|
+
puts "Keine Einträge gefunden".colorize(:color => :white, :background => :red)
|
77
|
+
else
|
78
|
+
bus_ary.each do |entry|
|
79
|
+
puts entry.display_info
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Springer
|
@@ -20,8 +20,10 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- bin/mvg
|
23
|
+
- lib/mvg.rb
|
23
24
|
homepage: https://rubygems.org/gems/mvg
|
24
|
-
licenses:
|
25
|
+
licenses:
|
26
|
+
- MIT
|
25
27
|
metadata: {}
|
26
28
|
post_install_message:
|
27
29
|
rdoc_options: []
|