Class: ADIWG::Mdtranslator::Writers::Iso19115_3::CI_Individual
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Iso19115_3::CI_Individual
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_individual.rb
Instance Method Summary collapse
-
#initialize(xml, hResponseObj) ⇒ CI_Individual
constructor
A new instance of CI_Individual.
- #writeXML(hContact, inContext = nil) ⇒ Object
Constructor Details
#initialize(xml, hResponseObj) ⇒ CI_Individual
Returns a new instance of CI_Individual.
18 19 20 21 22 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_individual.rb', line 18 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_3 end |
Instance Method Details
#writeXML(hContact, inContext = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_individual.rb', line 24 def writeXML(hContact, inContext = nil) # classes used contactClass = CI_Contact.new(@xml, @hResponseObj) identifierClass = MD_PartyIdentifier.new(@xml, @hResponseObj) outContext = 'individual contact' outContext = inContext + ' individual contact' unless inContext.nil? unless hContact.empty? @xml.tag!('cit:CI_Individual') do # individual - name unless hContact[:name].nil? @xml.tag!('cit:name') do @xml.tag!('gco:CharacterString', hContact[:name]) end end if hContact[:name].nil? && @hResponseObj[:writerShowTags] @xml.tag!('cit:name') end # individual - contact information [] (only one contactInfo supported in this implementation) haveInfo = false unless hContact[:phones].empty? && hContact[:addresses].empty? && hContact[:eMailList].empty? && hContact[:onlineResources].empty? && hContact[:hoursOfService].empty? && hContact[:contactInstructions].nil? haveInfo = true end if haveInfo @xml.tag!('cit:contactInfo') do contactClass.writeXML(hContact) end end if !haveInfo && @hResponseObj[:writerShowTags] @xml.tag!('cit:contactInfo') end # individual - party identifier if hContact[:externalIdentifier] && hContact[:externalIdentifier].length > 0 hContact[:externalIdentifier].each do |identifier| @xml.tag!('cit:partyIdentifier') do identifierClass.writeXML(identifier); end end else if hContact[:contactId] && hContact[:contactId].is_a?(Hash) @xml.tag!('cit:partyIdentifier') do identifierClass.writeXML(hContact[:contactId]); end elsif hContact[:contactId].is_a?(String) @xml.tag!('cit:partyIdentifier') do identifierClass.writeXML({ identifier: hContact[:contactId] }) end end end # individual - position unless hContact[:positionName].nil? @xml.tag!('cit:positionName') do @xml.tag!('gco:CharacterString', hContact[:positionName]) end end if hContact[:positionName].nil? && @hResponseObj[:writerShowTags] @xml.tag!('cit:positionName') end end end if hContact.empty? @NameSpace.issueWarning(271, nil, outContext) end end |