Sha256: 14cd8d2f84f94004188e793706720563c851a9919f6ee48a1bb59d101e429837

Contents?: true

Size: 1.1 KB

Versions: 47

Compression:

Stored size: 1.1 KB

Contents

module ViewModel
  class AcReportWrapper
    attr_reader :view_model

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

    def type
      :AC_REPORT
    end

    def to_hash
      @summary.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::AcReport.new xml_doc
      when :"CEPC-NI-8.0.0"
        ViewModel::CepcNi800::AcReport.new xml_doc
      when :"CEPC-7.1"
        ViewModel::Cepc71::AcReport.new xml_doc
      when :"CEPC-7.0"
        ViewModel::Cepc70::AcReport.new xml_doc
      when :"CEPC-6.0"
        ViewModel::Cepc60::AcReport.new xml_doc
      when :"CEPC-5.1"
        ViewModel::Cepc51::AcReport.new xml_doc
      when :"CEPC-5.0"
        ViewModel::Cepc50::AcReport.new xml_doc
      when :"CEPC-4.0"
        ViewModel::Cepc40::AcReport.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-1.0.6 lib/view_model/ac_report_wrapper.rb
epb_view_models-1.0.5 lib/view_model/ac_report_wrapper.rb
epb_view_models-1.0.4 lib/view_model/ac_report_wrapper.rb
epb_view_models-1.0.3 lib/view_model/ac_report_wrapper.rb
epb_view_models-1.0.2 lib/view_model/ac_report_wrapper.rb
epb_view_models-1.0.1 lib/view_model/ac_report_wrapper.rb
epb_view_models-1.0.0 lib/view_model/ac_report_wrapper.rb