Class: ViewModel::CepcNi800::AcCert

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

Constructor Details

This class inherits a constructor from ViewModel::BaseViewModel

Instance Method Details

#ac_rated_outputObject



23
24
25
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 23

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

#ac_system_meteredObject



35
36
37
38
39
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 35

def ac_system_metered
  xpath(
    %w[Air-Conditioning-Inspection-Certificate AC-System-Metered-Flag],
  )
end

#building_complexityObject



15
16
17
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 15

def building_complexity
  xpath(%w[Building-Complexity])
end

#f_gas_compliant_dateObject



19
20
21
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 19

def f_gas_compliant_date
  xpath(%w[Air-Conditioning-Inspection-Certificate F-Gas-Compliant-Date])
end

#random_samplingObject



27
28
29
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 27

def random_sampling
  xpath(%w[Air-Conditioning-Inspection-Certificate Random-Sampling-Flag])
end

#refrigerant_chargeObject



41
42
43
44
45
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 41

def refrigerant_charge
  xpath(
    %w[Air-Conditioning-Inspection-Certificate Refrigerant-Charge-Total],
  )&.to_i
end


47
48
49
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 47

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

#subsystemsObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 51

def subsystems
  @xml_doc.search("AC-Sub-System").select(&:element?).map { |node|
    {
      number: xpath(%w[Sub-System-Number], node),
      description: xpath(%w[Sub-System-Description], node),
      age: xpath(%w[Sub-System-Age], node),
      refrigerantType: xpath(%w[Refrigerant-Type], node),
    }
  }.compact
end

#treated_floor_areaObject



31
32
33
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 31

def treated_floor_area
  xpath(%w[Air-Conditioning-Inspection-Certificate Treated-Floor-Area])&.to_i
end

#xpath(queries, node = @xml_doc) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/view_model/cepc_ni800/ac_cert.rb', line 4

def xpath(queries, node = @xml_doc)
  queries.each do |query|
    if node
      node = node.at query
    else
      return nil
    end
  end
  node ? node.content : nil
end