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

Inherits:
Object
  • Object
show all
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.

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

Constructor Details

#initialize(type:) ⇒ UsageLimitation


377
378
379
380
# File 'lib/aixm/feature/airport.rb', line 377

def initialize(type:)
  self.type = type
  @conditions = []
end

Instance Attribute Details

#airportAIXM::Feature::Airport (readonly)


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

def airport
  @airport
end

#conditionsArray<AIXM::Feature::Airport::UsageLimitation::Condition> (readonly)


369
370
371
# File 'lib/aixm/feature/airport.rb', line 369

def conditions
  @conditions
end

#remarksString?


375
376
377
# File 'lib/aixm/feature/airport.rb', line 375

def remarks
  @remarks
end

#timetableAIXM::Component::Timetable?


372
373
374
# File 'lib/aixm/feature/airport.rb', line 372

def timetable
  @timetable
end

#typeSymbol


366
367
368
# File 'lib/aixm/feature/airport.rb', line 366

def type
  @type
end

Instance Method Details

#add_condition {|condition| ... } ⇒ self

Add a condition to the usage limitation.


395
396
397
398
399
400
# File 'lib/aixm/feature/airport.rb', line 395

def add_condition
  condition = Condition.new
  yield(condition)
  @conditions << condition
  self
end

#inspectString


383
384
385
# File 'lib/aixm/feature/airport.rb', line 383

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

#to_xmlString


412
413
414
415
416
417
418
419
420
421
422
# File 'lib/aixm/feature/airport.rb', line 412

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