Class: AIXM::Feature::Address
- Inherits:
-
AIXM::Feature
- Object
- AIXM::Feature
- AIXM::Feature::Address
- 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
-
#address ⇒ String
Postal address, phone number, radio frequency etc.
-
#addressable ⇒ AIXM::Feature
readonly
Addressable feature.
-
#remarks ⇒ String?
Free text remarks.
-
#type ⇒ Symbol
Type of address (see TYPES).
Attributes inherited from AIXM::Feature
Instance Method Summary collapse
-
#initialize(source: nil, type:, address:) ⇒ Address
constructor
A new instance of Address.
- #inspect ⇒ String
-
#to_uid(as:, sequence:) ⇒ String
UID markup.
-
#to_xml(as:, sequence:) ⇒ String
AIXM or OFMX markup.
Methods inherited from AIXM::Feature
Constructor Details
#initialize(source: nil, type:, address:) ⇒ Address
Returns a new instance of 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
#address ⇒ String
Returns postal address, phone number, radio frequency etc.
43 44 45 |
# File 'lib/aixm/feature/address.rb', line 43 def address @address end |
#addressable ⇒ AIXM::Feature
Returns addressable feature.
37 38 39 |
# File 'lib/aixm/feature/address.rb', line 37 def addressable @addressable end |
#remarks ⇒ String?
Returns free text remarks.
46 47 48 |
# File 'lib/aixm/feature/address.rb', line 46 def remarks @remarks end |
#type ⇒ Symbol
Returns type of address (see TYPES).
40 41 42 |
# File 'lib/aixm/feature/address.rb', line 40 def type @type end |
Instance Method Details
#inspect ⇒ String
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
Returns UID markup.
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 end |
#to_xml(as:, sequence:) ⇒ String
Returns AIXM or OFMX markup.
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 |