Sha256: 0a43455f5f5ce6dfd8166632e674dec092f5cc2124582f46be790cfb57dec338

Contents?: true

Size: 1.38 KB

Versions: 47

Compression:

Stored size: 1.38 KB

Contents

module ViewModel
  class CepcRrWrapper
    attr_reader :view_model

    def initialize(xml_doc, schema_type)
      @view_model = build_view_model(xml_doc, schema_type)
      @summary = Presenter::CepcRr::Summary.new(view_model)
      @recommendation_report = Presenter::CepcRr::RecommendationReport.new(view_model)
    end

    def type
      :CEPC_RR
    end

    def to_hash
      @summary.to_hash
    end

    # FIXME: Method name is not consistent for recommendation reports (see SAP/RdSAP)
    def to_report
      @recommendation_report.to_hash
    end

    def get_view_model
      view_model
    end

  private

    def build_view_model(xml_doc, schema_type)
      case schema_type
      when :"CEPC-8.0.0"
        ViewModel::Cepc800::CepcRr.new xml_doc
      when :"CEPC-NI-8.0.0"
        ViewModel::CepcNi800::CepcRr.new xml_doc
      when :"CEPC-7.1"
        ViewModel::Cepc71::CepcRr.new xml_doc
      when :"CEPC-7.0"
        ViewModel::Cepc70::CepcRr.new xml_doc
      when :"CEPC-6.0"
        ViewModel::Cepc60::CepcRr.new xml_doc
      when :"CEPC-5.1"
        ViewModel::Cepc51::CepcRr.new xml_doc
      when :"CEPC-5.0"
        ViewModel::Cepc50::CepcRr.new xml_doc
      when :"CEPC-4.0"
        ViewModel::Cepc40::CepcRr.new xml_doc
      when :"CEPC-3.1"
        ViewModel::Cepc31::CepcRr.new xml_doc
      else
        raise ArgumentError, "Unsupported schema type"
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
epb_view_models-2.0.5 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-2.0.4 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-2.0.3 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-2.0.2 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-2.0.1 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-2.0.0 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.2.3 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.2.2 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.2.1 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.2.0 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.6 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.5 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.4 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.3 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.2 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.1 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.1.0 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.0.29 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.0.28 lib/view_model/cepc_rr_wrapper.rb
epb_view_models-1.0.27 lib/view_model/cepc_rr_wrapper.rb