Class: ADIWG::Mdtranslator::Writers::Fgdc::Contact
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Fgdc::Contact
- Defined in:
- lib/adiwg/mdtranslator/writers/fgdc/classes/class_contact.rb
Instance Method Summary collapse
-
#initialize(xml, hResponseObj) ⇒ Contact
constructor
A new instance of Contact.
- #writeXML(hContact) ⇒ Object
Constructor Details
#initialize(xml, hResponseObj) ⇒ Contact
Returns a new instance of Contact.
19 20 21 22 23 |
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_contact.rb', line 19 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj @NameSpace = ADIWG::Mdtranslator::Writers::Fgdc end |
Instance Method Details
#writeXML(hContact) ⇒ Object
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_contact.rb', line 25 def writeXML(hContact) # classes used addressClass = Address.new(@xml, @hResponseObj) phoneClass = Phone.new(@xml, @hResponseObj) # outContext outContext = 'contact' outContext += ' ' + hContact[:name] unless hContact[:name].nil? outContext += ' (' + hContact[:contactId] + ')' unless hContact[:contactId].nil? # set contact type and names contactType = nil personName = nil orgName = nil if hContact[:isOrganization] contactType = 'organization' orgName = hContact[:name] if orgName.nil? @NameSpace.issueWarning(50, 'cntorgp', outContext) end else contactType = 'person' personName = hContact[:name] if personName.nil? @NameSpace.issueWarning('51', 'cntperp', outContext) end unless hContact[:memberOfOrgs].empty? hOrgContact = ADIWG::Mdtranslator::Writers::Fgdc.get_contact(hContact[:memberOfOrgs][0]) unless hOrgContact.empty? orgName = hOrgContact[:name] end end end if contactType.nil? @NameSpace.issueError(52, outContext) end # contact 10 (cntinfo) - contact information @xml.tag!('cntinfo') do # contact 10.1 (cntperp) - contact person primary if contactType == 'person' @xml.tag!('cntperp') do # contact 10.1.1 (cntper) - contact person name unless personName.nil? @xml.tag!('cntper', personName) end if personName == '' @NameSpace.issueWarning(53,'cntper', outContext) end # contact 10.1.1 (cntorg) - contact organization name unless orgName.nil? @xml.tag!('cntorg', orgName) end if orgName.nil? && @hResponseObj[:writerShowTags] @xml.tag!('cntorg') end end end # contact 10.2 (cntorgp) - contact organization primary if contactType == 'organization' @xml.tag!('cntorgp') do # contact 10.2.1 (cntper) - contact person name unless personName.nil? @xml.tag!('cntper', personName) end # contact 10.2.1 (cntorg) - contact organization name unless orgName == '' @xml.tag!('cntorg', orgName) end if orgName.nil? @NameSpace.issueWarning(54, 'cntorg', outContext) end end end # contact 10.3 (cntpos) - contact position name unless hContact[:positionName].nil? @xml.tag!('cntpos', hContact[:positionName]) end if hContact[:positionName].nil? && @hResponseObj[:writerShowTags] @xml.tag!('cntpos') end # contact 10.4 (cntaddr) - contact address (required) hContact[:addresses].each do |hAddress| unless hAddress.empty? @xml.tag!('cntaddr') do addressClass.writeXML(hAddress, outContext) end end end if hContact[:addresses].empty? @NameSpace.issueWarning(55, nil, outContext) end # contact 10.5..7 - phone (voice phone required) # requirement testing is done in phoneClass phoneClass.writeXML(hContact[:phones], outContext) # contact 10.8 - email addresses [] hContact[:eMailList].each do |email| @xml.tag!('cntemail', email) end if hContact[:eMailList].empty? && @hResponseObj[:writerShowTags] @xml.tag!('cntemail') end # contact 10.9 - hours of service # <- hContact[:hoursOfService][0] unless hContact[:hoursOfService].empty? @xml.tag!('hours', hContact[:hoursOfService][0]) end if hContact[:hoursOfService].empty? && @hResponseObj[:writerShowTags] @xml.tag!('hours') end # contact 10.10 (cntinst) - contact instructions unless hContact[:contactInstructions].nil? @xml.tag!('cntinst', hContact[:contactInstructions]) end if hContact[:contactInstructions].nil? && @hResponseObj[:writerShowTags] @xml.tag!('cntinst') end end end |