multicity 1.2.0 → 1.3.0
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.
- data/lib/multicity/multicity_agent.rb +23 -3
- data/lib/multicity/multicity_spot.rb +18 -0
- data/lib/multicity/version.rb +1 -1
- data/lib/multicity.rb +1 -0
- metadata +12 -11
@@ -3,7 +3,8 @@ module Multicity
|
|
3
3
|
|
4
4
|
@@options = {
|
5
5
|
:url_list => 'https://kunden.multicity-carsharing.de/kundenbuchung/hal2ajax_process.php?zoom=10&lng1=&lat1=&lng2=&lat2=&stadtCache=&mapstation_id=&mapstadt_id=&verwaltungfirma=¢erLng=13.382322739257802¢erLat=52.50734843957503&searchmode=buchanfrage&with_staedte=false&buchungsanfrage=N&lat=52.50734843957503&lng=13.382322739257802&instant_access=J&open_end=J&objectname=multicitymarker&ignore_virtual_stations=J&before=null&after=null&ajxmod=hal2map&callee=getMarker',
|
6
|
-
:url_area => 'https://www.multicity-carsharing.de/wp-content/plugins/multicity_map/geschaeftsbereich.kml'
|
6
|
+
:url_area => 'https://www.multicity-carsharing.de/wp-content/plugins/multicity_map/geschaeftsbereich.kml',
|
7
|
+
:url_load_stations => 'https://www.multicity-carsharing.de/rwe/json.php'
|
7
8
|
}
|
8
9
|
|
9
10
|
# Set the user agent
|
@@ -43,17 +44,24 @@ module Multicity
|
|
43
44
|
coords
|
44
45
|
end
|
45
46
|
|
47
|
+
def get_loading_spots
|
48
|
+
data = @agent.get(@@options[:url_load_stations]).body
|
49
|
+
data = encode data
|
50
|
+
marker = JSON.parse(data)
|
51
|
+
marker["marker"].map! {|item| Spot.new(item)}
|
52
|
+
end
|
53
|
+
|
46
54
|
def self.price duration, rate = :starter
|
47
55
|
duration = duration.to_f
|
48
56
|
rate = rate == :vielnutzer ? 2.0 : 2.5
|
49
57
|
if duration > 1440.0
|
50
58
|
price = (duration / 1440.0).floor * 39.00
|
51
|
-
price += (duration % 1440.0) / 10 * rate
|
59
|
+
price += (duration % 1440.0) / 10.0 * rate
|
52
60
|
else
|
53
61
|
price = (duration / 10.0).ceil * rate
|
54
62
|
end
|
55
63
|
|
56
|
-
{:price => price.round(2), :unit => 'EUR', :rate => rate }
|
64
|
+
{:price => price.to_f.round(2), :unit => 'EUR', :rate => rate }
|
57
65
|
end
|
58
66
|
|
59
67
|
private
|
@@ -64,5 +72,17 @@ module Multicity
|
|
64
72
|
"accept-charset" => "utf-8"
|
65
73
|
}
|
66
74
|
end
|
75
|
+
|
76
|
+
#######################################################
|
77
|
+
private
|
78
|
+
#######################################################
|
79
|
+
|
80
|
+
def encode str
|
81
|
+
if str.respond_to? :encode
|
82
|
+
str.force_encoding("iso-8859-1").encode("utf-8")
|
83
|
+
else
|
84
|
+
Iconv.conv("utf-8", "iso-8859-1", str)
|
85
|
+
end
|
86
|
+
end
|
67
87
|
end
|
68
88
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Multicity
|
2
|
+
class Spot
|
3
|
+
attr_accessor :lat, :lon, :name, :address, :city, :capacity, :free
|
4
|
+
|
5
|
+
def initialize json={}
|
6
|
+
self.lat = json["lat"]
|
7
|
+
self.lon = json["lng"]
|
8
|
+
info = json["hal2option"]["markerInfo"] || {"address" => {}}
|
9
|
+
self.name = info["name"]
|
10
|
+
self.capacity = info["capacity"]
|
11
|
+
self.free = info["free"]
|
12
|
+
addr = info["address"]
|
13
|
+
self.city = addr["city"]
|
14
|
+
self.address = "#{addr['streetName']} #{addr['houseNumber']}, #{addr['postalCode']} #{addr['city']}"
|
15
|
+
self.address += " #{addr['freeText']}" unless addr['freeText'].to_s.empty?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/multicity/version.rb
CHANGED
data/lib/multicity.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multicity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &13282000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.6'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13282000
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mechanize
|
27
|
-
requirement: &
|
27
|
+
requirement: &13281620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13281620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: xml-simple
|
38
|
-
requirement: &
|
38
|
+
requirement: &13281160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13281160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &13280640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *13280640
|
58
58
|
description: Wraps the Multicity JSON to use it nicely in your own environment. You
|
59
59
|
can use this Gem to read all cars that are available.
|
60
60
|
email: github@simonwoker.de
|
@@ -64,6 +64,7 @@ extra_rdoc_files: []
|
|
64
64
|
files:
|
65
65
|
- lib/multicity/multicity_agent.rb
|
66
66
|
- lib/multicity/multicity_car.rb
|
67
|
+
- lib/multicity/multicity_spot.rb
|
67
68
|
- lib/multicity/version.rb
|
68
69
|
- lib/multicity.rb
|
69
70
|
- LICENSE
|
@@ -83,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
84
|
version: '0'
|
84
85
|
segments:
|
85
86
|
- 0
|
86
|
-
hash:
|
87
|
+
hash: -1799344324344999223
|
87
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
89
|
none: false
|
89
90
|
requirements:
|