Class: AIXM::Feature::Airport::UsageLimitation

Inherits:
Object
  • Object
show all
Includes:
Association
Defined in:
lib/aixm/feature/airport.rb

Overview

Limitations concerning the availability of an airport for certain flight types, aircraft types etc during specific hours.

See UsageLimitation::TYPES for recognized limitations and UsageLimitation#add_condition for recognized conditions.

Multiple conditions are joined with an implicit or whereas the specifics of a condition (aircraft, rule etc) are joined with an implicit and.

Examples:

Limitation applying to any traffic

airport.add_usage_limitation(type: :permitted)

Limitation applying to specific traffic

airport.add_usage_limitation(type: :reservation_required) do |reservation_required|
  reservation_required.add_condition do |condition|
    condition.aircraft = :glider
  end
  reservation_required.add_condition do |condition|
    condition.rule = :ifr
    condition.origin = :international
  end
  reservation_required.timetable = AIXM::H24
  reservation_required.remarks = "Reservation 24 HRS prior to arrival"
end

See Also:

Defined Under Namespace

Classes: Condition

Constant Summary collapse

TYPES =
{
  PERMIT: :permitted,
  FORBID: :forbidden,
  RESERV: :reservation_required,
  OTHER: :other                    # specify in remarks
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Association

included

Constructor Details

#initialize(type:) ⇒ UsageLimitation


358
359
360
# File 'lib/aixm/feature/airport.rb', line 358

def initialize(type:)
  self.type = type
end

Instance Attribute Details

#remarksString?


356
357
358
# File 'lib/aixm/feature/airport.rb', line 356

def remarks
  @remarks
end

#timetableAIXM::Component::Timetable?


353
354
355
# File 'lib/aixm/feature/airport.rb', line 353

def timetable
  @timetable
end

#typeSymbol


350
351
352
# File 'lib/aixm/feature/airport.rb', line 350

def type
  @type
end

Instance Method Details

#add_condition {|AIXM::Feature::Airport::UsageLimitation::Condition| ... } ⇒ self


343
# File 'lib/aixm/feature/airport.rb', line 343

has_many :conditions, accept: 'AIXM::Feature::Airport::UsageLimitation::Condition' do |condition| end

#airportAIXM::Feature::Airport


347
# File 'lib/aixm/feature/airport.rb', line 347

belongs_to :airport

#conditionsArray<AIXM::Feature::Airport::UsageLimitation::Condition>


343
# File 'lib/aixm/feature/airport.rb', line 343

has_many :conditions, accept: 'AIXM::Feature::Airport::UsageLimitation::Condition' do |condition| end

#inspectString


363
364
365
# File 'lib/aixm/feature/airport.rb', line 363

def inspect
  %Q(#<#{self.class} type=#{type.inspect}>)
end

#to_xmlString


381
382
383
384
385
386
387
388
389
390
391
# File 'lib/aixm/feature/airport.rb', line 381

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.UsageLimitation do |usage_limitation|
    usage_limitation.codeUsageLimitation(TYPES.key(type).to_s)
    conditions.each do |condition|
      usage_limitation << condition.to_xml.indent(2)
    end
    usage_limitation << timetable.to_xml(as: :Timetable).indent(2) if timetable
    usage_limitation.txtRmk(remarks) if remarks
  end
end