japan_etc 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/database/japan_etc_tollbooths.csv +2681 -2681
- data/lib/japan_etc/database.rb +1 -1
- data/lib/japan_etc/road.rb +10 -0
- data/lib/japan_etc/tollbooth.rb +28 -1
- data/lib/japan_etc/version.rb +1 -1
- metadata +2 -2
data/lib/japan_etc/database.rb
CHANGED
data/lib/japan_etc/road.rb
CHANGED
@@ -5,6 +5,7 @@ require 'japan_etc/util'
|
|
5
5
|
|
6
6
|
module JapanETC
|
7
7
|
Road = Struct.new(:name, :route_name) do
|
8
|
+
include Comparable
|
8
9
|
include Util
|
9
10
|
|
10
11
|
IRREGULAR_ABBREVIATIONS = {
|
@@ -49,5 +50,14 @@ module JapanETC
|
|
49
50
|
|
50
51
|
abbreviation
|
51
52
|
end
|
53
|
+
|
54
|
+
def <=>(other)
|
55
|
+
[:name, :route_name].each do |attribute|
|
56
|
+
result = send(attribute) <=> other.send(attribute)
|
57
|
+
return result unless result.zero?
|
58
|
+
end
|
59
|
+
|
60
|
+
0
|
61
|
+
end
|
52
62
|
end
|
53
63
|
end
|
data/lib/japan_etc/tollbooth.rb
CHANGED
@@ -8,6 +8,7 @@ require 'japan_etc/util'
|
|
8
8
|
|
9
9
|
module JapanETC
|
10
10
|
class Tollbooth
|
11
|
+
include Comparable
|
11
12
|
include Util
|
12
13
|
|
13
14
|
attr_accessor :identifier, :road, :name, :entrance_or_exit, :direction, :notes
|
@@ -56,6 +57,21 @@ module JapanETC
|
|
56
57
|
identifier.hash
|
57
58
|
end
|
58
59
|
|
60
|
+
def <=>(other)
|
61
|
+
result = identifier <=> other.identifier
|
62
|
+
return result unless result.zero?
|
63
|
+
|
64
|
+
return -1 if !obsolete? && other.obsolete?
|
65
|
+
return 1 if obsolete? && !other.obsolete?
|
66
|
+
|
67
|
+
[:road, :name].each do |attribute|
|
68
|
+
result = send(attribute) <=> other.send(attribute)
|
69
|
+
return result unless result.zero?
|
70
|
+
end
|
71
|
+
|
72
|
+
0
|
73
|
+
end
|
74
|
+
|
59
75
|
def to_a
|
60
76
|
[
|
61
77
|
identifier.to_s,
|
@@ -67,6 +83,12 @@ module JapanETC
|
|
67
83
|
].flatten
|
68
84
|
end
|
69
85
|
|
86
|
+
def obsolete?
|
87
|
+
notes.any? { |note| note.include?('迄') }
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
70
92
|
def normalize!
|
71
93
|
extract_notes_from_name!
|
72
94
|
extract_direction_from_notes!
|
@@ -180,6 +202,7 @@ module JapanETC
|
|
180
202
|
end
|
181
203
|
|
182
204
|
Identifier = Struct.new(:road_number, :tollbooth_number) do
|
205
|
+
include Comparable
|
183
206
|
include Util
|
184
207
|
|
185
208
|
def initialize(road_number, tollbooth_number)
|
@@ -195,7 +218,11 @@ module JapanETC
|
|
195
218
|
end
|
196
219
|
|
197
220
|
def to_s
|
198
|
-
format('%02d-%03d', road_number, tollbooth_number)
|
221
|
+
@string ||= format('%02d-%03d', road_number, tollbooth_number)
|
222
|
+
end
|
223
|
+
|
224
|
+
def <=>(other)
|
225
|
+
to_s <=> other.to_s
|
199
226
|
end
|
200
227
|
end
|
201
228
|
end
|
data/lib/japan_etc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: japan_etc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|