Class: Presenter::CepcRr::RecommendationReport
- Inherits:
-
Object
- Object
- Presenter::CepcRr::RecommendationReport
- Defined in:
- lib/presenter/cepc_rr/recommendation_report.rb
Instance Method Summary collapse
-
#initialize(view_model) ⇒ RecommendationReport
constructor
A new instance of RecommendationReport.
- #to_hash ⇒ Object
Constructor Details
#initialize(view_model) ⇒ RecommendationReport
Returns a new instance of RecommendationReport.
4 5 6 |
# File 'lib/presenter/cepc_rr/recommendation_report.rb', line 4 def initialize(view_model) @view_model = view_model end |
Instance Method Details
#to_hash ⇒ 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 42 43 44 45 46 |
# File 'lib/presenter/cepc_rr/recommendation_report.rb', line 8 def to_hash { assessment_id: @view_model.assessment_id, recommendations: [ @view_model.short_payback_recommendations.map do |recommendation| { payback_type: "short", recommendation_code: recommendation[:code], recommendation: recommendation[:text], cO2_Impact: recommendation[:cO2Impact], } end, @view_model.medium_payback_recommendations.map do |recommendation| { payback_type: "medium", recommendation_code: recommendation[:code], recommendation: recommendation[:text], cO2_Impact: recommendation[:cO2Impact], } end, @view_model.long_payback_recommendations.map do |recommendation| { payback_type: "long", recommendation_code: recommendation[:code], recommendation: recommendation[:text], cO2_Impact: recommendation[:cO2Impact], } end, @view_model.other_recommendations.map do |recommendation| { payback_type: "other", recommendation_code: recommendation[:code], recommendation: recommendation[:text], cO2_Impact: recommendation[:cO2Impact], } end, ].flatten, } end |