# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 159 def primary_energy_use xpath(%w[Energy-Consumption-Current]) end
class ViewModel::SapSchemaNi120::CommonSchema
Public Instance Methods
address_id()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 61 def address_id "LPRN-#{xpath(%w[UPRN])}" end
address_line1()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 8 def address_line1 xpath(%w[Property Address Address-Line-1]) end
address_line2()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 12 def address_line2 xpath(%w[Property Address Address-Line-2]).to_s end
address_line3()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 16 def address_line3 xpath(%w[Property Address Address-Line-3]).to_s end
address_line4()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 20 def address_line4 xpath(%w[Property Address Address-Line-4]).to_s end
all_floor_descriptions()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 466 def all_floor_descriptions @xml_doc.search("Property-Summary/Floor/Description").map(&:content) end
all_floor_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 470 def all_floor_energy_efficiency_rating @xml_doc .search("Property-Summary/Floor/Energy-Efficiency-Rating") .map(&:content) end
all_floor_env_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 476 def all_floor_env_energy_efficiency_rating @xml_doc .search("Property-Summary/Floor/Environmental-Efficiency-Rating") .map(&:content) end
all_main_heating_controls_descriptions()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 386 def all_main_heating_controls_descriptions @xml_doc.search("Main-Heating-Controls/Description").map(&:content) end
all_main_heating_controls_energy_efficiency()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 482 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()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 488 def all_main_heating_controls_environmental_efficiency @xml_doc .search("Main-Heating-Controls/Environmental-Efficiency-Rating") .map(&:content) end
all_main_heating_descriptions()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 378 def all_main_heating_descriptions @xml_doc.search("Main-Heating/Description").map(&:content) end
all_main_heating_energy_efficiency()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 426 def all_main_heating_energy_efficiency @xml_doc.search("Main-Heating/Energy-Efficiency-Rating").map(&:content) end
all_main_heating_environmental_efficiency()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 456 def all_main_heating_environmental_efficiency @xml_doc .search("Main-Heating/Environmental-Efficiency-Rating") .map(&:content) end
all_roof_descriptions()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 394 def all_roof_descriptions @xml_doc.search("Roof/Description").map(&:content) end
all_roof_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 398 def all_roof_energy_efficiency_rating @xml_doc.search("Roof/Energy-Efficiency-Rating").map(&:content) end
all_roof_env_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 402 def all_roof_env_energy_efficiency_rating @xml_doc.search("Roof/Environmental-Efficiency-Rating").map(&:content) end
all_wall_descriptions()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 406 def all_wall_descriptions @xml_doc.search("Walls/Description").map(&:content) end
all_wall_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 410 def all_wall_energy_efficiency_rating @xml_doc.search("Walls/Energy-Efficiency-Rating").map(&:content) end
all_wall_env_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 414 def all_wall_env_energy_efficiency_rating @xml_doc.search("Walls/Environmental-Efficiency-Rating").map(&:content) end
assessment_id()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 4 def assessment_id xpath(%w[RRN]) end
assessor_email()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 45 def assessor_email xpath(%w[Home-Inspector E-Mail]) end
assessor_name()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 36 def assessor_name [ xpath(%w[Home-Inspector Name Prefix]), xpath(%w[Home-Inspector Name First-Name]), xpath(%w[Home-Inspector Name Surname]), xpath(%w[Home-Inspector Name Suffix]), ].reject { |e| e.to_s.empty? }.join(" ") end
assessor_telephone()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 49 def assessor_telephone xpath(%w[Home-Inspector Telephone]) end
built_form()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 362 def built_form xpath(%w[Built-Form]) end
co2_emissions_current_per_floor_area()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 253 def co2_emissions_current_per_floor_area xpath(%w[CO2-Emissions-Current-Per-Floor-Area]) end
country_code()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 222 def country_code xpath(%w[Country-Code]) end
current_carbon_emission()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 147 def current_carbon_emission xpath(%w[CO2-Emissions-Current]) end
current_energy_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 155 def current_energy_rating xpath(%w[Energy-Rating-Current]).to_i end
current_space_heating_demand()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 196 def current_space_heating_demand xpath(%w[Space-Heating-Existing-Dwelling]) end
current_water_heating_demand()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 200 def current_water_heating_demand xpath(%w[Water-Heating]) end
date_of_assessment()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 53 def date_of_assessment xpath(%w[Inspection-Date]) end
date_of_expiry()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 65 def date_of_expiry expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10 expires_at.to_s end
date_of_registration()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 57 def date_of_registration xpath(%w[Registration-Date]) end
dwelling_type()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 178 def dwelling_type xpath(%w[Dwelling-Type]) end
energy_consumption_potential()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 163 def energy_consumption_potential xpath(%w[Energy-Consumption-Potential]) end
energy_tariff()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 418 def energy_tariff xpath(%w[Electricity-Tariff]) end
environmental_impact_current()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 245 def environmental_impact_current xpath(%w[Environmental-Impact-Current]) end
environmental_impact_potential()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 249 def environmental_impact_potential xpath(%w[Environmental-Impact-Potential]) end
estimated_energy_cost()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 167 def estimated_energy_cost xpath(%w[Estimated-Energy-Cost]) end
extensions_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 382 def extensions_count xpath(%w[Extensions-Count]) end
fixed_lighting_outlets_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 298 def fixed_lighting_outlets_count xpath(%w[Fixed-Lighting-Outlets-Count]) end
floor_height()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 462 def floor_height @xml_doc.search("Storey-Height").map(&:content) end
floor_level()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 422 def floor_level xpath(%w[SAP-Flat-Details Level]) end
glazed_area()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 282 def glazed_area nil end
habitable_room_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 286 def habitable_room_count nil end
heat_loss_corridor()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 370 def heat_loss_corridor xpath(%w[Heat-Loss-Corridor]) end
heated_room_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 290 def heated_room_count nil end
heating_cost_current()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 135 def heating_cost_current xpath(%w[Heating-Cost-Current]) end
heating_cost_potential()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 123 def heating_cost_potential xpath(%w[Heating-Cost-Potential]) end
hot_water_cost_current()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 131 def hot_water_cost_current xpath(%w[Hot-Water-Cost-Current]) end
hot_water_cost_potential()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 119 def hot_water_cost_potential xpath(%w[Hot-Water-Cost-Potential]) end
hot_water_description()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 310 def hot_water_description xpath(%w[Hot-Water Description]) end
hot_water_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 314 def hot_water_energy_efficiency_rating xpath(%w[Hot-Water Energy-Efficiency-Rating]) end
hot_water_environmental_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 318 def hot_water_environmental_efficiency_rating xpath(%w[Hot-Water Environmental-Efficiency-Rating]) end
impact_of_cavity_insulation()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 204 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()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 210 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()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 216 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()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 96 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()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 261 def level xpath(%w[Level]) end
lighting_cost_current()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 139 def lighting_cost_current xpath(%w[Lighting-Cost-Current]) end
lighting_cost_potential()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 127 def lighting_cost_potential xpath(%w[Lighting-Cost-Potential]) end
lighting_description()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 346 def lighting_description xpath(%w[Lighting Description]) end
lighting_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 350 def lighting_energy_efficiency_rating xpath(%w[Lighting Energy-Efficiency-Rating]) end
lighting_environmental_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 354 def lighting_environmental_efficiency_rating xpath(%w[Lighting Environmental-Efficiency-Rating]) end
low_energy_fixed_lighting_outlets_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 302 def low_energy_fixed_lighting_outlets_count xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Count]) end
low_energy_lighting()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 294 def low_energy_lighting xpath(%w[Low-Energy-Fixed-Lighting-Outlets-Percentage]) end
main_dwelling_construction_age_band_or_year()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 438 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()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 226 def main_fuel_type xpath(%w[Main-Fuel-Type]) end
main_heating_controls()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 274 def main_heating_controls xpath(%w[Main-Heating-Controls Description]) end
mains_gas()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 257 def mains_gas nil end
mechanical_ventilation()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 434 def mechanical_ventilation nil end
multiple_glazed_proportion()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 278 def multiple_glazed_proportion xpath(%w[Multiple-Glazed-Proportion]) end
open_fireplaces_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 306 def open_fireplaces_count xpath(%w[Open-Fireplaces-Count]) end
photovoltaic_roof_area_percent()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 358 def photovoltaic_roof_area_percent nil end
postcode()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 28 def postcode xpath(%w[Property Address Postcode]) end
potential_carbon_emission()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 143 def potential_carbon_emission xpath(%w[CO2-Emissions-Potential]) end
potential_energy_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 151 def potential_energy_rating xpath(%w[Energy-Rating-Potential]).to_i end
potential_energy_saving()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 182 def potential_energy_saving; end
primary_energy_use()
click to toggle source
property_age_band()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 184 def property_age_band xpath(%w[Construction-Year]) end
property_summary()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 71 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
report_type()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 390 def report_type xpath(%w[Report-Type]) end
scheme_assessor_id()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 32 def scheme_assessor_id xpath(%w[Certificate-Number]) end
secondary_fuel_type()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 230 def secondary_fuel_type xpath(%w[Secondary-Fuel-Type]) end
secondary_heating_description()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 334 def secondary_heating_description xpath(%w[Secondary-Heating Description]) end
secondary_heating_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 338 def secondary_heating_energy_efficiency_rating xpath(%w[Secondary-Heating Energy-Efficiency-Rating]) end
secondary_heating_environmental_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 342 def secondary_heating_environmental_efficiency_rating xpath(%w[Secondary-Heating Environmental-Efficiency-Rating]) end
solar_water_heating_flag()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 430 def solar_water_heating_flag nil end
storey_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 270 def storey_count nil end
tenure()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 188 def tenure nil end
top_storey()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 265 def top_storey flat_level_code = xpath(%w[Level]) flat_level_code == "3" ? "Y" : "N" end
total_floor_area()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 171 def total_floor_area building_part_areas = @xml_doc.search("//SAP-Building-Part/SAP-Floor-Dimensions/SAP-Floor-Dimension/Total-Floor-Area").map(&:content) room_in_roof_areas = @xml_doc.search("//SAP-Building-Part/SAP-Room-In-Roof/Floor-Area").map(&:content) all_areas = (building_part_areas + room_in_roof_areas).map(&:to_f) all_areas.sum.round.to_i.to_s end
town()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 24 def town xpath(%w[Property Address Post-Town]) end
transaction_type()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 192 def transaction_type xpath(%w[Transaction-Type]) end
type_of_assessment()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 234 def type_of_assessment case xpath(%w[Report-Type]).to_i when 1 "HCR" when 2 "RdSAP" else "SAP" end end
unheated_corridor_length()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 374 def unheated_corridor_length xpath(%w[Unheated-Corridor-Length]) end
wind_turbine_count()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 366 def wind_turbine_count xpath(%w[Wind-Turbines-Count]) end
window_description()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 322 def window_description xpath(%w[Windows Description]) end
window_energy_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 326 def window_energy_efficiency_rating xpath(%w[Windows Energy-Efficiency-Rating]) end
window_environmental_efficiency_rating()
click to toggle source
# File lib/view_model/sap_schema_ni_120/common_schema.rb, line 330 def window_environmental_efficiency_rating xpath(%w[Windows Environmental-Efficiency-Rating]) end