Class: ViewModel::Cepc800::Dec

Inherits:
CommonSchema show all
Defined in:
lib/view_model/cepc800/dec.rb

Instance Method Summary collapse

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, #company_address, #company_name, #date_of_assessment, #date_of_issue, #date_of_registration, #inspection_type, #or_assessment_end_date, #postcode, #report_type, #scheme_assessor_id, #town

Methods inherited from BaseViewModel

#initialize, #xpath

Constructor Details

This class inherits a constructor from ViewModel::BaseViewModel

Instance Method Details

#ac_inspection_commissionedObject



210
211
212
# File 'lib/view_model/cepc800/dec.rb', line 210

def ac_inspection_commissioned
  xpath(%w[AC-Inspection-Commissioned])
end

#ac_kw_ratingObject



218
219
220
# File 'lib/view_model/cepc800/dec.rb', line 218

def ac_kw_rating
  xpath(%w[AC-kW-Rating])&.to_i
end

#ac_presentObject



214
215
216
# File 'lib/view_model/cepc800/dec.rb', line 214

def ac_present
  xpath(%w[AC-Present])
end

#annual_energy_summaryObject



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/view_model/cepc800/dec.rb', line 178

def annual_energy_summary
  summary = @xml_doc.search("DEC-Annual-Energy-Summary")
  {
    electrical: xpath(%w[Annual-Energy-Use-Electrical], summary),
    fuel_thermal: xpath(%w[Annual-Energy-Use-Fuel-Thermal], summary),
    renewables_fuel_thermal: xpath(%w[Renewables-Fuel-Thermal], summary),
    renewables_electrical: xpath(%w[Renewables-Electrical], summary),
    typical_thermal_use: xpath(%w[Typical-Thermal-Use], summary),
    typical_electrical_use: xpath(%w[Typical-Electrical-Use], summary),
  }
end

#annual_energy_use_electricalObject



102
103
104
# File 'lib/view_model/cepc800/dec.rb', line 102

def annual_energy_use_electrical
  xpath(%w[DEC-Annual-Energy-Summary Annual-Energy-Use-Electrical])
end

#annual_energy_use_fuel_thermalObject



98
99
100
# File 'lib/view_model/cepc800/dec.rb', line 98

def annual_energy_use_fuel_thermal
  xpath(%w[Annual-Energy-Use-Fuel-Thermal])
end

#asset_ratingObject



94
95
96
# File 'lib/view_model/cepc800/dec.rb', line 94

def asset_rating
  xpath(%w[OR-Previous-Data Asset-Rating])&.to_i
end

#benchmarksObject



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/view_model/cepc800/dec.rb', line 150

def benchmarks
  @xml_doc
    .search("Benchmarks/Benchmark")
    .map do |node|
      {
        name: xpath(%w[Name], node),
        id: xpath(%w[Benchmark-ID], node)&.to_i,
        tufa: xpath(%w[TUFA], node),
      }
    end
end

#building_categoryObject



226
227
228
# File 'lib/view_model/cepc800/dec.rb', line 226

def building_category
  xpath(%w[Building-Category])
end

#building_environmentObject



86
87
88
# File 'lib/view_model/cepc800/dec.rb', line 86

def building_environment
  xpath(%w[Technical-Information Building-Environment])
end

#calculation_toolObject



130
131
132
# File 'lib/view_model/cepc800/dec.rb', line 130

def calculation_tool
  xpath(%w[Calculation-Details Calculation-Tool])
end

#current_assessment_dateObject



26
27
28
# File 'lib/view_model/cepc800/dec.rb', line 26

def current_assessment_date
  xpath(%w[This-Assessment Nominated-Date])
end

#current_electricity_co2Object



34
35
36
# File 'lib/view_model/cepc800/dec.rb', line 34

def current_electricity_co2
  xpath(%w[This-Assessment Electricity-CO2])&.to_i
end

#current_heating_co2Object



30
31
32
# File 'lib/view_model/cepc800/dec.rb', line 30

def current_heating_co2
  xpath(%w[This-Assessment Heating-CO2])&.to_i
end

#current_renewables_co2Object



38
39
40
# File 'lib/view_model/cepc800/dec.rb', line 38

def current_renewables_co2
  xpath(%w[This-Assessment Renewables-CO2])&.to_i
end

#date_of_expiryObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/view_model/cepc800/dec.rb', line 6

def date_of_expiry
  floor_area =
    xpath(%w[Display-Certificate Technical-Information Floor-Area])

  expiry_date = Date.parse(current_assessment_date)

  expiry_date =
    if floor_area.to_i <= 1000 && !postcode.start_with?("BT")
      (expiry_date - 1).next_year 10
    else
      (expiry_date - 1).next_year 1
    end

  expiry_date.strftime("%F")
end


126
127
128
# File 'lib/view_model/cepc800/dec.rb', line 126

def dec_related_party_disclosure
  xpath(%w[DEC-Related-Party-Disclosure])
end

#dec_statusObject



122
123
124
# File 'lib/view_model/cepc800/dec.rb', line 122

def dec_status
  xpath(%w[DEC-Status])
end

#energy_efficiency_ratingObject



22
23
24
# File 'lib/view_model/cepc800/dec.rb', line 22

def energy_efficiency_rating
  xpath(%w[This-Assessment Energy-Rating])&.to_i
end

#estimated_ac_kw_ratingObject



222
223
224
# File 'lib/view_model/cepc800/dec.rb', line 222

def estimated_ac_kw_rating
  xpath(%w[AC-Estimated-Output])&.to_i
end

#floor_areaObject



90
91
92
# File 'lib/view_model/cepc800/dec.rb', line 90

def floor_area
  xpath(%w[Technical-Information Floor-Area])
end

#main_benchmarkObject



194
195
196
# File 'lib/view_model/cepc800/dec.rb', line 194

def main_benchmark
  xpath(%w[OR-Benchmark-Data Main-Benchmark])
end

#main_heating_fuelObject



82
83
84
# File 'lib/view_model/cepc800/dec.rb', line 82

def main_heating_fuel
  xpath(%w[Technical-Information Main-Heating-Fuel])
end

#occupancy_levelObject



206
207
208
# File 'lib/view_model/cepc800/dec.rb', line 206

def occupancy_level
  xpath(%w[Benchmarks Benchmark Occupancy-Level])
end

#occupierObject



146
147
148
# File 'lib/view_model/cepc800/dec.rb', line 146

def occupier
  xpath(%w[Occupier])
end

#or_assessment_start_dateObject



142
143
144
# File 'lib/view_model/cepc800/dec.rb', line 142

def or_assessment_start_date
  xpath(%w[OR-Operational-Rating OR-Assessment-Start-Date])
end

#or_energy_consumptionObject



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/view_model/cepc800/dec.rb', line 162

def or_energy_consumption
  @xml_doc
    .search("OR-Energy-Consumption")
    .children
    .select(&:element?)
    .map do |node|
      {
        consumption: xpath(%w[Consumption], node),
        start_date: xpath(%w[Start-Date], node),
        end_date: xpath(%w[End-Date], node),
        estimate: xpath(%w[Estimate], node)&.to_i,
        name: node.name,
      }
    end
end

#other_fuelObject



198
199
200
# File 'lib/view_model/cepc800/dec.rb', line 198

def other_fuel
  xpath(%w[Technical-Information Other-Fuel-Description])
end

#output_engineObject



138
139
140
# File 'lib/view_model/cepc800/dec.rb', line 138

def output_engine
  xpath(%w[Output-Engine])
end

#property_typeObject



190
191
192
# File 'lib/view_model/cepc800/dec.rb', line 190

def property_type
  xpath(%w[Property-Type])
end


134
135
136
# File 'lib/view_model/cepc800/dec.rb', line 134

def related_rrn
  xpath(%w[Related-RRN])
end

#renewables_electricalObject



118
119
120
# File 'lib/view_model/cepc800/dec.rb', line 118

def renewables_electrical
  xpath(%w[DEC-Annual-Energy-Summary Renewables-Electrical])
end

#renewables_fuel_thermalObject



114
115
116
# File 'lib/view_model/cepc800/dec.rb', line 114

def renewables_fuel_thermal
  xpath(%w[DEC-Annual-Energy-Summary Renewables-Fuel-Thermal])
end

#special_energy_usesObject



202
203
204
# File 'lib/view_model/cepc800/dec.rb', line 202

def special_energy_uses
  xpath(%w[Technical-Information Special-Energy-Uses])
end

#typical_electrical_useObject



110
111
112
# File 'lib/view_model/cepc800/dec.rb', line 110

def typical_electrical_use
  xpath(%w[DEC-Annual-Energy-Summary Typical-Electrical-Use])
end

#typical_thermal_useObject



106
107
108
# File 'lib/view_model/cepc800/dec.rb', line 106

def typical_thermal_use
  xpath(%w[DEC-Annual-Energy-Summary Typical-Thermal-Use])
end

#year1_assessment_dateObject



42
43
44
# File 'lib/view_model/cepc800/dec.rb', line 42

def year1_assessment_date
  xpath(%w[Year1-Assessment Nominated-Date])
end

#year1_electricity_co2Object



50
51
52
# File 'lib/view_model/cepc800/dec.rb', line 50

def year1_electricity_co2
  xpath(%w[Year1-Assessment Electricity-CO2])&.to_i
end

#year1_energy_efficiency_ratingObject



58
59
60
# File 'lib/view_model/cepc800/dec.rb', line 58

def year1_energy_efficiency_rating
  xpath(%w[Year1-Assessment Energy-Rating])&.to_i
end

#year1_heating_co2Object



46
47
48
# File 'lib/view_model/cepc800/dec.rb', line 46

def year1_heating_co2
  xpath(%w[Year1-Assessment Heating-CO2])&.to_i
end

#year1_renewables_co2Object



54
55
56
# File 'lib/view_model/cepc800/dec.rb', line 54

def year1_renewables_co2
  xpath(%w[Year1-Assessment Renewables-CO2])&.to_i
end

#year2_assessment_dateObject



62
63
64
# File 'lib/view_model/cepc800/dec.rb', line 62

def year2_assessment_date
  xpath(%w[Year2-Assessment Nominated-Date])
end

#year2_electricity_co2Object



70
71
72
# File 'lib/view_model/cepc800/dec.rb', line 70

def year2_electricity_co2
  xpath(%w[Year2-Assessment Electricity-CO2])&.to_i
end

#year2_energy_efficiency_ratingObject



78
79
80
# File 'lib/view_model/cepc800/dec.rb', line 78

def year2_energy_efficiency_rating
  xpath(%w[Year2-Assessment Energy-Rating])&.to_i
end

#year2_heating_co2Object



66
67
68
# File 'lib/view_model/cepc800/dec.rb', line 66

def year2_heating_co2
  xpath(%w[Year2-Assessment Heating-CO2])&.to_i
end

#year2_renewables_co2Object



74
75
76
# File 'lib/view_model/cepc800/dec.rb', line 74

def year2_renewables_co2
  xpath(%w[Year2-Assessment Renewables-CO2])&.to_i
end