Class: ViewModel::Cepc40::AcReport

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

#air_handling_systemsObject



152
153
154
# File 'lib/view_model/cepc40/ac_report.rb', line 152

def air_handling_systems
  []
end

#checklist_values(checklist) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/view_model/cepc40/ac_report.rb', line 88

def checklist_values(checklist)
  results =
    checklist&.element_children&.map { |node|
      checklist_item = node.name.underscore.to_sym
      value = node.content == "Yes"
      { checklist_item => value }
    }&.inject(&:merge)

  results.nil? ? {} : results
end

#cooling_plantsObject



82
83
84
85
86
# File 'lib/view_model/cepc40/ac_report.rb', line 82

def cooling_plants
  @xml_doc
    .search("Air-Conditioning-Inspection-Report/ACI-Cooling-Plant")
    .map { |_node| {} }
end

#executive_summaryObject



8
9
10
# File 'lib/view_model/cepc40/ac_report.rb', line 8

def executive_summary
  xpath(%w[Executive-Summary])
end

#extract_aci_recommendations(nodes) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/view_model/cepc40/ac_report.rb', line 12

def extract_aci_recommendations(nodes)
  nodes.filter_map do |node|
    unless node.at("Text").content.nil? || node.at("Text").content.empty?
      {
        sequence: node.at("Seq-Number").content&.to_i,
        text: node.at("Text").content,
      }
    end
  end
end

#key_recommendations_controlObject



39
40
41
42
43
44
45
# File 'lib/view_model/cepc40/ac_report.rb', line 39

def key_recommendations_control
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Recommendations/Alternative-Solutions/ACI-Recommendation",
    ),
  )
end

#key_recommendations_efficiencyObject



23
24
25
26
27
28
29
# File 'lib/view_model/cepc40/ac_report.rb', line 23

def key_recommendations_efficiency
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Recommendations/System-Efficiency/ACI-Recommendation",
    ),
  )
end

#key_recommendations_maintenanceObject



31
32
33
34
35
36
37
# File 'lib/view_model/cepc40/ac_report.rb', line 31

def key_recommendations_maintenance
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Recommendations/Improvement-Options/ACI-Recommendation",
    ),
  )
end

#key_recommendations_managementObject



47
48
49
50
51
52
53
# File 'lib/view_model/cepc40/ac_report.rb', line 47

def key_recommendations_management
  extract_aci_recommendations(
    @xml_doc.search(
      "ACI-Recommendations/Other-Recommendations/ACI-Recommendation",
    ),
  )
end

#pre_inspection_checklistObject



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/view_model/cepc40/ac_report.rb', line 99

def pre_inspection_checklist
  pcs_essential =
    checklist_values(
      @xml_doc.at(
        "PCS-Pre-Inspection-Information/PCS-Pre-Inspection-Essential",
      ),
    )
  pcs_desirable =
    checklist_values(
      @xml_doc.at(
        "PCS-Pre-Inspection-Information/PCS-Pre-Inspection-Desirable",
      ),
    )
  pcs_optional =
    checklist_values(
      @xml_doc.at(
        "PCS-Pre-Inspection-Information/PCS-Pre-Inspection-Optional",
      ),
    )

  sccs_essential =
    checklist_values(
      @xml_doc.at(
        "SCCS-Pre-Inspection-Information/SCCS-Pre-Inspection-Essential",
      ),
    )
  sccs_desirable =
    checklist_values(
      @xml_doc.at(
        "SCCS-Pre-Inspection-Information/SCCS-Pre-Inspection-Desirable",
      ),
    )
  sccs_optional =
    checklist_values(
      @xml_doc.at(
        "SCCS-Pre-Inspection-Information/SCCS-Pre-Inspection-Optional",
      ),
    )

  {
    pcs: {
      essential: pcs_essential,
      desirable: pcs_desirable,
      optional: pcs_optional,
    },
    sccs: {
      essential: sccs_essential,
      desirable: sccs_desirable,
      optional: sccs_optional,
    },
  }
end


4
5
6
# File 'lib/view_model/cepc40/ac_report.rb', line 4

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


78
79
80
# File 'lib/view_model/cepc40/ac_report.rb', line 78

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

#sub_systemsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/view_model/cepc40/ac_report.rb', line 55

def sub_systems
  @xml_doc
    .search("ACI-Sub-Systems/ACI-Sub-System")
    .map do |node|
      {
        volume_definitions:
          node.at("Sub-System-Volume-Definitions")&.content,
        id: node.at("Sub-System-ID")&.content,
        description: node.at("Sub-System-Description")&.content,
        cooling_output: node.at("Sub-System-Cooling-Output")&.content,
        area_served:
          node.at("Sub-System-Area-Served-Description")&.content,
        inspection_date: node.at("Sub-System-Inspection-Date")&.content,
        cooling_plant_count:
          node.at("Sub-System-Cooling-Plant-Count")&.content,
        ahu_count: node.at("Sub-System-AHU-Count")&.content,
        terminal_units_count:
          node.at("Sub-System-Terminal-Units-Count")&.content,
        controls_count: node.at("Sub-System-Controls-Count")&.content,
      }
    end
end

#system_controlsObject



160
161
162
# File 'lib/view_model/cepc40/ac_report.rb', line 160

def system_controls
  []
end

#terminal_unitsObject



156
157
158
# File 'lib/view_model/cepc40/ac_report.rb', line 156

def terminal_units
  []
end