Sha256: 2e1a820bc989fc3994bd40a4249f468c971d8422552528f8e34b12397c0a975f

Contents?: true

Size: 1.56 KB

Versions: 41

Compression:

Stored size: 1.56 KB

Contents

module ViewModel
  module Cepc800
    class AcCert < ViewModel::Cepc800::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.0.20 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.19 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.18 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.17 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.16 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.15 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.14 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.13 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.12 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.11 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.10 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.9 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.8 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.7 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.6 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.5 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.4 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.3 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.2 lib/view_model/cepc800/ac_cert.rb
epb_view_models-1.0.1 lib/view_model/cepc800/ac_cert.rb