Class: ViewModel::CepcS71::Cepc

Inherits:
ViewModel::Cepc71::CommonSchema show all
Defined in:
lib/view_model/cepc_s_71/cepc.rb

Instance Method Summary collapse

Methods inherited from ViewModel::Cepc71::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, #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

#approximate_energy_useObject



50
51
52
# File 'lib/view_model/cepc_s_71/cepc.rb', line 50

def approximate_energy_use
  xpath(%w[Approximate-Energy-Use])
end

#building_environmentObject



10
11
12
# File 'lib/view_model/cepc_s_71/cepc.rb', line 10

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

#calculation_toolObject



86
87
88
# File 'lib/view_model/cepc_s_71/cepc.rb', line 86

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

#company_nameObject



155
156
157
# File 'lib/view_model/cepc_s_71/cepc.rb', line 155

def company_name
  xpath(%w[Company-Name])
end

#comparative_asset_bandObject



42
43
44
# File 'lib/view_model/cepc_s_71/cepc.rb', line 42

def comparative_asset_band
  xpath(%w[Comparative-Energy-Band])
end

#comparative_asset_ratingObject



38
39
40
# File 'lib/view_model/cepc_s_71/cepc.rb', line 38

def comparative_asset_rating
  xpath(%w[Comparative-Asset-Rating])
end

#compliant_2002Object



70
71
72
# File 'lib/view_model/cepc_s_71/cepc.rb', line 70

def compliant_2002
  xpath(%w[Compliant-2002])
end

#current_energy_efficiency_bandObject



18
19
20
# File 'lib/view_model/cepc_s_71/cepc.rb', line 18

def current_energy_efficiency_band
  xpath(%w[Energy-Band])
end

#date_of_expiryObject



4
5
6
7
8
# File 'lib/view_model/cepc_s_71/cepc.rb', line 4

def date_of_expiry
  expires_at = (Date.parse(date_of_registration) - 1) >> 12 * 10

  expires_at.to_s
end

#electricity_sourcesObject



78
79
80
# File 'lib/view_model/cepc_s_71/cepc.rb', line 78

def electricity_sources
  @xml_doc.search("Electricity-Sources").map(&:content)
end

#energy_efficiency_ratingObject



14
15
16
# File 'lib/view_model/cepc_s_71/cepc.rb', line 14

def energy_efficiency_rating
  xpath(%w[Asset-Rating])&.to_i
end

#epc_rating_berObject



46
47
48
# File 'lib/view_model/cepc_s_71/cepc.rb', line 46

def epc_rating_ber
  xpath(%w[BER])
end


147
148
149
# File 'lib/view_model/cepc_s_71/cepc.rb', line 147

def epc_related_party_disclosure
  xpath(%w[EPC-Related-Party-Disclosure])
end

#existing_build_ratingObject



143
144
145
# File 'lib/view_model/cepc_s_71/cepc.rb', line 143

def existing_build_rating
  xpath(%w[Existing-Stock-Benchmark])&.to_i
end

#floor_areaObject



54
55
56
# File 'lib/view_model/cepc_s_71/cepc.rb', line 54

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

#insurerObject



159
160
161
# File 'lib/view_model/cepc_s_71/cepc.rb', line 159

def insurer
  xpath(%w[Insurer])
end

#insurer_effective_dateObject



167
168
169
# File 'lib/view_model/cepc_s_71/cepc.rb', line 167

def insurer_effective_date
  xpath(%w[Effective-Date])
end

#insurer_expiry_dateObject



171
172
173
# File 'lib/view_model/cepc_s_71/cepc.rb', line 171

def insurer_expiry_date
  xpath(%w[Expiry-Date])
end

#insurer_pi_limitObject



175
176
177
# File 'lib/view_model/cepc_s_71/cepc.rb', line 175

def insurer_pi_limit
  xpath(%w[PI-Limit])
end

#long_payback_recommendationsObject



127
128
129
# File 'lib/view_model/cepc_s_71/cepc.rb', line 127

def long_payback_recommendations
  recommendations("Long-Payback")
end

#main_heating_fuelObject



58
59
60
# File 'lib/view_model/cepc_s_71/cepc.rb', line 58

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

#medium_payback_recommendationsObject



123
124
125
# File 'lib/view_model/cepc_s_71/cepc.rb', line 123

def medium_payback_recommendations
  recommendations("Medium-Payback")
end

#new_build_benchmark_bandObject



34
35
36
# File 'lib/view_model/cepc_s_71/cepc.rb', line 34

def new_build_benchmark_band
  xpath(%w[New-Build-Benchmark-Band])
end

#new_build_benchmark_ratingObject



30
31
32
# File 'lib/view_model/cepc_s_71/cepc.rb', line 30

def new_build_benchmark_rating
  xpath(%w[New-Build-Benchmark])
end

#new_build_ratingObject



139
140
141
# File 'lib/view_model/cepc_s_71/cepc.rb', line 139

def new_build_rating
  xpath(%w[New-Build-Benchmark])&.to_i
end

#other_recommendationsObject



131
132
133
# File 'lib/view_model/cepc_s_71/cepc.rb', line 131

def other_recommendations
  recommendations("Other-Payback")
end

#policy_noObject



163
164
165
# File 'lib/view_model/cepc_s_71/cepc.rb', line 163

def policy_no
  xpath(%w[Policy-No])
end

#potential_energy_bandObject



26
27
28
# File 'lib/view_model/cepc_s_71/cepc.rb', line 26

def potential_energy_band
  xpath(%w[Potential-Band])
end

#potential_energy_ratingObject



22
23
24
# File 'lib/view_model/cepc_s_71/cepc.rb', line 22

def potential_energy_rating
  xpath(%w[Potential-Rating])
end

#primary_energy_indicatorObject



82
83
84
# File 'lib/view_model/cepc_s_71/cepc.rb', line 82

def primary_energy_indicator
  xpath(%w[Primary-Energy-Indicator])
end

#property_short_descriptionObject



66
67
68
# File 'lib/view_model/cepc_s_71/cepc.rb', line 66

def property_short_description
  xpath(%w[Property-Type Short-Description])
end

#property_typeObject



62
63
64
# File 'lib/view_model/cepc_s_71/cepc.rb', line 62

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

#recommendations(payback = "") ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/view_model/cepc_s_71/cepc.rb', line 102

def recommendations(payback = "")
  if payback.empty?
    # return an enumerable of all nodes
    @xml_doc.xpath "Recommendations-Report RR-Recommendations"
  else
    @xml_doc
      .search("Recommendations-Report RR-Recommendations/#{payback}")
      .map do |node|
      {
        code: node.at("Recommendation-Code").content,
        text: node.at("Recommendation").content,
        cO2Impact: node.at("CO2-Impact").content,
      }
    end
  end
end


135
136
137
# File 'lib/view_model/cepc_s_71/cepc.rb', line 135

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

#renewable_energy_sourcesObject



74
75
76
# File 'lib/view_model/cepc_s_71/cepc.rb', line 74

def renewable_energy_sources
  @xml_doc.search("Renewable-Energy-Sources").map(&:content)
end

#renewable_sourcesObject



98
99
100
# File 'lib/view_model/cepc_s_71/cepc.rb', line 98

def renewable_sources
  xpath(%w[Renewable-Sources])
end

#short_payback_recommendationsObject



119
120
121
# File 'lib/view_model/cepc_s_71/cepc.rb', line 119

def short_payback_recommendations
  recommendations("Short-Payback")
end

#terObject



94
95
96
# File 'lib/view_model/cepc_s_71/cepc.rb', line 94

def ter
  xpath(%w[TER])
end

#ter_2002Object



90
91
92
# File 'lib/view_model/cepc_s_71/cepc.rb', line 90

def ter_2002
  xpath(%w[TER-2002])
end

#trading_addressObject



151
152
153
# File 'lib/view_model/cepc_s_71/cepc.rb', line 151

def trading_address
  xpath(%w[Trading-Address])
end