Class: Presenter::Dec::XmlSummary
- Inherits:
-
Object
- Object
- Presenter::Dec::XmlSummary
- Defined in:
- lib/presenter/dec/xml_summary.rb
Instance Method Summary collapse
-
#initialize(view_model) ⇒ XmlSummary
constructor
A new instance of XmlSummary.
- #to_xml ⇒ Object
Constructor Details
#initialize(view_model) ⇒ XmlSummary
Returns a new instance of XmlSummary.
4 5 6 |
# File 'lib/presenter/dec/xml_summary.rb', line 4 def initialize(view_model) @view_model = view_model end |
Instance Method Details
#to_xml ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/presenter/dec/xml_summary.rb', line 8 def to_xml dec_data = { report_type: @view_model.report_type, address_id: if @view_model.address_id&.include?("LPRN-") "" else @view_model.address_id end, output_engine: @view_model.output_engine, assessment_start_date: @view_model.or_assessment_start_date, assessment_end_date: @view_model.or_assessment_end_date, benchmarks: @view_model.benchmarks, energy_consumption: @view_model.or_energy_consumption, annual_energy_summary: @view_model.annual_energy_summary, dec_status: @view_model.respond_to?(:dec_status) ? @view_model.dec_status : nil, current_assessment_date: @view_model.current_assessment_date, energy_efficiency_rating: @view_model., current_electricity_co2: @view_model.current_electricity_co2, current_heating_co2: @view_model.current_heating_co2, current_renewables_co2: @view_model.current_renewables_co2, main_heating_fuel: @view_model.main_heating_fuel, } xml = ERB.new(get_template).result_with_hash dec_data if !@view_model.respond_to?(:dec_status) || @view_model.dec_status.nil? doc = Nokogiri.XML(xml) { |config| config.huge.strict } doc.at("DEC-Status").remove xml = doc.to_xml end xml end |