Class: ViewModel::Cepc51::Dec

Inherits:
CommonSchema show all
Defined in:
lib/view_model/cepc51/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



196
197
198
# File 'lib/view_model/cepc51/dec.rb', line 196

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

#ac_kw_ratingObject



204
205
206
# File 'lib/view_model/cepc51/dec.rb', line 204

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

#ac_presentObject



200
201
202
# File 'lib/view_model/cepc51/dec.rb', line 200

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

#annual_energy_summaryObject



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/view_model/cepc51/dec.rb', line 176

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



108
109
110
# File 'lib/view_model/cepc51/dec.rb', line 108

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

#annual_energy_use_fuel_thermalObject



104
105
106
# File 'lib/view_model/cepc51/dec.rb', line 104

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

#asset_ratingObject



100
101
102
# File 'lib/view_model/cepc51/dec.rb', line 100

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

#benchmarksObject



156
157
158
# File 'lib/view_model/cepc51/dec.rb', line 156

def benchmarks
  []
end

#building_categoryObject



212
213
214
# File 'lib/view_model/cepc51/dec.rb', line 212

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

#building_environmentObject



92
93
94
# File 'lib/view_model/cepc51/dec.rb', line 92

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

#calculation_toolObject



136
137
138
# File 'lib/view_model/cepc51/dec.rb', line 136

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

#current_assessment_dateObject



24
25
26
# File 'lib/view_model/cepc51/dec.rb', line 24

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

#current_electricity_co2Object



32
33
34
# File 'lib/view_model/cepc51/dec.rb', line 32

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

#current_heating_co2Object



28
29
30
# File 'lib/view_model/cepc51/dec.rb', line 28

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

#current_renewables_co2Object



36
37
38
# File 'lib/view_model/cepc51/dec.rb', line 36

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

#date_of_expiryObject



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

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


132
133
134
# File 'lib/view_model/cepc51/dec.rb', line 132

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

#dec_statusObject



128
129
130
# File 'lib/view_model/cepc51/dec.rb', line 128

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

#energy_efficiency_ratingObject



20
21
22
# File 'lib/view_model/cepc51/dec.rb', line 20

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

#estimated_ac_kw_ratingObject



208
209
210
# File 'lib/view_model/cepc51/dec.rb', line 208

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

#floor_areaObject



96
97
98
# File 'lib/view_model/cepc51/dec.rb', line 96

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

#main_benchmarkObject



192
193
194
# File 'lib/view_model/cepc51/dec.rb', line 192

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

#main_heating_fuelObject



88
89
90
# File 'lib/view_model/cepc51/dec.rb', line 88

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

#occupancy_levelObject



84
85
86
# File 'lib/view_model/cepc51/dec.rb', line 84

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

#occupierObject



152
153
154
# File 'lib/view_model/cepc51/dec.rb', line 152

def occupier
  xpath(%w[Occupier])
end

#or_assessment_start_dateObject



148
149
150
# File 'lib/view_model/cepc51/dec.rb', line 148

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

#or_energy_consumptionObject



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

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



216
217
218
# File 'lib/view_model/cepc51/dec.rb', line 216

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

#output_engineObject



144
145
146
# File 'lib/view_model/cepc51/dec.rb', line 144

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

#property_typeObject



188
189
190
# File 'lib/view_model/cepc51/dec.rb', line 188

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


140
141
142
# File 'lib/view_model/cepc51/dec.rb', line 140

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

#renewables_electricalObject



124
125
126
# File 'lib/view_model/cepc51/dec.rb', line 124

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

#renewables_fuel_thermalObject



120
121
122
# File 'lib/view_model/cepc51/dec.rb', line 120

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

#special_energy_usesObject



76
77
78
# File 'lib/view_model/cepc51/dec.rb', line 76

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

#typical_electrical_useObject



116
117
118
# File 'lib/view_model/cepc51/dec.rb', line 116

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

#typical_thermal_useObject



112
113
114
# File 'lib/view_model/cepc51/dec.rb', line 112

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

#year1_assessment_dateObject



40
41
42
# File 'lib/view_model/cepc51/dec.rb', line 40

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

#year1_electricity_co2Object



48
49
50
# File 'lib/view_model/cepc51/dec.rb', line 48

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

#year1_energy_efficiency_ratingObject



56
57
58
# File 'lib/view_model/cepc51/dec.rb', line 56

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

#year1_heating_co2Object



44
45
46
# File 'lib/view_model/cepc51/dec.rb', line 44

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

#year1_renewables_co2Object



52
53
54
# File 'lib/view_model/cepc51/dec.rb', line 52

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

#year2_assessment_dateObject



60
61
62
# File 'lib/view_model/cepc51/dec.rb', line 60

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

#year2_electricity_co2Object



68
69
70
# File 'lib/view_model/cepc51/dec.rb', line 68

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

#year2_energy_efficiency_ratingObject



80
81
82
# File 'lib/view_model/cepc51/dec.rb', line 80

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

#year2_heating_co2Object



64
65
66
# File 'lib/view_model/cepc51/dec.rb', line 64

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

#year2_renewables_co2Object



72
73
74
# File 'lib/view_model/cepc51/dec.rb', line 72

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