Class: ViewModel::Cepc800::AcReport
- Inherits:
-
CommonSchema
- Object
- BaseViewModel
- CommonSchema
- ViewModel::Cepc800::AcReport
- Defined in:
- lib/view_model/cepc800/ac_report.rb
Instance Method Summary collapse
- #air_handling_systems ⇒ Object
- #checklist_values(checklist) ⇒ Object
- #cooling_plants ⇒ Object
- #executive_summary ⇒ Object
- #extract_aci_recommendations(nodes) ⇒ Object
- #extract_inspection_item(node) ⇒ Object
- #key_recommendations_control ⇒ Object
- #key_recommendations_efficiency ⇒ Object
- #key_recommendations_maintenance ⇒ Object
- #key_recommendations_management ⇒ Object
- #pre_inspection_checklist ⇒ Object
- #related_party_disclosure ⇒ Object
- #related_rrn ⇒ Object
- #sub_systems ⇒ Object
- #system_controls ⇒ Object
- #terminal_units ⇒ Object
Methods inherited from CommonSchema
#address_id, #address_line1, #address_line2, #address_line3, #address_line4, #all_energy_types, #all_reason_types, #all_start_dates, #assessment_id, #assessor_email, #assessor_name, #assessor_telephone, #building_level, #calculation_tool, #company_address, #company_name, #date_of_assessment, #date_of_expiry, #date_of_issue, #date_of_registration, #inspection_type, #or_assessment_end_date, #postcode, #report_type, #scheme_assessor_id, #town
Methods inherited from BaseViewModel
Constructor Details
This class inherits a constructor from ViewModel::BaseViewModel
Instance Method Details
#air_handling_systems ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/view_model/cepc800/ac_report.rb', line 145 def air_handling_systems @xml_doc .search("ACI-Air-Handling-System") .map do |node| { equipment: { unit: node.at("System-Number")&.content, component: node.at("System-Component-Identifier")&.content, systems_served: node.at("ACI-Air-Handling-System-Equipment/Systems-Served") &.content, manufacturer: node.at("ACI-Air-Handling-System-Equipment/Manufacturer") &.content, year_installed: node.at("ACI-Air-Handling-System-Equipment/Year-Installed") &.content, location: node.at("ACI-Air-Handling-System-Equipment/Location") &.content, areas_served: node.at("ACI-Air-Handling-System-Equipment/Area-Served") &.content, discrepancy: node.at("ACI-Air-Handling-System-Equipment/Discrepancy-Note") &.content, }, inspection: { filters: { filter_condition: extract_inspection_item(node.at("Filter-Condition-OK")), change_frequency: extract_inspection_item( node.at("Filter-Change-Frequency-OK"), ), differential_pressure_gauge: extract_inspection_item( node.at("Differential-Pressure-Gauge-OK"), ), }, heat_exchangers: { condition: extract_inspection_item(node.at("Heat-Exchangers-OK")), }, refrigeration: { leaks: extract_inspection_item(node.at("Refrigeration-Leak")), }, fan_rotation: { direction: extract_inspection_item(node.at("Fan-Rotation-OK")), modulation: extract_inspection_item(node.at("Fan-Modulation-OK")), }, fan_control: { setting: extract_inspection_item(node.at("Fan-Control-Setting")), }, heat_recovery: { energy_conservation: extract_inspection_item( node.at("Energy-Conservation-Features"), ), }, air_leakage: { condition: extract_inspection_item(node.at("Air-Leakage")), }, outdoor_inlets: { condition: extract_inspection_item(node.at("Outdoor-Air-Inlets")), }, fan_power: { condition: extract_inspection_item(node.at("Fan-Power-OK")), sfp_calculation: xpath(%w[SFP-Calculation], node), }, }, } end end |
#checklist_values(checklist) ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/view_model/cepc800/ac_report.rb', line 93 def checklist_values(checklist) results = checklist&.element_children&.map { |node| checklist_item = node.name.underscore.to_sym value = node.content == "Yes" { checklist_item => value } }&.inject(&:merge) results.nil? ? {} : results end |
#cooling_plants ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/view_model/cepc800/ac_report.rb', line 85 def cooling_plants extraction_helper = Helper::AcReportExtraction.new @xml_doc .search("Air-Conditioning-Inspection-Report/ACI-Cooling-Plant") .map { |node| extraction_helper.cooling_plant(node) } end |
#executive_summary ⇒ Object
11 12 13 |
# File 'lib/view_model/cepc800/ac_report.rb', line 11 def executive_summary xpath(%w[Executive-Summary]) end |
#extract_aci_recommendations(nodes) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/view_model/cepc800/ac_report.rb', line 19 def extract_aci_recommendations(nodes) nodes.filter_map do |node| unless node.at("Text").content.nil? || node.at("Text").content.empty? { sequence: node.at("Seq-Number").content&.to_i, text: node.at("Text").content, } end end end |
#extract_inspection_item(node) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/view_model/cepc800/ac_report.rb', line 127 def extract_inspection_item(node) inspection_item = { note: node&.at("Note")&.content, recommendations: if node.respond_to?(:search) extract_aci_recommendations(node.search("ACI-Recommendation")) else [] end, } if node.respond_to?(:at) && node.at("Flag") inspection_item[:flag] = node.at("Flag").content == "Yes" end inspection_item end |
#key_recommendations_control ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/view_model/cepc800/ac_report.rb', line 46 def key_recommendations_control extract_aci_recommendations( @xml_doc.search( "ACI-Key-Recommendations/Alternative-Solutions/ACI-Recommendation", ), ) end |
#key_recommendations_efficiency ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/view_model/cepc800/ac_report.rb', line 30 def key_recommendations_efficiency extract_aci_recommendations( @xml_doc.search( "ACI-Key-Recommendations/Sub-System-Efficiency-Capacity-Cooling-Loads/ACI-Recommendation", ), ) end |
#key_recommendations_maintenance ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/view_model/cepc800/ac_report.rb', line 38 def key_recommendations_maintenance extract_aci_recommendations( @xml_doc.search( "ACI-Key-Recommendations/Improvement-Options/ACI-Recommendation", ), ) end |
#key_recommendations_management ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/view_model/cepc800/ac_report.rb', line 54 def key_recommendations_management extract_aci_recommendations( @xml_doc.search( "ACI-Key-Recommendations/Other-Recommendations/ACI-Recommendation", ), ) end |
#pre_inspection_checklist ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/view_model/cepc800/ac_report.rb', line 104 def pre_inspection_checklist { essential: checklist_values( @xml_doc.at( "ACI-Pre-Inspection-Information/ACI-Pre-Inspection-Essential", ), ), desirable: checklist_values( @xml_doc.at( "ACI-Pre-Inspection-Information/ACI-Pre-Inspection-Desirable", ), ), optional: checklist_values( @xml_doc.at( "ACI-Pre-Inspection-Information/ACI-Pre-Inspection-Optional", ), ), } end |
#related_party_disclosure ⇒ Object
7 8 9 |
# File 'lib/view_model/cepc800/ac_report.rb', line 7 def xpath(%w[ACI-Related-Party-Disclosure]) end |
#related_rrn ⇒ Object
15 16 17 |
# File 'lib/view_model/cepc800/ac_report.rb', line 15 def xpath(%w[Related-RRN]) end |
#sub_systems ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/view_model/cepc800/ac_report.rb', line 62 def sub_systems @xml_doc .search("ACI-Sub-Systems/ACI-Sub-System") .map do |node| { volume_definitions: node.at("Sub-System-Volume-Definitions")&.content, id: node.at("Sub-System-ID")&.content, description: node.at("Sub-System-Description")&.content, cooling_output: node.at("Sub-System-Cooling-Output")&.content, area_served: node.at("Sub-System-Area-Served-Description")&.content, inspection_date: node.at("Sub-System-Inspection-Date")&.content, cooling_plant_count: node.at("Sub-System-Cooling-Plant-Count")&.content, ahu_count: node.at("Sub-System-AHU-Count")&.content, terminal_units_count: node.at("Sub-System-Terminal-Units-Count")&.content, controls_count: node.at("Sub-System-Controls-Count")&.content, } end end |
#system_controls ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/view_model/cepc800/ac_report.rb', line 279 def system_controls @xml_doc .search("ACI-System-Control") .map do |node| { sub_system_id: xpath(%w[Sub-System-ID], node), component: xpath(%w[System-Component-Identifier], node), inspection: { zoning: extract_inspection_item(node.at("Zoning-Assessment")), time: extract_inspection_item(node.at("Current-Indicated-Time")), set_on_period: extract_inspection_item(node.at("Set-On-Period")), timer_shortfall: extract_inspection_item(node.at("Timer-Shortfall")), sensors: extract_inspection_item(node.at("Sensors-Appropriate")), set_temperature: extract_inspection_item(node.at("Set-Temperature")), dead_band: extract_inspection_item(node.at("Dead-Band-Set")), capacity: extract_inspection_item(node.at("Equipment-Capacity")), airflow: extract_inspection_item(node.at("Airflow-Modulation")), guidance_controls: extract_inspection_item(node.at("Use-Guidance-Or-Controls")), }, } end end |
#terminal_units ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/view_model/cepc800/ac_report.rb', line 224 def terminal_units @xml_doc .search("ACI-Terminal-Unit") .map do |node| { equipment: { unit: node.at("System-Number")&.content, component: node.at("System-Component-Identifier")&.content, description: node.at("System-Identifier")&.content, cooling_plant: node.at("Systems-Served")&.content, manufacturer: node.at("Manufacturer")&.content, year_installed: node.at("Year-Installed")&.content, area_served: node.at("Area-Served")&.content, discrepancy: node.at("Discrepancy-Note")&.content, }, inspection: { insulation: { pipework: extract_inspection_item(node.at("Pipe-Insulation-OK")), ductwork: extract_inspection_item(node.at("Ductwork-Insulated-OK")), }, unit: { condition: extract_inspection_item(node.at("Unit-Condition-OK")), }, grilles_air_flow: { distribution: extract_inspection_item( node.at("Air-Flow-Distribution-OK"), ), tampering: extract_inspection_item( node.at("Air-Flow-Tampering-Issues"), ), water_supply: extract_inspection_item(node.at("Water-Supply-OK")), complaints: extract_inspection_item(node.at("Air-Flow-Issues")), }, diffuser_positions: { position_issues: extract_inspection_item( node.at("Diffuser-Positions-Issues"), ), partitioning_issues: extract_inspection_item(node.at("Partitioning-Issues")), control_operation: extract_inspection_item(node.at("Control-Operation-OK")), }, }, } end end |