Sha256: 9a7d7a162e2f561b4abe14a4cbf47d24a5816576b76577c6bde1c74ed28c1dd8

Contents?: true

Size: 1.93 KB

Versions: 49

Compression:

Stored size: 1.93 KB

Contents

module ViewModel
  module CepcNi800
    class DecRr < ViewModel::CepcNi800::CommonSchema
      def date_of_expiry
        expiry_date = (Date.parse(date_of_issue) - 1).next_year 7

        expiry_date.strftime("%F")
      end

      def recommendations(payback)
        @xml_doc
          .search("AR-Recommendations/#{payback}")
          .map do |node|
            {
              code: node.at("Recommendation-Code").content,
              text: node.at("Recommendation").content,
              cO2Impact: node.at("CO2-Impact").content,
            }
          end
      end

      def site_services(service)
        {
          description:
            @xml_doc.at("Site-Services/#{service}/Description").content,
          quantity: @xml_doc.at("Site-Services/#{service}/Quantity").content,
        }
      end

      def site_service_one
        site_services("Service-1")
      end

      def site_service_two
        site_services("Service-2")
      end

      def site_service_three
        site_services("Service-3")
      end

      def short_payback_recommendations
        recommendations("Short-Payback")
      end

      def medium_payback_recommendations
        recommendations("Medium-Payback")
      end

      def long_payback_recommendations
        recommendations("Long-Payback")
      end

      def other_recommendations
        recommendations("Other-Payback")
      end

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

      def building_environment
        xpath(%w[Advisory-Report Technical-Information Building-Environment])
      end

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

      def occupier
        xpath(%w[Occupier])
      end

      def property_type
        xpath(%w[Property-Type])
      end

      def renewable_sources
        xpath(%w[Renewable-Sources])
      end

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

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
epb_view_models-2.0.7 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.6 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.5 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.4 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.3 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.2 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.1 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-2.0.0 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.2.3 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.2.2 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.2.1 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.2.0 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.6 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.5 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.4 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.3 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.2 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.1 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.1.0 lib/view_model/cepc_ni800/dec_rr.rb
epb_view_models-1.0.29 lib/view_model/cepc_ni800/dec_rr.rb