lib/aixm/component/layer.rb in aixm-1.1.0 vs lib/aixm/component/layer.rb in aixm-1.2.0

- old
+ new

@@ -19,10 +19,12 @@ # layer.add_service(AIXM.service) # # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airspace class Layer < Component include AIXM::Association + include AIXM::Concerns::Timetable + include AIXM::Concerns::Remarks CLASSES = (:A..:G).freeze ACTIVITIES = { ACCIDENT: :accident_investigation, @@ -104,22 +106,28 @@ # @!method airspace # @return [AIXM::Feature::Airspace] airspace the layer defines belongs_to :airspace - # @return [String, nil] four letter location identifier as published in the ICAO DOC 7910 + # Four letter location identifier as published in the ICAO DOC 7910 + # + # @overload location_indicator + # @return [String, nil] + # @overload location_indicator=(value) + # @param value [String, nil] attr_reader :location_indicator - # @return [String, nil] primary activity (e.g. "GLIDER") + # Primary activity + # + # @overload activity + # @return [Symbol, nil] any of {ACTIVITIES} + # @overload activity=(value) + # @param value [Symbol, nil] any of {ACTIVITIES} attr_reader :activity - # @return [AIXM::Component::Timetable, nil] activation hours - attr_reader :timetable - - # @return [String, nil] free text remarks - attr_reader :remarks - + # See the {cheat sheet}[AIXM::Component::Layer] for examples on how to + # create instances of this class. def initialize(class: nil, location_indicator: nil, vertical_limit:) self.class = binding.local_variable_get(:class) self.location_indicator, self.vertical_limit = location_indicator, vertical_limit self.selective = false end @@ -127,12 +135,19 @@ # @return [String] def inspect %Q(#<#{__class__} class=#{@klass.inspect}>) end + # Class of layer. + # + # @note Use +Object#__class__+ alias to query the Ruby object class. + # # @!attribute class - # @return [Symbol] class of layer (see {CLASSES}) + # @overload class + # @return [Symbol] any of {CLASSES} + # @overload class=(value) + # @param value [Symbol] any of {CLASSES} def class @klass end def class=(value) @@ -147,27 +162,23 @@ def activity=(value) @activity = value.nil? ? nil : ACTIVITIES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid activity") end - def timetable=(value) - fail(ArgumentError, "invalid timetable") unless value.nil? || value.is_a?(AIXM::Component::Timetable) - @timetable = value - end - - # @!attribute [w] selective - # @return [Boolean] whether the layer may be activated selectively + # Whether the layer may be activated selectively. + # + # @!attribute selective + # @overload selective? + # @return [Boolean] + # @overload selective=(value) + # @param value [Boolean] def selective? @selective end def selective=(value) fail(ArgumentError, "invalid selective") unless [true, false].include? value @selective = value - end - - def remarks=(value) - @remarks = value&.to_s end # @return [String] AIXM or OFMX markup def to_xml builder = Builder::XmlMarkup.new(indent: 2)