moscow_metro 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Changelog.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +26 -4
- data/lib/db/sources/data-en-2015-11-30.json +4738 -0
- data/lib/db/sources/data-ru-2020-10-26.json +2747 -0
- data/lib/moscow_metro/line.rb +6 -1
- data/lib/moscow_metro/station.rb +37 -22
- data/lib/moscow_metro/version.rb +1 -1
- metadata +5 -3
data/lib/moscow_metro/line.rb
CHANGED
@@ -5,7 +5,6 @@ module MoscowMetro
|
|
5
5
|
|
6
6
|
COLUMNS = [:color, :name, :name_en, :name_prepositional, :open_year, :uid]
|
7
7
|
RECORDS = YAML.load_file(DB_DIR.join("lines.yml"))
|
8
|
-
Record = Struct.new(*COLUMNS)
|
9
8
|
UIDS = {
|
10
9
|
mcd: %w[D1 D2 D3 D4 D5].freeze,
|
11
10
|
mck: %w[14].freeze,
|
@@ -13,6 +12,12 @@ module MoscowMetro
|
|
13
12
|
monorail: %w[13].freeze
|
14
13
|
}
|
15
14
|
|
15
|
+
Record = Struct.new(*COLUMNS) do
|
16
|
+
def stations
|
17
|
+
MoscowMetro::Station.at_lines([uid])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
16
21
|
def self.all
|
17
22
|
RECORDS.map { |record_data| Record.new(*hash_values(COLUMNS, record_data)) }
|
18
23
|
end
|
data/lib/moscow_metro/station.rb
CHANGED
@@ -8,7 +8,7 @@ module MoscowMetro
|
|
8
8
|
|
9
9
|
Record = Struct.new(*COLUMNS) do
|
10
10
|
def coordinates
|
11
|
-
|
11
|
+
[latitude, longitude] if (latitude && longitude)
|
12
12
|
end
|
13
13
|
|
14
14
|
def line
|
@@ -16,33 +16,48 @@ module MoscowMetro
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
RECORDS.map { |record_data| Record.new(*hash_values(COLUMNS, record_data)) }
|
21
|
-
end
|
19
|
+
class << self
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def all
|
22
|
+
RECORDS.map { |record_data| to_record(record_data) }
|
23
|
+
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
def first
|
26
|
+
to_record RECORDS.first
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def last
|
30
|
+
to_record RECORDS.last
|
31
|
+
end
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
def to_record(record_data)
|
34
|
+
Record.new(*hash_values(COLUMNS, record_data))
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
def names
|
38
|
+
all.map(&:name).uniq
|
39
|
+
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
def at_lines(uids)
|
42
|
+
all.select { |station| uids.include? station.line_uid }
|
43
|
+
end
|
44
|
+
|
45
|
+
def at_mcd
|
46
|
+
at_lines Line::UIDS[:mck]
|
47
|
+
end
|
48
|
+
|
49
|
+
def at_mck
|
50
|
+
at_lines Line::UIDS[:mck]
|
51
|
+
end
|
46
52
|
|
53
|
+
def at_metro
|
54
|
+
at_lines Line::UIDS[:metro]
|
55
|
+
end
|
56
|
+
|
57
|
+
def at_monorail
|
58
|
+
at_lines Line::UIDS[:monorail]
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
47
62
|
end
|
48
63
|
end
|
data/lib/moscow_metro/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moscow_metro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Pedan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Database of lines and stations metro & metro-like train transport of
|
14
14
|
Moscow. Can be used as a database alongside a real database or as a source of data
|
@@ -30,6 +30,8 @@ files:
|
|
30
30
|
- bin/console
|
31
31
|
- bin/setup
|
32
32
|
- lib/db/lines.yml
|
33
|
+
- lib/db/sources/data-en-2015-11-30.json
|
34
|
+
- lib/db/sources/data-ru-2020-10-26.json
|
33
35
|
- lib/db/stations.yml
|
34
36
|
- lib/moscow_metro.rb
|
35
37
|
- lib/moscow_metro/line.rb
|
@@ -60,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
62
|
- !ruby/object:Gem::Version
|
61
63
|
version: '0'
|
62
64
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
65
|
+
rubygems_version: 3.2.0
|
64
66
|
signing_key:
|
65
67
|
specification_version: 4
|
66
68
|
summary: Database of lines and stations metro & metro-like train transport of Moscow
|