aixm 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +14 -0
- data/README.md +3 -1
- data/lib/aixm/a.rb +29 -15
- data/lib/aixm/association.rb +2 -1
- data/lib/aixm/classes.rb +4 -0
- data/lib/aixm/component/address.rb +15 -9
- data/lib/aixm/component/approach_lighting.rb +28 -25
- data/lib/aixm/component/fato.rb +38 -26
- data/lib/aixm/component/frequency.rb +32 -20
- data/lib/aixm/component/geometry/arc.rb +16 -3
- data/lib/aixm/component/geometry/border.rb +8 -1
- data/lib/aixm/component/geometry/circle.rb +14 -2
- data/lib/aixm/component/geometry/point.rb +8 -1
- data/lib/aixm/component/geometry/rhumb_line.rb +8 -1
- data/lib/aixm/component/geometry.rb +20 -10
- data/lib/aixm/component/helipad.rb +41 -20
- data/lib/aixm/component/layer.rb +31 -20
- data/lib/aixm/component/lighting.rb +22 -24
- data/lib/aixm/component/runway.rb +32 -25
- data/lib/aixm/component/service.rb +11 -17
- data/lib/aixm/component/surface.rb +47 -14
- data/lib/aixm/component/timesheet.rb +178 -0
- data/lib/aixm/component/timetable.rb +32 -13
- data/lib/aixm/component/vasis.rb +36 -6
- data/lib/aixm/component/vertical_limit.rb +26 -4
- data/lib/aixm/component.rb +4 -1
- data/lib/aixm/concerns/hash_equality.rb +21 -0
- data/lib/aixm/concerns/intensity.rb +30 -0
- data/lib/aixm/concerns/marking.rb +21 -0
- data/lib/aixm/concerns/remarks.rb +21 -0
- data/lib/aixm/concerns/timetable.rb +22 -0
- data/lib/aixm/d.rb +20 -14
- data/lib/aixm/document.rb +22 -5
- data/lib/aixm/f.rb +29 -17
- data/lib/aixm/feature/airport.rb +91 -45
- data/lib/aixm/feature/airspace.rb +28 -5
- data/lib/aixm/feature/navigational_aid/designated_point.rb +8 -1
- data/lib/aixm/feature/navigational_aid/dme.rb +12 -2
- data/lib/aixm/feature/navigational_aid/marker.rb +9 -2
- data/lib/aixm/feature/navigational_aid/ndb.rb +15 -3
- data/lib/aixm/feature/navigational_aid/vor.rb +20 -3
- data/lib/aixm/feature/navigational_aid.rb +29 -20
- data/lib/aixm/feature/obstacle.rb +105 -29
- data/lib/aixm/feature/obstacle_group.rb +3 -7
- data/lib/aixm/feature/organisation.rb +23 -14
- data/lib/aixm/feature/unit.rb +23 -11
- data/lib/aixm/feature.rb +23 -4
- data/lib/aixm/memoize.rb +3 -3
- data/lib/aixm/p.rb +20 -14
- data/lib/aixm/payload_hash.rb +5 -2
- data/lib/aixm/r.rb +15 -12
- data/lib/aixm/refinements.rb +42 -2
- data/lib/aixm/schedule/date.rb +181 -0
- data/lib/aixm/schedule/day.rb +114 -0
- data/lib/aixm/schedule/time.rb +255 -0
- data/lib/aixm/shortcuts.rb +3 -0
- data/lib/aixm/version.rb +1 -1
- data/lib/aixm/w.rb +20 -13
- data/lib/aixm/xy.rb +36 -25
- data/lib/aixm/z.rb +29 -17
- data/lib/aixm.rb +13 -0
- data.tar.gz.sig +0 -0
- metadata +22 -13
- metadata.gz.sig +0 -0
@@ -0,0 +1,178 @@
|
|
1
|
+
using AIXM::Refinements
|
2
|
+
|
3
|
+
module AIXM
|
4
|
+
class Component
|
5
|
+
|
6
|
+
# Timesheets define customized activity time windows.
|
7
|
+
#
|
8
|
+
# AIXM supports only yearless dates whereas OFMX extends the model to
|
9
|
+
# accommodate years as well, therefore, the year part is ignored for AIXM.
|
10
|
+
#
|
11
|
+
# ===Cheat Sheat in Pseudo Code:
|
12
|
+
# timesheet = AIXM.timesheet(
|
13
|
+
# adjust_to_dst: Boolean
|
14
|
+
# dates: (AIXM.date..AIXM.date)
|
15
|
+
# days: (AIXM.day..AIXM..day) # either: range of days
|
16
|
+
# day: AIXM.day (default: :any) # or: single day
|
17
|
+
# )
|
18
|
+
# timesheet.times = (AIXM.time..AIXM_time)
|
19
|
+
#
|
20
|
+
# @see https://gitlab.com/openflightmaps/ofmx/-/wikis/Timetable#custom-timetable
|
21
|
+
class Timesheet < Component
|
22
|
+
|
23
|
+
DAYS = {
|
24
|
+
MON: :monday,
|
25
|
+
TUE: :tuesday,
|
26
|
+
WED: :wednesday,
|
27
|
+
THU: :thursday,
|
28
|
+
FRI: :friday,
|
29
|
+
SAT: :saturday,
|
30
|
+
SUN: :sunday,
|
31
|
+
WD: :workday,
|
32
|
+
PWD: :day_preceding_workday,
|
33
|
+
AWD: :day_following_workday,
|
34
|
+
LH: :holiday,
|
35
|
+
PLH: :day_preceding_holiday,
|
36
|
+
ALH: :day_following_holiday,
|
37
|
+
ANY: :any
|
38
|
+
}
|
39
|
+
|
40
|
+
EVENTS = {
|
41
|
+
SR: :sunrise,
|
42
|
+
SS: :sunset
|
43
|
+
}
|
44
|
+
|
45
|
+
PRECEDENCES = {
|
46
|
+
E: :first,
|
47
|
+
L: :last
|
48
|
+
}
|
49
|
+
|
50
|
+
# Range of schedule dates for which this timesheet is active.
|
51
|
+
#
|
52
|
+
# @note Neither open beginning nor open ending is allowed.
|
53
|
+
#
|
54
|
+
# @overload dates
|
55
|
+
# @return [Range<AIXM::Schedule::Date>]
|
56
|
+
# @overload dates=(value)
|
57
|
+
# @param value [Range<AIXM::Schedule::Date>] range of schedule dates
|
58
|
+
# either all with year or all yearless
|
59
|
+
attr_reader :dates
|
60
|
+
|
61
|
+
# Day or days for which this timesheet is active.
|
62
|
+
#
|
63
|
+
# @note Neither open beginning nor open ending is allowed.
|
64
|
+
#
|
65
|
+
# @overload day
|
66
|
+
# @return [AIXM::Schedule::Day]
|
67
|
+
# @overload days
|
68
|
+
# @return [Range<AIXM::Schedule::Day>]
|
69
|
+
# @overload day=(value)
|
70
|
+
# @param value [AIXM::Schedule::Day] schedule day
|
71
|
+
# @overload days=(value)
|
72
|
+
# @param value [Range<AIXM::Schedule::Day>] range of schedule days
|
73
|
+
attr_reader :days
|
74
|
+
|
75
|
+
# Range of schedule times for which this timesheet is active.
|
76
|
+
#
|
77
|
+
# @note Either open beginning or open ending is allowed.
|
78
|
+
#
|
79
|
+
# @overload times
|
80
|
+
# @return [Range<AIXM::Schedule::Time>, nil] range of schedule times
|
81
|
+
# @overload times=(value)
|
82
|
+
# @param value [Range<AIXM::Schedule::Time>, nil] range of schedule times
|
83
|
+
attr_reader :times
|
84
|
+
|
85
|
+
# See the {cheat sheet}[AIXM::Component::Timesheet] for examples on how to
|
86
|
+
# create instances of this class.
|
87
|
+
def initialize(adjust_to_dst:, dates:, days: nil, day: AIXM::ANY_DAY)
|
88
|
+
self.adjust_to_dst, self.dates = adjust_to_dst, dates
|
89
|
+
if days
|
90
|
+
self.days = days
|
91
|
+
else
|
92
|
+
self.day = day
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [String]
|
97
|
+
def inspect
|
98
|
+
%Q(#<#{self.class} dates=#{dates.inspect}>)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Whether to adjust to dayight savings time.
|
102
|
+
#
|
103
|
+
# @note See the {OFMX docs}[https://gitlab.com/openflightmaps/ofmx/-/wikis/Timetable#custom-timetable]
|
104
|
+
# for how exactly this affects dates and times.
|
105
|
+
#
|
106
|
+
# @!attribute adjust_to_dst
|
107
|
+
# @overload adjust_to_dst?
|
108
|
+
# @return [Boolean]
|
109
|
+
# @overload adjust_to_dst=(value)
|
110
|
+
# @param value [Boolean]
|
111
|
+
def adjust_to_dst?
|
112
|
+
@adjust_to_dst
|
113
|
+
end
|
114
|
+
|
115
|
+
def adjust_to_dst=(value)
|
116
|
+
fail(ArgumentError, "invalid adjust_to_dst") unless [true, false].include? value
|
117
|
+
@adjust_to_dst = value
|
118
|
+
end
|
119
|
+
|
120
|
+
def dates=(value)
|
121
|
+
fail(ArgumentError, 'invalid dates') unless value.instance_of?(Range) && value.begin && value.end
|
122
|
+
@dates = value
|
123
|
+
end
|
124
|
+
|
125
|
+
def days=(value)
|
126
|
+
fail(ArgumentError, 'invalid days') unless value.instance_of?(Range) && value.begin && value.end
|
127
|
+
@days = value
|
128
|
+
end
|
129
|
+
|
130
|
+
def times=(value)
|
131
|
+
fail(ArgumentError, 'invalid times') unless value.nil? || (value.instance_of?(Range) && value.begin && value.end)
|
132
|
+
@times = value
|
133
|
+
end
|
134
|
+
|
135
|
+
def day
|
136
|
+
@days unless @days.instance_of? Range
|
137
|
+
end
|
138
|
+
|
139
|
+
def day=(value)
|
140
|
+
fail(ArgumentError, 'invalid day') unless value.instance_of? AIXM::Schedule::Day
|
141
|
+
@days = value
|
142
|
+
end
|
143
|
+
|
144
|
+
# @return [String] AIXM or OFMX markup
|
145
|
+
def to_xml
|
146
|
+
builder = Builder::XmlMarkup.new(indent: 2)
|
147
|
+
builder.Timsh do |timsh|
|
148
|
+
timsh.codeTimeRef(adjust_to_dst? ? 'UTCW' : 'UTC')
|
149
|
+
timsh.dateValidWef(dates.begin.to_s('%d-%m'))
|
150
|
+
timsh.dateYearValidWef(dates.begin.year) if AIXM.ofmx? && !dates.begin.yearless?
|
151
|
+
timsh.dateValidTil(dates.end.to_s('%d-%m'))
|
152
|
+
timsh.dateYearValidTil(dates.end.year) if AIXM.ofmx? && !dates.end.yearless?
|
153
|
+
if days.instance_of? Range
|
154
|
+
timsh.codeDay(DAYS.key(days.begin.day).to_s)
|
155
|
+
timsh.codeDayTil(DAYS.key(days.end.day).to_s)
|
156
|
+
else
|
157
|
+
timsh.codeDay(DAYS.key(days.day).to_s)
|
158
|
+
end
|
159
|
+
if times
|
160
|
+
if times.begin
|
161
|
+
timsh.timeWef(times.begin.to_s('%R'))
|
162
|
+
timsh.codeEventWef(EVENTS.key(times.begin.event).to_s) if times.begin.event
|
163
|
+
timsh.timeRelEventWef(times.begin.delta) unless times.begin.delta.zero?
|
164
|
+
timsh.codeCombWef(PRECEDENCES.key(times.begin.precedence).to_s) if times.begin.precedence
|
165
|
+
end
|
166
|
+
if times.end
|
167
|
+
timsh.timeTil(times.end.to_s('%R'))
|
168
|
+
timsh.codeEventTil(EVENTS.key(times.end.event).to_s) if times.end.event
|
169
|
+
timsh.timeRelEventTil(times.end.delta) unless times.end.delta.zero?
|
170
|
+
timsh.codeCombTil(PRECEDENCES.key(times.end.precedence).to_s) if times.end.precedence
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
@@ -5,12 +5,11 @@ module AIXM
|
|
5
5
|
|
6
6
|
# Timetables define activity time windows.
|
7
7
|
#
|
8
|
-
# @note As of now, only predefined timetables (see {CODES}) are imlemented.
|
9
|
-
#
|
10
8
|
# ===Cheat Sheat in Pseudo Code:
|
11
9
|
# timetable = AIXM.timetable(
|
12
|
-
# code: String or Symbol
|
10
|
+
# code: String or Symbol (default: :timesheet)
|
13
11
|
# )
|
12
|
+
# timetable.add_timesheet(AIXM.timesheet)
|
14
13
|
# timetable.remarks = String or nil
|
15
14
|
#
|
16
15
|
# ===Shortcuts:
|
@@ -19,7 +18,11 @@ module AIXM
|
|
19
18
|
#
|
20
19
|
# @see https://gitlab.com/openflightmaps/ofmx/wikis/Timetable#predefined-timetable
|
21
20
|
class Timetable < Component
|
21
|
+
include AIXM::Association
|
22
|
+
include AIXM::Concerns::Remarks
|
23
|
+
|
22
24
|
CODES = {
|
25
|
+
TIMSH: :timesheet, # attached timesheet
|
23
26
|
H24: :continuous, # all day and all night
|
24
27
|
HJ: :sunrise_to_sunset, # all day
|
25
28
|
HN: :sunset_to_sunrise, # all night
|
@@ -29,13 +32,19 @@ module AIXM
|
|
29
32
|
OTHER: :other # specify in remarks
|
30
33
|
}.freeze
|
31
34
|
|
32
|
-
#
|
33
|
-
|
35
|
+
# @!method timesheets
|
36
|
+
# @return [Array<AIXM::Component::Timesheet>] timesheets attached to
|
37
|
+
# this timetable
|
38
|
+
#
|
39
|
+
# @!method add_timesheet(timesheet)
|
40
|
+
# @note The {#code} is forced to +:timesheet+ once at least one timesheet
|
41
|
+
# has been added.
|
42
|
+
# @param timesheet [AIXM::Component::Timesheet]
|
43
|
+
has_many :timesheets
|
34
44
|
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
def initialize(code:)
|
45
|
+
# See the {cheat sheet}[AIXM::Component::Timetable] for examples on how to
|
46
|
+
# create instances of this class.
|
47
|
+
def initialize(code: :timesheet)
|
39
48
|
self.code = code
|
40
49
|
end
|
41
50
|
|
@@ -44,21 +53,31 @@ module AIXM
|
|
44
53
|
%Q(#<#{self.class} code=#{code.inspect}>)
|
45
54
|
end
|
46
55
|
|
56
|
+
# Timetable code
|
57
|
+
#
|
58
|
+
# @!attribute code
|
59
|
+
# @overload code
|
60
|
+
# @return [Symbol] any of {CODES}
|
61
|
+
# @overload code=(value)
|
62
|
+
# @param value [Symbol] any of {CODES}
|
63
|
+
def code
|
64
|
+
timesheets.any? ? :timesheet : @code
|
65
|
+
end
|
66
|
+
|
47
67
|
def code=(value)
|
48
68
|
@code = if value
|
49
69
|
CODES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid code")
|
50
70
|
end
|
51
71
|
end
|
52
72
|
|
53
|
-
def remarks=(value)
|
54
|
-
@remarks = value&.to_s
|
55
|
-
end
|
56
|
-
|
57
73
|
# @return [String] AIXM or OFMX markup
|
58
74
|
def to_xml(as: :Timetable)
|
59
75
|
builder = Builder::XmlMarkup.new(indent: 2)
|
60
76
|
builder.tag!(as) do |tag|
|
61
77
|
tag.codeWorkHr(CODES.key(code).to_s)
|
78
|
+
timesheets.each do |timesheet|
|
79
|
+
tag << timesheet.to_xml.indent(2)
|
80
|
+
end
|
62
81
|
tag.txtRmkWorkHr(remarks) if remarks
|
63
82
|
end
|
64
83
|
end
|
data/lib/aixm/component/vasis.rb
CHANGED
@@ -35,22 +35,52 @@ module AIXM
|
|
35
35
|
OTHER: :other # specify in remarks
|
36
36
|
}.freeze
|
37
37
|
|
38
|
-
#
|
38
|
+
# Type of VASIS.
|
39
|
+
#
|
40
|
+
# @overload type
|
41
|
+
# @return [Symbol, nil] any of {TYPES}
|
42
|
+
# @overload type=(value)
|
43
|
+
# @param value [Symbol, nil] any of {TYPES}
|
39
44
|
attr_reader :type
|
40
45
|
|
41
|
-
#
|
46
|
+
# Position relative to the runway.
|
47
|
+
#
|
48
|
+
# @overload position
|
49
|
+
# @return [Symbol, nil] any of {POSITIONS}
|
50
|
+
# @overload position=(value)
|
51
|
+
# @param value [Symbol, nil] any of {POSITIONS}
|
42
52
|
attr_reader :position
|
43
53
|
|
44
|
-
#
|
54
|
+
# Number of boxes.
|
55
|
+
#
|
56
|
+
# @overload boxes
|
57
|
+
# @return [Integer, nil]
|
58
|
+
# @overload boxes=(value)
|
59
|
+
# @param value [Integer, nil]
|
45
60
|
attr_reader :boxes
|
46
61
|
|
47
|
-
#
|
62
|
+
# Whether the VASIS is portable.
|
63
|
+
#
|
64
|
+
# @overload portable
|
65
|
+
# @return [Boolean, nil] +nil+ means unknown
|
66
|
+
# @overload portable=(value)
|
67
|
+
# @param value [Boolean, nil] +nil+ means unknown
|
48
68
|
attr_reader :portable
|
49
69
|
|
50
|
-
#
|
70
|
+
# Appropriate approach slope angle.
|
71
|
+
#
|
72
|
+
# @overload slope_angle
|
73
|
+
# @return [AIXM::A, nil]
|
74
|
+
# @overload slope_angle=(value)
|
75
|
+
# @param value [AIXM::A, nil]
|
51
76
|
attr_reader :slope_angle
|
52
77
|
|
53
|
-
#
|
78
|
+
# Minimum eye height over threshold.
|
79
|
+
#
|
80
|
+
# @overload meht
|
81
|
+
# @return [AIXM::Z, nil]
|
82
|
+
# @overload meht=(value)
|
83
|
+
# @param value [AIXM::Z, nil]
|
54
84
|
attr_reader :meht
|
55
85
|
|
56
86
|
# @return [String]
|
@@ -38,18 +38,40 @@ module AIXM
|
|
38
38
|
# @return [AIXM::Component::Layer] layer to which this vertical limit applies
|
39
39
|
belongs_to :layer
|
40
40
|
|
41
|
-
#
|
41
|
+
# Upper limit
|
42
|
+
#
|
43
|
+
# @overload upper_z
|
44
|
+
# @return [AIXM::Z]
|
45
|
+
# @overload upper_z=(value)
|
46
|
+
# @param value [AIXM::Z]
|
42
47
|
attr_reader :upper_z
|
43
48
|
|
44
|
-
#
|
49
|
+
# Lower limit
|
50
|
+
#
|
51
|
+
# @overload lower_z
|
52
|
+
# @return [AIXM::Z]
|
53
|
+
# @overload lower_z=(value)
|
54
|
+
# @param value [AIXM::Z]
|
45
55
|
attr_reader :lower_z
|
46
56
|
|
47
|
-
#
|
57
|
+
# Alternative upper limit ("whichever is higher")
|
58
|
+
#
|
59
|
+
# @overload max_z
|
60
|
+
# @return [AIXM::Z, nil]
|
61
|
+
# @overload max_z=(value)
|
62
|
+
# @param value [AIXM::Z, nil]
|
48
63
|
attr_reader :max_z
|
49
64
|
|
50
|
-
#
|
65
|
+
# Alternative lower limit ("whichever is lower")
|
66
|
+
#
|
67
|
+
# @overload min_z
|
68
|
+
# @return [AIXM::Z, nil]
|
69
|
+
# @overload min_z=(value)
|
70
|
+
# @param value [AIXM::Z, nil]
|
51
71
|
attr_reader :min_z
|
52
72
|
|
73
|
+
# See the {cheat sheet}[AIXM::Component::VerticalLimit] for examples on
|
74
|
+
# how to create instances of this class.
|
53
75
|
def initialize(upper_z:, max_z: nil, lower_z:, min_z: nil)
|
54
76
|
self.upper_z, self.max_z, self.lower_z, self.min_z = upper_z, max_z, lower_z, min_z
|
55
77
|
end
|
data/lib/aixm/component.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
using AIXM::Refinements
|
2
|
+
|
3
|
+
module AIXM
|
4
|
+
module Concerns
|
5
|
+
|
6
|
+
# Implements Hash equality
|
7
|
+
module HashEquality
|
8
|
+
|
9
|
+
# @see Object#hash
|
10
|
+
def hash
|
11
|
+
[self.__class__, to_s].hash
|
12
|
+
end
|
13
|
+
|
14
|
+
# @see Object#eql?
|
15
|
+
def eql?(other)
|
16
|
+
hash == other.hash
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
using AIXM::Refinements
|
2
|
+
|
3
|
+
module AIXM
|
4
|
+
module Concerns
|
5
|
+
|
6
|
+
# Adds optional intensity of lights to features.
|
7
|
+
module Intensity
|
8
|
+
|
9
|
+
INTENSITIES = {
|
10
|
+
LIL: :low,
|
11
|
+
LIM: :medium,
|
12
|
+
LIH: :high,
|
13
|
+
OTHER: :other # specify in remarks
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
# Intensity of lights
|
17
|
+
#
|
18
|
+
# @overload remarks
|
19
|
+
# @return [AIXM::Component::Timetable, nil] any of {INTENSITIES}
|
20
|
+
# @overload remarks=(value)
|
21
|
+
# @param value [AIXM::Component::Timetable, nil] any of {INTENSITIES}
|
22
|
+
attr_reader :intensity
|
23
|
+
|
24
|
+
def intensity=(value)
|
25
|
+
@intensity = value.nil? ? nil : INTENSITIES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid intensity")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AIXM
|
2
|
+
module Concerns
|
3
|
+
|
4
|
+
# Adds optional markings to features.
|
5
|
+
module Marking
|
6
|
+
|
7
|
+
# Markings
|
8
|
+
#
|
9
|
+
# @overload remarks
|
10
|
+
# @return [String, nil]
|
11
|
+
# @overload remarks=(value)
|
12
|
+
# @param value [String, nil]
|
13
|
+
attr_reader :marking
|
14
|
+
|
15
|
+
def marking=(value)
|
16
|
+
@marking = value&.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module AIXM
|
2
|
+
module Concerns
|
3
|
+
|
4
|
+
# Adds optional free text remarks to features.
|
5
|
+
module Remarks
|
6
|
+
|
7
|
+
# Free text remarks
|
8
|
+
#
|
9
|
+
# @overload remarks
|
10
|
+
# @return [String, nil]
|
11
|
+
# @overload remarks=(value)
|
12
|
+
# @param value [String, nil]
|
13
|
+
attr_reader :remarks
|
14
|
+
|
15
|
+
def remarks=(value)
|
16
|
+
@remarks = value&.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module AIXM
|
2
|
+
module Concerns
|
3
|
+
|
4
|
+
# Adds optional timetable to features.
|
5
|
+
module Timetable
|
6
|
+
|
7
|
+
# Operating hours
|
8
|
+
#
|
9
|
+
# @overload remarks
|
10
|
+
# @return [AIXM::Component::Timetable, nil]
|
11
|
+
# @overload remarks=(value)
|
12
|
+
# @param value [AIXM::Component::Timetable, nil]
|
13
|
+
attr_reader :timetable
|
14
|
+
|
15
|
+
def timetable=(value)
|
16
|
+
fail(ArgumentError, "invalid timetable") unless value.nil? || value.is_a?(AIXM::Component::Timetable)
|
17
|
+
@timetable = value
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/aixm/d.rb
CHANGED
@@ -7,6 +7,7 @@ module AIXM
|
|
7
7
|
# @example
|
8
8
|
# AIXM.d(123, :m)
|
9
9
|
class D
|
10
|
+
include AIXM::Concerns::HashEquality
|
10
11
|
include Comparable
|
11
12
|
extend Forwardable
|
12
13
|
|
@@ -17,16 +18,29 @@ module AIXM
|
|
17
18
|
nm: { ft: 6076.11548554, km: 1.852, m: 1852 }
|
18
19
|
}.freeze
|
19
20
|
|
21
|
+
# Whether dimension is zero.
|
22
|
+
#
|
20
23
|
# @!method zero?
|
21
|
-
#
|
24
|
+
# @return [Boolean]
|
22
25
|
def_delegator :@dim, :zero?
|
23
26
|
|
24
|
-
#
|
27
|
+
# Dimension
|
28
|
+
#
|
29
|
+
# @overload dim
|
30
|
+
# @return [Float]
|
31
|
+
# @overload dim=(value)
|
32
|
+
# @param value [Float]
|
25
33
|
attr_reader :dim
|
26
34
|
|
27
|
-
#
|
35
|
+
# Unit
|
36
|
+
#
|
37
|
+
# @overload unit
|
38
|
+
# @return [Symbol] any of {UNITS}
|
39
|
+
# @overload unit=(value)
|
40
|
+
# @param value [Symbol] any of {UNITS}
|
28
41
|
attr_reader :unit
|
29
42
|
|
43
|
+
# See the {overview}[AIXM::D] for examples.
|
30
44
|
def initialize(dim, unit)
|
31
45
|
self.dim, self.unit = dim, unit
|
32
46
|
end
|
@@ -52,12 +66,13 @@ module AIXM
|
|
52
66
|
fail(ArgumentError, "invalid unit") unless UNITS.has_key? @unit
|
53
67
|
end
|
54
68
|
|
69
|
+
# Convert dimension
|
70
|
+
#
|
55
71
|
# @!method to_ft
|
56
72
|
# @!method to_km
|
57
73
|
# @!method to_m
|
58
74
|
# @!method to_nm
|
59
|
-
#
|
60
|
-
# @return [AIXM::D] convert dimension
|
75
|
+
# @return [AIXM::D] converted dimension
|
61
76
|
UNITS.each_key do |target_unit|
|
62
77
|
define_method "to_#{target_unit}" do
|
63
78
|
return self if unit == target_unit
|
@@ -66,22 +81,13 @@ module AIXM
|
|
66
81
|
end
|
67
82
|
|
68
83
|
# @see Object#<=>
|
69
|
-
# @return [Integer]
|
70
84
|
def <=>(other)
|
71
85
|
dim <=> other.send(:"to_#{unit}").dim
|
72
86
|
end
|
73
87
|
|
74
88
|
# @see Object#==
|
75
|
-
# @return [Boolean]
|
76
89
|
def ==(other)
|
77
90
|
self.class === other && (self <=> other).zero?
|
78
91
|
end
|
79
|
-
alias_method :eql?, :==
|
80
|
-
|
81
|
-
# @see Object#hash
|
82
|
-
# @return [Integer]
|
83
|
-
def hash
|
84
|
-
to_s.hash
|
85
|
-
end
|
86
92
|
end
|
87
93
|
end
|
data/lib/aixm/document.rb
CHANGED
@@ -28,15 +28,32 @@ module AIXM
|
|
28
28
|
# @return [self]
|
29
29
|
has_many :features, accept: ['AIXM::Feature']
|
30
30
|
|
31
|
-
#
|
31
|
+
# UUID to namespace the data contained in this document
|
32
|
+
#
|
33
|
+
# @overload namespace
|
34
|
+
# @return [String]
|
35
|
+
# @overload namespace=(value)
|
36
|
+
# @param value [String]
|
32
37
|
attr_reader :namespace
|
33
38
|
|
34
|
-
#
|
39
|
+
# Creation date and time
|
40
|
+
#
|
41
|
+
# @overload created_at
|
42
|
+
# @return [Time]
|
43
|
+
# @overload created_at=(value)
|
44
|
+
# @param value [Time] default: {#effective_at} or now
|
35
45
|
attr_reader :created_at
|
36
46
|
|
37
|
-
#
|
47
|
+
# Effective after date and time
|
48
|
+
#
|
49
|
+
# @overload effective_at
|
50
|
+
# @return [Time]
|
51
|
+
# @overload effective_at=(value)
|
52
|
+
# @param value [Time] default: {#created_at} or now
|
38
53
|
attr_reader :effective_at
|
39
54
|
|
55
|
+
# See the {cheat sheet}[AIXM::Document] for examples on how to create
|
56
|
+
# instances of this class.
|
40
57
|
def initialize(namespace: nil, created_at: nil, effective_at: nil)
|
41
58
|
self.namespace, self.created_at, self.effective_at = namespace, created_at, effective_at
|
42
59
|
end
|
@@ -93,14 +110,14 @@ module AIXM
|
|
93
110
|
end.count
|
94
111
|
end
|
95
112
|
|
96
|
-
# Validate the generated AIXM or OFMX
|
113
|
+
# Validate the generated AIXM or OFMX against its XSD.
|
97
114
|
#
|
98
115
|
# @return [Boolean] whether valid or not
|
99
116
|
def valid?
|
100
117
|
errors.none?
|
101
118
|
end
|
102
119
|
|
103
|
-
# Validate the generated AIXM or OFMX
|
120
|
+
# Validate the generated AIXM or OFMX against its XSD and return the
|
104
121
|
# errors found.
|
105
122
|
#
|
106
123
|
# @return [Array<String>] validation errors
|