Class: ViewModel::SapSchema1900::CommonSchema
- Inherits:
-
DomesticEpcViewModel
- Object
- BaseViewModel
- DomesticEpcViewModel
- ViewModel::SapSchema1900::CommonSchema
- Defined in:
- lib/view_model/sap_schema_1900/common_schema.rb
Constant Summary collapse
- THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY =
65
Instance Method Summary collapse
- #address_id ⇒ Object
- #address_line1 ⇒ Object
- #address_line2 ⇒ Object
- #address_line3 ⇒ Object
- #all_building_parts ⇒ Object
- #all_floor_descriptions ⇒ Object
- #all_floor_energy_efficiency_rating ⇒ Object
- #all_floor_env_energy_efficiency_rating ⇒ Object
- #all_main_heating_controls_descriptions ⇒ Object
- #all_main_heating_controls_energy_efficiency ⇒ Object
- #all_main_heating_controls_environmental_efficiency ⇒ Object
- #all_main_heating_descriptions ⇒ Object
- #all_main_heating_energy_efficiency ⇒ Object
- #all_main_heating_environmental_efficiency ⇒ Object
- #all_roof_descriptions ⇒ Object
- #all_roof_energy_efficiency_rating ⇒ Object
- #all_roof_env_energy_efficiency_rating ⇒ Object
- #all_sap_floor_dimensions ⇒ Object
- #all_wall_descriptions ⇒ Object
- #all_wall_energy_efficiency_rating ⇒ Object
- #all_wall_env_energy_efficiency_rating ⇒ Object
- #assessment_id ⇒ Object
- #assessor_email ⇒ Object
- #assessor_name ⇒ Object
- #assessor_telephone ⇒ Object
- #boiler_flue_type ⇒ Object
- #building_part_number ⇒ Object
- #built_form ⇒ Object
- #co2_emissions_current_per_floor_area ⇒ Object
- #country_code ⇒ Object
- #current_carbon_emission ⇒ Object
- #current_energy_rating ⇒ Object
- #current_space_heating_demand ⇒ Object
- #current_water_heating_demand ⇒ Object
- #cylinder_insul_thickness ⇒ Object
- #cylinder_insulation_type ⇒ Object
- #cylinder_size ⇒ Object
- #date_of_assessment ⇒ Object
- #date_of_completion ⇒ Object
- #date_of_expiry ⇒ Object
- #date_of_registration ⇒ Object
- #dwelling_type ⇒ Object
- #electricity_smart_meter_present ⇒ Object
- #energy_consumption_potential ⇒ Object
- #energy_tariff ⇒ Object
- #environmental_impact_current ⇒ Object
- #environmental_impact_potential ⇒ Object
- #estimated_energy_cost ⇒ Object
- #fixed_lighting_outlets_count ⇒ Object
- #floor_heat_loss ⇒ Object
- #floor_height ⇒ Object
- #floor_level ⇒ Object
- #format_fixed_light_array ⇒ Object
- #gas_smart_meter_present ⇒ Object
- #has_cylinder_thermostat ⇒ Object
- #heating_cost_current ⇒ Object
- #heating_cost_potential ⇒ Object
- #hot_water_cost_current ⇒ Object
- #hot_water_cost_potential ⇒ Object
- #hot_water_description ⇒ Object
- #hot_water_energy_efficiency_rating ⇒ Object
- #hot_water_environmental_efficiency_rating ⇒ Object
- #immersion_heating_type ⇒ Object
- #impact_of_cavity_insulation ⇒ Object
- #impact_of_loft_insulation ⇒ Object
- #impact_of_solid_wall_insulation ⇒ Object
- #improvements ⇒ Object
- #level ⇒ Object
- #lighting_cost_current ⇒ Object
- #lighting_cost_potential ⇒ Object
- #lighting_description ⇒ Object
- #lighting_energy_efficiency_rating ⇒ Object
- #lighting_environmental_efficiency_rating ⇒ Object
- #low_energy_fixed_lighting_outlets_count ⇒ Object
- #low_energy_lighting ⇒ Object
- #main_dwelling_construction_age_band_or_year ⇒ Object
- #main_fuel_type ⇒ Object
- #main_heating_controls ⇒ Object
- #mech_vent_sys_index_number ⇒ Object
- #mechanical_vent_data_source ⇒ Object
- #meter_type ⇒ Object
- #multiple_glazed_proportion ⇒ Object
- #open_fireplaces_count ⇒ Object
- #postcode ⇒ Object
- #potential_carbon_emission ⇒ Object
- #potential_energy_rating ⇒ Object
- #potential_energy_saving ⇒ Object
- #primary_energy_use ⇒ Object
- #property_age_band ⇒ Object
- #property_summary ⇒ Object
- #recommendations_for_report ⇒ Object
- #related_party_disclosure_number ⇒ Object
- #related_party_disclosure_text ⇒ Object
- #report_type ⇒ Object
- #sap_main_heating_code ⇒ Object
- #scheme_assessor_id ⇒ Object
- #secondary_fuel_type ⇒ Object
- #secondary_heating_description ⇒ Object
- #secondary_heating_energy_efficiency_rating ⇒ Object
- #secondary_heating_environmental_efficiency_rating ⇒ Object
- #storey_count ⇒ Object
- #tenure ⇒ Object
- #thermal_store ⇒ Object
- #top_storey ⇒ Object
- #total_floor_area ⇒ Object
- #total_roof_area ⇒ Object
- #town ⇒ Object
- #transaction_type ⇒ Object
- #type_of_assessment ⇒ Object
- #ventilation_type ⇒ Object
- #water_heating_fuel ⇒ Object
- #wind_turbine_count ⇒ Object
- #window_description ⇒ Object
- #window_energy_efficiency_rating ⇒ Object
- #window_environmental_efficiency_rating ⇒ Object
Methods inherited from DomesticEpcViewModel
#addendum, #has_hot_water_cylinder, #improvement_title, #lzc_energy_sources, #main_heating_category, #multi_glazing_type, #property_type, #status, #water_heating_code
Methods inherited from BaseViewModel
Constructor Details
This class inherits a constructor from ViewModel::BaseViewModel
Instance Method Details
#address_id ⇒ Object
58 59 60 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 58 def address_id xpath(%w[UPRN]) end |
#address_line1 ⇒ Object
10 11 12 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 10 def address_line1 xpath(%w[Report-Header Property Address Address-Line-1]) end |
#address_line2 ⇒ Object
14 15 16 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 14 def address_line2 xpath(%w[Report-Header Property Address Address-Line-2]) end |
#address_line3 ⇒ Object
18 19 20 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 18 def address_line3 xpath(%w[Report-Header Property Address Address-Line-3]) end |
#all_building_parts ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 288 def all_building_parts @xml_doc .search("SAP-Building-Parts/SAP-Building-Part") .map do |part| { roof_insulation_thickness: if part.xpath("Roof-Insulation-Thickness").empty? nil else part.xpath("Roof-Insulation-Thickness").text end, rafter_insulation_thickness: xpath(%w[Rafter-Insulation-Thickness], part), flat_roof_insulation_thickness: xpath(%w[Flat-Roof-Insulation-Thickness], part), sloping_ceiling_insulation_thickness: xpath(%w[Sloping-Ceiling-Insulation-Thickness], part), roof_u_value: xpath(%w[Roof-U-Value], part), } end end |
#all_floor_descriptions ⇒ Object
525 526 527 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 525 def all_floor_descriptions @xml_doc.search("Property-Summary/Floor/Description").map(&:content) end |
#all_floor_energy_efficiency_rating ⇒ Object
529 530 531 532 533 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 529 def @xml_doc .search("Property-Summary/Floor/Energy-Efficiency-Rating") .map(&:content) end |
#all_floor_env_energy_efficiency_rating ⇒ Object
535 536 537 538 539 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 535 def @xml_doc .search("Property-Summary/Floor/Environmental-Efficiency-Rating") .map(&:content) end |
#all_main_heating_controls_descriptions ⇒ Object
477 478 479 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 477 def all_main_heating_controls_descriptions @xml_doc.search("Main-Heating-Controls/Description").map(&:content) end |
#all_main_heating_controls_energy_efficiency ⇒ Object
541 542 543 544 545 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 541 def all_main_heating_controls_energy_efficiency @xml_doc .search("Main-Heating-Controls/Energy-Efficiency-Rating") .map(&:content) end |
#all_main_heating_controls_environmental_efficiency ⇒ Object
547 548 549 550 551 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 547 def all_main_heating_controls_environmental_efficiency @xml_doc .search("Main-Heating-Controls/Environmental-Efficiency-Rating") .map(&:content) end |
#all_main_heating_descriptions ⇒ Object
473 474 475 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 473 def all_main_heating_descriptions @xml_doc.search("Main-Heating/Description").map(&:content) end |
#all_main_heating_energy_efficiency ⇒ Object
517 518 519 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 517 def all_main_heating_energy_efficiency @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content) end |
#all_main_heating_environmental_efficiency ⇒ Object
553 554 555 556 557 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 553 def all_main_heating_environmental_efficiency @xml_doc .search("Main-Heating/Environmental-Efficiency-Rating") .map(&:content) end |
#all_roof_descriptions ⇒ Object
485 486 487 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 485 def all_roof_descriptions @xml_doc.search("Roof/Description").map(&:content) end |
#all_roof_energy_efficiency_rating ⇒ Object
493 494 495 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 493 def @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content) end |
#all_roof_env_energy_efficiency_rating ⇒ Object
489 490 491 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 489 def @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content) end |
#all_sap_floor_dimensions ⇒ Object
261 262 263 264 265 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 261 def all_sap_floor_dimensions @xml_doc.search("SAP-Floor-Dimension").select(&:element?).map { |node| { total_floor_area: xpath(%w[Total-Floor-Area], node).to_f } }.compact end |
#all_wall_descriptions ⇒ Object
497 498 499 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 497 def all_wall_descriptions @xml_doc.search("Walls/Description").map(&:content) end |
#all_wall_energy_efficiency_rating ⇒ Object
501 502 503 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 501 def @xml_doc.search("Walls/Energy-Efficiency-Rating").map(&:content) end |
#all_wall_env_energy_efficiency_rating ⇒ Object
505 506 507 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 505 def @xml_doc.search("Walls/Environmental-Efficiency-Rating").map(&:content) end |
#assessment_id ⇒ Object
6 7 8 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 6 def assessment_id xpath(%w[Report-Header RRN]) end |
#assessor_email ⇒ Object
38 39 40 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 38 def assessor_email xpath(%w[Home-Inspector/E-Mail]) end |
#assessor_name ⇒ Object
34 35 36 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 34 def assessor_name xpath(%w[Home-Inspector Name]) end |
#assessor_telephone ⇒ Object
42 43 44 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 42 def assessor_telephone xpath(%w[Home-Inspector/Telephone]) end |
#boiler_flue_type ⇒ Object
330 331 332 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 330 def boiler_flue_type xpath(%w[Boiler-Flue-Type]) end |
#building_part_number ⇒ Object
284 285 286 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 284 def building_part_number xpath(%w[Building-Part-Number]) end |
#built_form ⇒ Object
465 466 467 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 465 def built_form xpath(%w[Built-Form]) end |
#co2_emissions_current_per_floor_area ⇒ Object
354 355 356 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 354 def co2_emissions_current_per_floor_area xpath(%w[CO2-Emissions-Current-Per-Floor-Area]) end |
#country_code ⇒ Object
342 343 344 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 342 def country_code xpath(%w[Country-Code]) end |
#current_carbon_emission ⇒ Object
161 162 163 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 161 def current_carbon_emission xpath(%w[CO2-Emissions-Current]) end |
#current_energy_rating ⇒ Object
169 170 171 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 169 def xpath(%w[Energy-Rating-Current])&.to_i end |
#current_space_heating_demand ⇒ Object
235 236 237 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 235 def current_space_heating_demand xpath(%w[Space-Heating]) or xpath(%w[Space-Heating-Existing-Dwelling]) end |
#current_water_heating_demand ⇒ Object
239 240 241 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 239 def current_water_heating_demand xpath(%w[Water-Heating]) end |
#cylinder_insul_thickness ⇒ Object
559 560 561 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 559 def cylinder_insul_thickness xpath(%w[Hot-Water-Store-Insulation-Thickness]) end |
#cylinder_insulation_type ⇒ Object
563 564 565 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 563 def cylinder_insulation_type xpath(%w[Hot-Water-Store-Insulation-Type]) end |
#cylinder_size ⇒ Object
567 568 569 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 567 def cylinder_size xpath(%w[Hot-Water-Store-Size]) end |
#date_of_assessment ⇒ Object
46 47 48 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 46 def date_of_assessment xpath(%w[Inspection-Date]) end |
#date_of_completion ⇒ Object
54 55 56 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 54 def date_of_completion xpath(%w[Completion-Date]) end |
#date_of_expiry ⇒ Object
62 63 64 65 66 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 62 def date_of_expiry expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10 expires_at.to_s end |
#date_of_registration ⇒ Object
50 51 52 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 50 def date_of_registration xpath(%w[Registration-Date]) end |
#dwelling_type ⇒ Object
199 200 201 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 199 def dwelling_type xpath(%w[Dwelling-Type]) end |
#electricity_smart_meter_present ⇒ Object
595 596 597 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 595 def electricity_smart_meter_present Helper::ToBool.execute(xpath(%w[Electricity-Smart-Meter-Present])) end |
#energy_consumption_potential ⇒ Object
177 178 179 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 177 def energy_consumption_potential xpath(%w[Energy-Consumption-Potential]) end |
#energy_tariff ⇒ Object
509 510 511 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 509 def energy_tariff xpath(%w[Electricity-Tariff]) end |
#environmental_impact_current ⇒ Object
346 347 348 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 346 def environmental_impact_current xpath(%w[Environmental-Impact-Current])&.to_i end |
#environmental_impact_potential ⇒ Object
350 351 352 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 350 def environmental_impact_potential xpath(%w[Environmental-Impact-Potential])&.to_i end |
#estimated_energy_cost ⇒ Object
181 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 181 def estimated_energy_cost; end |
#fixed_lighting_outlets_count ⇒ Object
366 367 368 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 366 def fixed_lighting_outlets_count @xml_doc.search("Fixed-Lights/Fixed-Light/Lighting-Outlets").map(&:content).map(&:to_i).sum end |
#floor_heat_loss ⇒ Object
310 311 312 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 310 def floor_heat_loss xpath(%w[Floor-Heat-Loss]) end |
#floor_height ⇒ Object
521 522 523 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 521 def floor_height @xml_doc.search("Storey-Height").map(&:content) end |
#floor_level ⇒ Object
513 514 515 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 513 def floor_level xpath(%w[SAP-Flat-Details Level]) end |
#format_fixed_light_array ⇒ Object
370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 370 def format_fixed_light_array @xml_doc .search("Fixed-Lights/Fixed-Light") .map do |part| { lighting_efficacy: xpath(%w[Lighting-Efficacy], part), lighting_outlets: xpath(%w[Lighting-Outlets], part), } end end |
#gas_smart_meter_present ⇒ Object
591 592 593 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 591 def gas_smart_meter_present Helper::ToBool.execute(xpath(%w[Gas-Smart-Meter-Present])) end |
#has_cylinder_thermostat ⇒ Object
571 572 573 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 571 def has_cylinder_thermostat xpath(%w[Has-Cylinder-Thermostat]) end |
#heating_cost_current ⇒ Object
149 150 151 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 149 def heating_cost_current xpath(%w[Heating-Cost-Current]) end |
#heating_cost_potential ⇒ Object
137 138 139 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 137 def heating_cost_potential xpath(%w[Heating-Cost-Potential]) end |
#hot_water_cost_current ⇒ Object
145 146 147 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 145 def hot_water_cost_current xpath(%w[Hot-Water-Cost-Current]) end |
#hot_water_cost_potential ⇒ Object
133 134 135 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 133 def hot_water_cost_potential xpath(%w[Hot-Water-Cost-Potential]) end |
#hot_water_description ⇒ Object
417 418 419 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 417 def hot_water_description xpath(%w[Hot-Water Description]) end |
#hot_water_energy_efficiency_rating ⇒ Object
421 422 423 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 421 def xpath(%w[Hot-Water Energy-Efficiency-Rating]) end |
#hot_water_environmental_efficiency_rating ⇒ Object
425 426 427 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 425 def xpath(%w[Hot-Water Environmental-Efficiency-Rating]) end |
#immersion_heating_type ⇒ Object
314 315 316 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 314 def immersion_heating_type xpath(%w[Immersion-Heating-Type]) end |
#impact_of_cavity_insulation ⇒ Object
243 244 245 246 247 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 243 def impact_of_cavity_insulation if xpath(%w[Impact-Of-Cavity-Insulation]) xpath(%w[Impact-Of-Cavity-Insulation])&.to_i end end |
#impact_of_loft_insulation ⇒ Object
249 250 251 252 253 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 249 def impact_of_loft_insulation if xpath(%w[Impact-Of-Loft-Insulation]) xpath(%w[Impact-Of-Loft-Insulation])&.to_i end end |
#impact_of_solid_wall_insulation ⇒ Object
255 256 257 258 259 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 255 def impact_of_solid_wall_insulation if xpath(%w[Impact-Of-Solid-Wall-Insulation]) xpath(%w[Impact-Of-Solid-Wall-Insulation])&.to_i end end |
#improvements ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 93 def improvements @xml_doc .search("Suggested-Improvements Improvement") .map do |node| { energy_performance_rating_improvement: xpath(%w[Energy-Performance-Rating], node).to_i, environmental_impact_rating_improvement: xpath(%w[Environmental-Impact-Rating], node).to_i, green_deal_category_code: xpath(%w[Green-Deal-Category], node), improvement_category: xpath(%w[Improvement-Category], node), improvement_code: xpath(%w[Improvement-Details Improvement-Number], node), improvement_description: xpath(%w[Improvement-Description], node), improvement_title: improvement_title(node), improvement_type: xpath(%w[Improvement-Type], node), indicative_cost: xpath(%w[Indicative-Cost], node), sequence: xpath(%w[Sequence], node).to_i, typical_saving: xpath(%w[Typical-Saving], node), } end end |
#level ⇒ Object
271 272 273 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 271 def level xpath(%w[Level]) end |
#lighting_cost_current ⇒ Object
153 154 155 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 153 def lighting_cost_current xpath(%w[Lighting-Cost-Current]) end |
#lighting_cost_potential ⇒ Object
141 142 143 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 141 def lighting_cost_potential xpath(%w[Lighting-Cost-Potential]) end |
#lighting_description ⇒ Object
453 454 455 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 453 def lighting_description xpath(%w[Lighting Description]) end |
#lighting_energy_efficiency_rating ⇒ Object
457 458 459 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 457 def xpath(%w[Lighting Energy-Efficiency-Rating]) end |
#lighting_environmental_efficiency_rating ⇒ Object
461 462 463 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 461 def xpath(%w[Lighting Environmental-Efficiency-Rating]) end |
#low_energy_fixed_lighting_outlets_count ⇒ Object
401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 401 def low_energy_fixed_lighting_outlets_count low_energy_outlet_count = [] format_fixed_light_array.each do |outlet| if outlet[:lighting_efficacy].to_i > THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY low_energy_outlet_count << outlet[:lighting_outlets].to_i end end low_energy_outlet_count.sum end |
#low_energy_lighting ⇒ Object
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 383 def low_energy_lighting total_energy_outlet_count = [] low_energy_outlet_count = [] format_fixed_light_array.each do |outlet| if outlet[:lighting_efficacy].to_i > THRESHOLD_LOW_ENERGY_LIGHTING_EFFICACY low_energy_outlet_count << outlet[:lighting_outlets].to_i end total_energy_outlet_count << outlet[:lighting_outlets].to_f end if total_energy_outlet_count.sum.zero? return 0 end (low_energy_outlet_count.sum / total_energy_outlet_count.sum * 100).round end |
#main_dwelling_construction_age_band_or_year ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 209 def main_dwelling_construction_age_band_or_year sap_building_parts = @xml_doc.xpath("//SAP-Building-Parts/SAP-Building-Part") sap_building_parts.each do |sap_building_part| building_part_number = sap_building_part.at("Building-Part-Number") # Identifies the Main Dwelling if building_part_number&.content == "1" return( sap_building_part.at_xpath( "Construction-Age-Band | Construction-Year", )&.content ) end end nil end |
#main_fuel_type ⇒ Object
318 319 320 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 318 def main_fuel_type xpath(%w[Main-Fuel-Type]) end |
#main_heating_controls ⇒ Object
358 359 360 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 358 def main_heating_controls xpath(%w[Main-Heating-Controls Description]) end |
#mech_vent_sys_index_number ⇒ Object
575 576 577 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 575 def mech_vent_sys_index_number xpath(%w[Mechanical-Vent-System-Index-Number])&.to_i end |
#mechanical_vent_data_source ⇒ Object
579 580 581 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 579 def mechanical_vent_data_source xpath(%w[Mechanical-Ventilation-Data-Source]) end |
#meter_type ⇒ Object
334 335 336 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 334 def meter_type xpath(%w[Meter-Type]) end |
#multiple_glazed_proportion ⇒ Object
362 363 364 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 362 def multiple_glazed_proportion xpath(%w[Multiple-Glazed-Percentage]) end |
#open_fireplaces_count ⇒ Object
413 414 415 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 413 def open_fireplaces_count xpath(%w[Open-Chimneys-Count])&.to_i end |
#postcode ⇒ Object
26 27 28 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 26 def postcode xpath(%w[Report-Header Property Address Postcode]) end |
#potential_carbon_emission ⇒ Object
157 158 159 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 157 def potential_carbon_emission xpath(%w[CO2-Emissions-Potential]) end |
#potential_energy_rating ⇒ Object
165 166 167 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 165 def xpath(%w[Energy-Rating-Potential])&.to_i end |
#potential_energy_saving ⇒ Object
203 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 203 def potential_energy_saving; end |
#primary_energy_use ⇒ Object
173 174 175 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 173 def primary_energy_use xpath(%w[Energy-Consumption-Current]) end |
#property_age_band ⇒ Object
205 206 207 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 205 def property_age_band xpath(%w[Construction-Year]) end |
#property_summary ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 68 def property_summary @xml_doc.search("Energy-Assessment Property-Summary").children.select( &:element? ).map { |node| next if xpath(%w[Energy-Efficiency-Rating], node).nil? { energy_efficiency_rating: xpath(%w[Energy-Efficiency-Rating], node).to_i, environmental_efficiency_rating: xpath(%w[Environmental-Efficiency-Rating], node).to_i, name: node.name.underscore, description: xpath(%w[Description], node), } }.compact end |
#recommendations_for_report ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 116 def recommendations_for_report accessor = Accessor::DomesticRecommendationsAccessor.instance @xml_doc .search("Suggested-Improvements Improvement") .map do |node| improvement_code = xpath(%w[Improvement-Details Improvement-Number], node) { sequence: xpath(%w[Sequence], node).to_i, improvement_summary: improvement_code ? accessor.fetch_details(schema_version: "SAP-Schema-19.0.0", improvement_number: improvement_code).summary : xpath(%w[Improvement-Summary], node), improvement_description: improvement_code ? accessor.fetch_details(schema_version: "SAP-Schema-19.0.0", improvement_number: improvement_code).description : xpath(%w[Improvement-Description], node), improvement_code: xpath(%w[Improvement-Details Improvement-Number], node), indicative_cost: xpath(%w[Indicative-Cost], node), } end end |
#related_party_disclosure_number ⇒ Object
89 90 91 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 89 def xpath(%w[Related-Party-Disclosure-Number])&.to_i end |
#related_party_disclosure_text ⇒ Object
85 86 87 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 85 def xpath(%w[Related-Party-Disclosure-Text]) end |
#report_type ⇒ Object
481 482 483 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 481 def report_type xpath(%w[Report-Type]) end |
#sap_main_heating_code ⇒ Object
338 339 340 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 338 def sap_main_heating_code xpath(%w[SAP-Main-Heating-Code]) end |
#scheme_assessor_id ⇒ Object
30 31 32 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 30 def scheme_assessor_id xpath(%w[Certificate-Number]) end |
#secondary_fuel_type ⇒ Object
322 323 324 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 322 def secondary_fuel_type xpath(%w[Secondary-Fuel-Type]) end |
#secondary_heating_description ⇒ Object
441 442 443 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 441 def secondary_heating_description xpath(%w[Secondary-Heating Description]) end |
#secondary_heating_energy_efficiency_rating ⇒ Object
445 446 447 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 445 def xpath(%w[Secondary-Heating Energy-Efficiency-Rating]) end |
#secondary_heating_environmental_efficiency_rating ⇒ Object
449 450 451 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 449 def xpath(%w[Secondary-Heating Environmental-Efficiency-Rating]) end |
#storey_count ⇒ Object
280 281 282 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 280 def storey_count xpath(%w[Storeys]) end |
#tenure ⇒ Object
227 228 229 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 227 def tenure xpath(%w[Tenure]) end |
#thermal_store ⇒ Object
583 584 585 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 583 def thermal_store xpath(%w[Thermal-Store]) end |
#top_storey ⇒ Object
275 276 277 278 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 275 def top_storey flat_level_code = xpath(%w[SAP-FlatLevelCode]) flat_level_code == "3" ? "Y" : "N" end |
#total_floor_area ⇒ Object
183 184 185 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 183 def total_floor_area xpath(%w[Property-Summary Total-Floor-Area])&.to_i end |
#total_roof_area ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 187 def total_roof_area roofs = @xml_doc.xpath("//SAP-Roofs/SAP-Roof") return nil if roofs.count.zero? total_roof_area = 0 roofs.each do |roof| roof_area = roof.at("Total-Roof-Area")&.content.to_i total_roof_area += roof_area end total_roof_area end |
#town ⇒ Object
22 23 24 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 22 def town xpath(%w[Report-Header Property Address Post-Town]) end |
#transaction_type ⇒ Object
231 232 233 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 231 def transaction_type xpath(%w[Transaction-Type]) end |
#type_of_assessment ⇒ Object
267 268 269 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 267 def type_of_assessment "SAP" end |
#ventilation_type ⇒ Object
587 588 589 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 587 def ventilation_type xpath(%w[Ventilation-Type]) end |
#water_heating_fuel ⇒ Object
326 327 328 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 326 def water_heating_fuel xpath(%w[Water-Fuel-Type]) end |
#wind_turbine_count ⇒ Object
469 470 471 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 469 def wind_turbine_count @xml_doc.search("Wind-Turbines/Wind-Turbine").map(&:content).count end |
#window_description ⇒ Object
429 430 431 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 429 def window_description xpath(%w[Windows Description]) end |
#window_energy_efficiency_rating ⇒ Object
433 434 435 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 433 def xpath(%w[Windows Energy-Efficiency-Rating]) end |
#window_environmental_efficiency_rating ⇒ Object
437 438 439 |
# File 'lib/view_model/sap_schema_1900/common_schema.rb', line 437 def xpath(%w[Windows Environmental-Efficiency-Rating]) end |