Class: AIXM::Feature::Address

Inherits:
AIXM::Feature show all
Defined in:
lib/aixm/feature/address.rb

Overview

Address or similar means to contact an entity.

Cheat Sheet in Pseudo Code:

address = AIXM.address(
  source: String or nil
  type: TYPES
  address: String
)
service.remarks = String or nil

Constant Summary collapse

TYPES =
{
  POST: :postal_address,
  PHONE: :phone,
  'PHONE-MET': :weather_phone,
  FAX: :fax,
  TLX: :telex,
  SITA: :sita,
  AFS: :aeronautical_fixed_service_address,
  EMAIL: :email,
  URL: :url,
  'URL-CAM': :webcam,
  'URL-MET': :weather_url,
  RADIO: :radio_frequency,
  OTHER: :other   # specify in remarks
}

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#source

Instance Method Summary collapse

Methods inherited from AIXM::Feature

#==

Constructor Details

#initialize(source: nil, type:, address:) ⇒ Address


48
49
50
51
# File 'lib/aixm/feature/address.rb', line 48

def initialize(source: nil, type:, address:)
  super(source: source)
  self.type, self.address = type, address
end

Instance Attribute Details

#addressString


43
44
45
# File 'lib/aixm/feature/address.rb', line 43

def address
  @address
end

#addressableAIXM::Feature


37
38
39
# File 'lib/aixm/feature/address.rb', line 37

def addressable
  @addressable
end

#remarksString?


46
47
48
# File 'lib/aixm/feature/address.rb', line 46

def remarks
  @remarks
end

#typeSymbol


40
41
42
# File 'lib/aixm/feature/address.rb', line 40

def type
  @type
end

Instance Method Details

#inspectString


54
55
56
# File 'lib/aixm/feature/address.rb', line 54

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

#to_uid(as:, sequence:) ⇒ String


78
79
80
81
82
83
84
85
# File 'lib/aixm/feature/address.rb', line 78

def to_uid(as:, sequence:)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(as) do |tag|
    tag << addressable.to_uid.indent(2) if addressable
    tag.codeType(TYPES.key(type).to_s.then_if(AIXM.aixm?) { |t| t.sub(/-\w+$/, '') })
    tag.noSeq(sequence)
  end.insert_payload_hash(region: AIXM.config.mid_region)
end

#to_xml(as:, sequence:) ⇒ String


88
89
90
91
92
93
94
95
96
# File 'lib/aixm/feature/address.rb', line 88

def to_xml(as:, sequence:)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.comment! ["Address: #{TYPES.key(type)}", addressable&.id].compact.join(' for ')
  builder.tag!(as, { source: (source if AIXM.ofmx?) }.compact) do |tag|
    tag << to_uid(as: :"#{as}Uid", sequence: sequence).indent(2)
    tag.txtAddress(address)
    tag.txtRmk(remarks) if remarks
  end
end