Class: ViewModel::Cepc31::CepcRr

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



41
42
43
# File 'lib/view_model/cepc31/cepc_rr.rb', line 41

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

#calculation_toolsObject



45
46
47
# File 'lib/view_model/cepc31/cepc_rr.rb', line 45

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

#floor_areaObject



37
38
39
# File 'lib/view_model/cepc31/cepc_rr.rb', line 37

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

#long_payback_recommendationsObject



29
30
31
# File 'lib/view_model/cepc31/cepc_rr.rb', line 29

def long_payback_recommendations
  recommendations("Long-Payback")
end

#medium_payback_recommendationsObject



25
26
27
# File 'lib/view_model/cepc31/cepc_rr.rb', line 25

def medium_payback_recommendations
  recommendations("Medium-Payback")
end

#other_recommendationsObject



33
34
35
# File 'lib/view_model/cepc31/cepc_rr.rb', line 33

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
19
# File 'lib/view_model/cepc31/cepc_rr.rb', line 4

def recommendations(payback = "")
  if payback.empty?
    # return an enumerable of all nodes
    @xml_doc.xpath "RR-Recommendations"
  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


49
50
51
# File 'lib/view_model/cepc31/cepc_rr.rb', line 49

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


53
54
55
# File 'lib/view_model/cepc31/cepc_rr.rb', line 53

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

#short_payback_recommendationsObject



21
22
23
# File 'lib/view_model/cepc31/cepc_rr.rb', line 21

def short_payback_recommendations
  recommendations("Short-Payback")
end

#special_energy_usesObject



57
58
59
# File 'lib/view_model/cepc31/cepc_rr.rb', line 57

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