Class: ViewModel::CepcNi800::CepcRr

Inherits:
CommonSchema show all
Defined in:
lib/view_model/cepc_ni800/cepc_rr.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, #calculation_tool, #company_address, #company_name, #date_of_assessment, #date_of_expiry, #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

#building_environmentObject



40
41
42
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 40

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

#calculation_toolsObject



44
45
46
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 44

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

#floor_areaObject



36
37
38
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 36

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

#long_payback_recommendationsObject



28
29
30
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 28

def long_payback_recommendations
  recommendations("Long-Payback")
end

#medium_payback_recommendationsObject



24
25
26
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 24

def medium_payback_recommendations
  recommendations("Medium-Payback")
end

#other_recommendationsObject



32
33
34
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 32

def other_recommendations
  recommendations("Other-Payback")
end

#recommendations(payback = "") ⇒ Object



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

def recommendations(payback = "")
  if payback.empty?
    @xml_doc.search(%w[RR-Recommendations]).map { |node| node }
  else
    @xml_doc
      .search("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


48
49
50
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 48

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


52
53
54
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 52

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

#short_payback_recommendationsObject



20
21
22
# File 'lib/view_model/cepc_ni800/cepc_rr.rb', line 20

def short_payback_recommendations
  recommendations("Short-Payback")
end