aixm 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +33 -3
  4. data/README.md +33 -3
  5. data/exe/ckmid +1 -7
  6. data/exe/mkmid +1 -7
  7. data/lib/aixm/a.rb +29 -15
  8. data/lib/aixm/classes.rb +6 -1
  9. data/lib/aixm/component/address.rb +27 -24
  10. data/lib/aixm/component/approach_lighting.rb +39 -41
  11. data/lib/aixm/component/fato.rb +60 -60
  12. data/lib/aixm/component/frequency.rb +42 -35
  13. data/lib/aixm/component/geometry/arc.rb +18 -6
  14. data/lib/aixm/component/geometry/border.rb +14 -11
  15. data/lib/aixm/component/geometry/circle.rb +18 -6
  16. data/lib/aixm/component/geometry/point.rb +12 -5
  17. data/lib/aixm/component/geometry/rhumb_line.rb +12 -5
  18. data/lib/aixm/component/geometry.rb +21 -11
  19. data/lib/aixm/component/helipad.rb +54 -40
  20. data/lib/aixm/component/layer.rb +37 -28
  21. data/lib/aixm/component/lighting.rb +34 -41
  22. data/lib/aixm/component/runway.rb +58 -63
  23. data/lib/aixm/component/service.rb +23 -33
  24. data/lib/aixm/component/surface.rb +55 -24
  25. data/lib/aixm/component/timesheet.rb +177 -0
  26. data/lib/aixm/component/timetable.rb +36 -18
  27. data/lib/aixm/component/vasis.rb +42 -14
  28. data/lib/aixm/component/vertical_limit.rb +34 -12
  29. data/lib/aixm/component.rb +6 -2
  30. data/lib/aixm/concerns/association.rb +381 -0
  31. data/lib/aixm/concerns/hash_equality.rb +21 -0
  32. data/lib/aixm/concerns/intensity.rb +30 -0
  33. data/lib/aixm/concerns/marking.rb +21 -0
  34. data/lib/aixm/concerns/memoize.rb +107 -0
  35. data/lib/aixm/concerns/remarks.rb +21 -0
  36. data/lib/aixm/concerns/timetable.rb +22 -0
  37. data/lib/aixm/concerns/xml_builder.rb +34 -0
  38. data/lib/aixm/d.rb +20 -14
  39. data/lib/aixm/document.rb +72 -24
  40. data/lib/aixm/f.rb +29 -17
  41. data/lib/aixm/feature/airport.rb +135 -92
  42. data/lib/aixm/feature/airspace.rb +55 -39
  43. data/lib/aixm/feature/generic.rb +67 -0
  44. data/lib/aixm/feature/navigational_aid/designated_point.rb +19 -14
  45. data/lib/aixm/feature/navigational_aid/dme.rb +24 -17
  46. data/lib/aixm/feature/navigational_aid/marker.rb +21 -17
  47. data/lib/aixm/feature/navigational_aid/ndb.rb +27 -18
  48. data/lib/aixm/feature/navigational_aid/tacan.rb +15 -17
  49. data/lib/aixm/feature/navigational_aid/vor.rb +36 -22
  50. data/lib/aixm/feature/navigational_aid.rb +36 -27
  51. data/lib/aixm/feature/obstacle.rb +125 -50
  52. data/lib/aixm/feature/obstacle_group.rb +22 -27
  53. data/lib/aixm/feature/organisation.rb +34 -26
  54. data/lib/aixm/feature/unit.rb +39 -29
  55. data/lib/aixm/feature.rb +45 -7
  56. data/lib/aixm/object.rb +1 -1
  57. data/lib/aixm/p.rb +20 -14
  58. data/lib/aixm/payload_hash.rb +5 -2
  59. data/lib/aixm/r.rb +15 -12
  60. data/lib/aixm/refinements.rb +99 -2
  61. data/lib/aixm/schedule/date.rb +181 -0
  62. data/lib/aixm/schedule/day.rb +114 -0
  63. data/lib/aixm/schedule/time.rb +276 -0
  64. data/lib/aixm/shortcuts.rb +3 -0
  65. data/lib/aixm/version.rb +1 -1
  66. data/lib/aixm/w.rb +20 -13
  67. data/lib/aixm/xy.rb +36 -25
  68. data/lib/aixm/z.rb +29 -17
  69. data/lib/aixm.rb +17 -3
  70. data/schemas/ofmx/0.1/OFMX-Snapshot.xsd +6 -1
  71. data.tar.gz.sig +3 -1
  72. metadata +26 -29
  73. metadata.gz.sig +0 -0
  74. data/lib/aixm/association.rb +0 -377
  75. data/lib/aixm/memoize.rb +0 -105
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33661b6ab9022c54a9d41dad531b0f1c53f39eaf053a6c4b8361c50543b9ae01
4
- data.tar.gz: add22919257222a6f06dae9de21f0f71c2b941a67e6bc52dba14bde5fbae6c9a
3
+ metadata.gz: af33154acb182006b0c9f4e048c305b2489cba22d15ee1bc9aa724ddec70ceab
4
+ data.tar.gz: 44c42b5e93537e33cb2623a19a043216853664358d5c616f59aa884ee4c3e80c
5
5
  SHA512:
6
- metadata.gz: c1fb317e1791098f127c769e5f680bbf0c30ab823c73c48f392d6ea918f1ba4c6396d4e5cb43357ef1c867bad73e475d25be95b274bad7fd9ee17ce297dbbb6f
7
- data.tar.gz: 904a2fa5c84b80bf14a67536fa2c0f2ab26b6d34dc3dc789e272116812994f86b9c3aff92b08d1cda9b3d3495abfe990eb922f0579fd779a1602963ba28ded59
6
+ metadata.gz: e960a18401dd58557db667b01cb3f15683728798f3aee736fda794a18519d7b3fb99e0725154a01b564a4e35658cdde5310402fd1c2b6f2e4550880cf47db98b
7
+ data.tar.gz: 2855fb8f01ca9dd515e8c05b60e79d80f4d4af77b48f1b03cc4baaadd1451810b877c92cd9364cb5d84b80f6d99ebda3b8c21d2445143f9d078a9e4e7ef2cc76
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,7 +1,37 @@
1
+ ## Main
2
+
3
+ Nothing so far
4
+
5
+ ## 1.3.0
6
+
7
+ #### Breaking Changes
8
+ * `Document#created_at` no longer falls back to `Document#effective_at`
9
+
10
+ #### Additions
11
+ * Refinement to pretty print Nokogiri XML documents
12
+ * XML comments on features (e.g. to include raw NOTAM)
13
+ * `Document#expiration_at` for OFMX
14
+ * Generic features as raw XML (e.g. extracted from another AIXM/OFMX file)
15
+
16
+ ## 1.2.1
17
+
18
+ #### Additions
19
+ * Rounding of `AIXM::Schedule::Time`
20
+
21
+ ## 1.2.0
22
+
23
+ #### Additions
24
+ * `Timesheet` to add custom schedules to `Timetable`
25
+ * `AIXM::Schedule::(Date|Day|Time)` for custom timetables
26
+ * Interface to allow most class instances as Hash keys
27
+
28
+ #### Fixes
29
+ * Fix typo in `GUESSED_UNIT_TYPES_MAP`
30
+
1
31
  ## 1.1.0
2
32
 
3
33
  #### Breaking Changes
4
- * `AIXM::Association:Array#duplicates` now returns an array of arrays which
34
+ * `AIXM::Concerns::Association:Array#duplicates` now returns an array of arrays which
5
35
  group all duplicates together.
6
36
  * `VOR#associate_dme` and `VOR#associate_tacan` no longer take the channel
7
37
  as argument but calculate it from the (ghost) frequency of the VOR.
@@ -55,10 +85,10 @@
55
85
 
56
86
  #### Additions
57
87
  * Proper `has_many` and `has_one` associations
58
- * `AIXM::Association:Array#find_by|find|duplicates` on `has_many` associations
88
+ * `AIXM::Concerns::Association:Array#find_by|find|duplicates` on `has_many` associations
59
89
  * `AIXM.config.mid` now defines whether `mid` attributes are inserted or not
60
90
  provided the selected schema is OFMX
61
- * `AIXM::Memoize` module
91
+ * `AIXM::Concerns::Memoize` module
62
92
  * `AIXM::PayloadHash` class
63
93
  * `mkmid` executable to insert `mid` attributes into valid OFMX file
64
94
  * `ckmid` executable to check `mid` attributes in an OFMX file
data/README.md CHANGED
@@ -11,7 +11,7 @@ For now, only the parts needed to automize the AIP import of [open flightmaps](h
11
11
 
12
12
  * [Homepage](https://github.com/svoop/aixm)
13
13
  * [API](https://www.rubydoc.info/gems/aixm)
14
- * Author: [Sven Schwyn - Bitcetera](http://www.bitcetera.com)
14
+ * Author: [Sven Schwyn - Bitcetera](https://bitcetera.com)
15
15
 
16
16
  ## Install
17
17
 
@@ -28,7 +28,7 @@ gem cert --add <(curl -Ls https://raw.github.com/svoop/aixm/main/certs/svoop.pem
28
28
  Add the following to the <tt>Gemfile</tt> or <tt>gems.rb</tt> of your [Bundler](https://bundler.io) powered Ruby project:
29
29
 
30
30
  ```ruby
31
- gem aixm
31
+ gem 'aixm'
32
32
  ```
33
33
 
34
34
  And then install the bundle:
@@ -163,6 +163,7 @@ AIXM.config.ignored_errors = /invalid date/i
163
163
  * [Organisation](https://www.rubydoc.info/gems/aixm/AIXM/Feature/Organisation.html)
164
164
  * [Service](https://www.rubydoc.info/gems/aixm/AIXM/Component/Service.html)
165
165
  * [Unit](https://www.rubydoc.info/gems/aixm/AIXM/Feature/Unit.html)
166
+ * [Generic](https://www.rubydoc.info/gems/aixm/AIXM/Feature/Generic.html)
166
167
 
167
168
  ### Components
168
169
 
@@ -182,6 +183,7 @@ AIXM.config.ignored_errors = /invalid date/i
182
183
  * [Service](https://www.rubydoc.info/gems/aixm/AIXM/Component/Service.html)
183
184
  * [Surface](https://www.rubydoc.info/gems/aixm/AIXM/Component/Surface.html)
184
185
  * [Timetable](https://www.rubydoc.info/gems/aixm/AIXM/Component/Timetable.html)
186
+ * [Timesheet](https://www.rubydoc.info/gems/aixm/AIXM/Component/Timesheet.html)
185
187
  * [VASIS](https://www.rubydoc.info/gems/aixm/AIXM/Component/VASIS.html)
186
188
  * [Vertical limit](https://www.rubydoc.info/gems/aixm/AIXM/Component/VerticalLimit.html)
187
189
 
@@ -189,7 +191,7 @@ AIXM.config.ignored_errors = /invalid date/i
189
191
 
190
192
  The different models are interwoven with [`has_many` and `has_one` associations](https://www.rubydoc.info/gems/aixm/AIXM/Association).
191
193
 
192
- Please note that `has_many` associations are instances `AIXM::Association::Array` which mostly behave like normal arrays. However, you must not add or remove elements on the array directly but use the corresponding method on the associating model instead:
194
+ Please note that `has_many` associations are instances `AIXM::Concerns::Association::Array` which mostly behave like normal arrays. However, you must not add or remove elements on the array directly but use the corresponding method on the associating model instead:
193
195
 
194
196
  ```ruby
195
197
  document.features << airport # => NoMethodError
@@ -229,6 +231,33 @@ Equally on `has_many` associations, use `duplicates` to find identical or equal
229
231
  document.features.duplicates # => [#<AIXM::Feature::Unit>, #<AIXM::Component::Service>, ...]
230
232
  ```
231
233
 
234
+ ## XML Comments
235
+
236
+ All features implement the `comment` attribute which accepts any object and converts it `#to_s`. When set, an XML comment is inserted right after the opening tag of the feature. This comes in handy e.g. in case you want to include source data facsimile such as NOTAM. Oneline and multiline comments are inserted differently:
237
+
238
+ ```xml
239
+ <Ase>
240
+ <!--
241
+ B0330/22 NOTAMR B1756/21
242
+ Q) LSAS/QAFLT/V/NBO/E/000/050/4734N00841E005
243
+ A) LSAS B) 2203170746 C) 2206242359 EST
244
+ -->
245
+ <AseUid>
246
+ <codeType>RAS</codeType>
247
+ <codeId>B0330/22</codeId>
248
+ </AseUid>
249
+ (...)
250
+ </Ase>
251
+
252
+ <Org>
253
+ <!-- Generic organisation -->
254
+ <OrgUid>
255
+ <txtName>FRANCE</txtName>
256
+ </OrgUid>
257
+ (...)
258
+ </Org>
259
+ ```
260
+
232
261
  ## Payload Hash
233
262
 
234
263
  OFMX defines a [payload hash function](https://gitlab.com/openflightmaps/ofmx/wikis/Functions) used to facilitate association and modification tracking. It is used internally, but you can also use it in your own code:
@@ -274,6 +303,7 @@ ckmid --help
274
303
  ### AIXM
275
304
  * [AIXM](http://aixm.aero)
276
305
  * [AICM 4.5 documentation](https://openflightmaps.gitlab.io/ofmx/aixm/4.5/manual/aicm/)
306
+ * [AICM 4.5 manual](https://www.aixm.aero/sites/aixm.aero/files/imce/library/aicm_manual_4-5.pdf)
277
307
  * [AIXM 4.5 specification](http://aixm.aero/document/aixm-45-specification)
278
308
 
279
309
  ### OFMX
data/exe/ckmid CHANGED
@@ -1,11 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/inline'
4
-
5
- gemfile do
6
- source 'https://rubygems.org'
7
- ruby '>= 3.0'
8
- gem 'aixm', '~> 0'
9
- end
3
+ require 'aixm'
10
4
 
11
5
  AIXM::Executables::Ckmid.new.run
data/exe/mkmid CHANGED
@@ -1,11 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/inline'
4
-
5
- gemfile do
6
- source 'https://rubygems.org'
7
- ruby '>= 3.0'
8
- gem 'aixm', '~> 0'
9
- end
3
+ require 'aixm'
10
4
 
11
5
  AIXM::Executables::Mkmid.new.run
data/lib/aixm/a.rb CHANGED
@@ -24,6 +24,8 @@ module AIXM
24
24
  # a.invert # => #<AIXM::A -137.8° "22R">
25
25
  # a.to_s(:runway) # => "22R"
26
26
  class A
27
+ include AIXM::Concerns::HashEquality
28
+
27
29
  SUFFIX_INVERSIONS = {
28
30
  R: :L,
29
31
  L: :R
@@ -31,12 +33,23 @@ module AIXM
31
33
 
32
34
  RUNWAY_RE = /\A(0[1-9]|[12]\d|3[0-6])([A-Z])?\z/
33
35
 
34
- # @return [Integer] angle in the range of -360 < angle < 360
36
+ # Angle in the range of -360 < angle < 360.
37
+ #
38
+ # @overload deg
39
+ # @return [Integer]
40
+ # @overload deg=(value)
41
+ # @param value [Integer]
35
42
  attr_reader :deg
36
43
 
37
- # @return [Symbol, nil] one-letter suffix
44
+ # One-letter suffix.
45
+ #
46
+ # @overload suffix
47
+ # @return [Symbol, nil]
48
+ # @overload suffix=(value)
49
+ # @param value [Symbol, nil]
38
50
  attr_reader :suffix
39
51
 
52
+ # See the {overview}[AIXM::A] for examples.
40
53
  def initialize(value)
41
54
  case value
42
55
  when String
@@ -54,12 +67,16 @@ module AIXM
54
67
  %Q(#<#{self.class} #{to_s} #{to_s(:runway).inspect}>)
55
68
  end
56
69
 
57
- # @return [Integer] within 0..359
70
+ # Degrees in the range of 0..359
71
+ #
72
+ # @return [Integer]
58
73
  def to_i
59
74
  (deg.round + 360) % 360
60
75
  end
61
76
 
62
- # @return [Float] within 0.0..359.9~
77
+ # Degrees in the range of 0.0...360.0
78
+ #
79
+ # @return [Float]
63
80
  def to_f
64
81
  ((deg + 360) % 360).to_f
65
82
  end
@@ -96,20 +113,20 @@ module AIXM
96
113
  @suffix = value&.to_s&.to_sym
97
114
  end
98
115
 
99
- # Invert an angle by 180 degrees
116
+ # Invert an angle by 180 degrees.
100
117
  #
101
118
  # @example
102
119
  # AIXM.a(120).invert # (300°)
103
120
  # AIXM.a("34L").invert # (160° suffix "R")
104
121
  #
105
- # @return [AIXM::A] inverted angle
122
+ # @return [AIXM::A]
106
123
  def invert
107
124
  self.class.new(deg.negative? ? deg - 180 : deg + 180).tap do |angle|
108
125
  angle.suffix = SUFFIX_INVERSIONS.fetch(suffix, suffix)
109
126
  end
110
127
  end
111
128
 
112
- # Check whether +other+ angle is the inverse
129
+ # Whether other angle is the inverse.
113
130
  #
114
131
  # @example
115
132
  # AIXM.a(120).inverse_of? AIXM.a(300) # => true
@@ -117,19 +134,19 @@ module AIXM
117
134
  # AIXM.a("33X").inverse_of? AIXM.a("33X") # => true
118
135
  # AIXM.a("16R").inverse_of? AIXM.a("16L") # => false
119
136
  #
120
- # @return [Boolean] whether the inverted angle or not
137
+ # @return [Boolean]
121
138
  def inverse_of?(other)
122
139
  invert == other
123
140
  end
124
141
 
125
- # Negate degrees
142
+ # Negate degrees.
126
143
  #
127
144
  # @return [AIXM::A]
128
145
  def -@
129
146
  deg.zero? ? self : self.class.new(-deg).tap { _1.suffix = suffix }
130
147
  end
131
148
 
132
- # Add degrees
149
+ # Add degrees.
133
150
  #
134
151
  # @param value [Numeric, AIXM::A]
135
152
  # @return [AIXM::A]
@@ -144,7 +161,7 @@ module AIXM
144
161
  end
145
162
  end
146
163
 
147
- # Subtract degrees
164
+ # Subtract degrees.
148
165
  #
149
166
  # @param value [Numeric, AIXM::A]
150
167
  # @return [AIXM::A]
@@ -153,16 +170,13 @@ module AIXM
153
170
  end
154
171
 
155
172
  # @see Object#==
156
- # @return [Boolean]
157
173
  def ==(other)
158
174
  self.class === other && deg == other.deg && suffix == other.suffix
159
175
  end
160
- alias_method :eql?, :==
161
176
 
162
177
  # @see Object#hash
163
- # @return [Integer]
164
178
  def hash
165
- [deg, suffix].join.hash
179
+ [self.class, deg, suffix].join.hash
166
180
  end
167
181
  end
168
182
 
data/lib/aixm/classes.rb CHANGED
@@ -11,6 +11,9 @@ module AIXM
11
11
  a: 'AIXM::A',
12
12
  w: 'AIXM::W',
13
13
  p: 'AIXM::P',
14
+ date: 'AIXM::Schedule::Date',
15
+ day: 'AIXM::Schedule::Day',
16
+ time: 'AIXM::Schedule::Time',
14
17
  address: 'AIXM::Component::Address',
15
18
  approach_lighting: 'AIXM::Component::ApproachLighting',
16
19
  organisation: 'AIXM::Feature::Organisation',
@@ -41,7 +44,9 @@ module AIXM
41
44
  obstacle: 'AIXM::Feature::Obstacle',
42
45
  obstacle_group: 'AIXM::Feature::ObstacleGroup',
43
46
  timetable: 'AIXM::Component::Timetable',
44
- vasis: 'AIXM::Component::VASIS'
47
+ timesheet: 'AIXM::Component::Timesheet',
48
+ vasis: 'AIXM::Component::VASIS',
49
+ generic: 'AIXM::Feature::Generic'
45
50
  }.freeze
46
51
 
47
52
  end
@@ -14,8 +14,8 @@ module AIXM
14
14
  #
15
15
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airport#aha-airport-address
16
16
  class Address < Component
17
- include AIXM::Association
18
- include AIXM::Memoize
17
+ include AIXM::Concerns::Association
18
+ include AIXM::Concerns::Remarks
19
19
 
20
20
  public_class_method :new
21
21
 
@@ -39,15 +39,24 @@ module AIXM
39
39
  # @return [AIXM::Feature] addressable feature
40
40
  belongs_to :addressable
41
41
 
42
- # @return [Symbol] type of address (see {TYPES})
42
+ # Type of address
43
+ #
44
+ # @overload type
45
+ # @return [Symbol] any of {TYPES}
46
+ # @overload type=(value)
47
+ # @param value [Symbol] any of {TYPES}
43
48
  attr_reader :type
44
49
 
45
- # @return [String] postal address, phone number, radio frequency etc
50
+ # Postal address, phone number, radio frequency etc
51
+ #
52
+ # @overload address
53
+ # @return [String]
54
+ # @overload address=(value)
55
+ # @param value [String]
46
56
  attr_reader :address
47
57
 
48
- # @return [String, nil] free text remarks
49
- attr_reader :remarks
50
-
58
+ # See the {cheat sheet}[AIXM::Component::Address] for examples on how to
59
+ # create instances of this class.
51
60
  def initialize(type:, address:)
52
61
  self.type, self.address = type, address
53
62
  end
@@ -72,30 +81,24 @@ module AIXM
72
81
  end
73
82
  end
74
83
 
75
- def remarks=(value)
76
- @remarks = value&.to_s
77
- end
78
-
79
- # @return [String] UID markup
80
- def to_uid(as:, sequence:)
81
- builder = Builder::XmlMarkup.new(indent: 2)
82
- builder.tag!(as) do |tag|
83
- tag << addressable.to_uid.indent(2) if addressable
84
+ # @!visibility private
85
+ def add_uid_to(builder, as:, sequence:)
86
+ builder.send(as) do |tag|
87
+ addressable.add_uid_to(tag) if addressable
84
88
  tag.codeType(TYPES.key(type).to_s.then_if(AIXM.aixm?) { _1.sub(/-\w+$/, '') })
85
89
  tag.noSeq(sequence)
86
90
  end
87
91
  end
88
- memoize :to_uid
89
92
 
90
- # @return [String] AIXM or OFMX markup
91
- def to_xml(as:, sequence:)
92
- builder = Builder::XmlMarkup.new(indent: 2)
93
- builder.comment! ["Address: #{TYPES.key(type)}", addressable&.id].compact.join(' for ')
94
- builder.tag!(as) do |tag|
95
- tag << to_uid(as: :"#{as}Uid", sequence: sequence).indent(2)
93
+ # @!visibility private
94
+ def add_to(builder, as:, sequence:)
95
+ builder.comment ["Address: #{TYPES.key(type)}", addressable&.id].compact.join(' for ').dress
96
+ builder.text "\n"
97
+ builder.send(as) do |tag|
98
+ add_uid_to(tag, as: :"#{as}Uid", sequence: sequence)
96
99
  case type
97
100
  when :radio_frequency
98
- tag.txtAddress(address.freq.to_s)
101
+ tag.txtAddress(address.freq)
99
102
  else
100
103
  tag.txtAddress(address)
101
104
  end
@@ -17,8 +17,9 @@ module AIXM
17
17
  #
18
18
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airport#rda-runway-direction-approach-lighting
19
19
  class ApproachLighting < Component
20
- include AIXM::Association
21
- include AIXM::Memoize
20
+ include AIXM::Concerns::Association
21
+ include AIXM::Concerns::Intensity
22
+ include AIXM::Concerns::Remarks
22
23
 
23
24
  TYPES = {
24
25
  A: :cat_1,
@@ -41,35 +42,44 @@ module AIXM
41
42
  OTHER: :other # specify in remarks
42
43
  }.freeze
43
44
 
44
- INTENSITIES = {
45
- LIL: :low,
46
- LIM: :medium,
47
- LIH: :high,
48
- OTHER: :other # specify in remarks
49
- }.freeze
50
-
51
45
  # @!method approach_lightable
52
46
  # @return [AIXM::Component::Runway::Direction, AIXM::Component::FATO::Direction] approach lighted entity
53
47
  belongs_to :approach_lightable
54
48
 
55
- # @return [Symbol, nil] type of the approach lighting system (see {TYPES})
49
+ # Type of the approach lighting system
50
+ #
51
+ # @overload type
52
+ # @return [Symbol] any of {TYPES}
53
+ # @overload type=(value)
54
+ # @param value [Symbol] any of {TYPES}
56
55
  attr_reader :type
57
56
 
58
- # @return [AIXM::D, nil] length
57
+ # Length
58
+ #
59
+ # @overload length
60
+ # @return [AIXM::D, nil]
61
+ # @overload length=(value)
62
+ # @param value [AIXM::D, nil]
59
63
  attr_reader :length
60
64
 
61
- # @return [Symbol, nil] intensity of lights (see {INTENSITIES})
62
- attr_reader :intensity
63
-
64
- # @return [Boolean, nil] whether sequenced flash is available
65
+ # Whether sequenced flash is available
66
+ #
67
+ # @overload sequenced_flash
68
+ # @return [Boolean, nil] +nil+ means unknown
69
+ # @overload sequenced_flash=(value)
70
+ # @param value [Boolean, nil] +nil+ means unknown
65
71
  attr_reader :sequenced_flash
66
72
 
67
- # @return [String, nil] description of the flash sequence
73
+ # Description of the flash sequence
74
+ #
75
+ # @overload flash_description
76
+ # @return [String, nil]
77
+ # @overload flash_description=(value)
78
+ # @param value [String, nil]
68
79
  attr_reader :flash_description
69
80
 
70
- # @return [String, nil] free text remarks
71
- attr_reader :remarks
72
-
81
+ # See the {cheat sheet}[AIXM::Component::ApproachLighting] for examples on
82
+ # how to create instances of this class.
73
83
  def initialize(type:)
74
84
  self.type = type
75
85
  end
@@ -88,10 +98,6 @@ module AIXM
88
98
  @length = value
89
99
  end
90
100
 
91
- def intensity=(value)
92
- @intensity = value.nil? ? nil : INTENSITIES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid intensity")
93
- end
94
-
95
101
  def sequenced_flash=(value)
96
102
  fail(ArgumentError, "invalid sequenced flash") unless [true, false, nil].include? value
97
103
  @sequenced_flash = value
@@ -101,35 +107,27 @@ module AIXM
101
107
  @flash_description = value&.to_s
102
108
  end
103
109
 
104
- def remarks=(value)
105
- @remarks = value&.to_s
106
- end
107
-
108
- # @return [String] UID markup
109
- def to_uid(as:)
110
- builder = Builder::XmlMarkup.new(indent: 2)
111
- builder.tag!(as) do |tag|
112
- tag << approach_lightable.to_uid.indent(2)
113
- tag.codeType(TYPES.key(type).to_s)
110
+ # @!visibility private
111
+ def add_uid_to(builder, as:)
112
+ builder.send(as) do |tag|
113
+ approach_lightable.add_uid_to(tag)
114
+ tag.codeType(TYPES.key(type))
114
115
  end
115
116
  end
116
- memoize :to_uid
117
117
 
118
- # @return [String] AIXM or OFMX markup
119
- def to_xml(as:)
120
- builder = Builder::XmlMarkup.new(indent: 2)
121
- builder.tag!(as) do |tag|
122
- tag << to_uid(as: "#{as}Uid").indent(2)
118
+ # @!visibility private
119
+ def add_to(builder, as:)
120
+ builder.send(as) do |tag|
121
+ add_uid_to(tag, as: "#{as}Uid")
123
122
  if length
124
123
  tag.valLen(length.dim.round)
125
124
  tag.uomLen(length.unit.to_s.upcase)
126
125
  end
127
- tag.codeIntst(INTENSITIES.key(intensity).to_s) if intensity
126
+ tag.codeIntst(INTENSITIES.key(intensity)) if intensity
128
127
  tag.codeSequencedFlash(sequenced_flash ? 'Y' : 'N') unless sequenced_flash.nil?
129
128
  tag.txtDescrFlash(flash_description) if flash_description
130
129
  tag.txtRmk(remarks) if remarks
131
130
  end
132
- builder.target!
133
131
  end
134
132
  end
135
133
  end