Sha256: f5d3eba0b95df5973999f8d6f025a601417475ce7ed196d1bbfd9084f0102200

Contents?: true

Size: 1.55 KB

Versions: 41

Compression:

Stored size: 1.55 KB

Contents

module ViewModel
  module Cepc70
    class AcCert < ViewModel::Cepc70::CommonSchema
      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

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

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

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

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

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

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

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

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

      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
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
epb_view_models-1.2.3 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.2.2 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.2.1 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.2.0 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.6 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.5 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.4 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.3 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.2 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.1 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.1.0 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.29 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.28 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.27 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.26 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.25 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.24 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.23 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.22 lib/view_model/cepc70/ac_cert.rb
epb_view_models-1.0.21 lib/view_model/cepc70/ac_cert.rb