Class: Presenter::Export::Base
- Inherits:
-
Object
- Object
- Presenter::Export::Base
- Defined in:
- lib/presenter/export/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #address ⇒ Object
- #assessor ⇒ Object
- #enum_value(method, *value) ⇒ Object
- #heat_demand ⇒ Object
-
#initialize(wrapper, assessment) ⇒ Base
constructor
A new instance of Base.
- #metadata ⇒ Object
Constructor Details
#initialize(wrapper, assessment) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 |
# File 'lib/presenter/export/base.rb', line 9 def initialize(wrapper, assessment) @wrapper = wrapper @view_model = wrapper.view_model @assessment = assessment end |
Instance Method Details
#address ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/presenter/export/base.rb', line 15 def address { address_id: @view_model.address_id, address_line1: @view_model.address_line1, address_line2: @view_model.address_line2, address_line3: @view_model.address_line3, address_line4: if @view_model.respond_to?(:address_line4) @view_model.address_line4 end, postcode: @view_model.postcode, town: @view_model.town, } end |
#assessor ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/presenter/export/base.rb', line 30 def assessor { "scheme_assessor_id": REDACTED, # @view_model.scheme_assessor_id, "name": REDACTED, # @view_model.assessor_name, "email": REDACTED, # @view_model.assessor_email, "telephone": REDACTED, # @view_model.assessor_telephone, } end |
#enum_value(method, *value) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/presenter/export/base.rb', line 51 def enum_value(method, *value) { description: Helper::XmlEnumsToOutput.send(method, *value), value: value[0], } end |
#heat_demand ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/presenter/export/base.rb', line 39 def heat_demand { current_space_heating_demand: @view_model.current_space_heating_demand&.to_i, current_water_heating_demand: @view_model.current_water_heating_demand&.to_i, impact_of_cavity_insulation: @view_model.respond_to?(:impact_of_cavity_insulation) ? @view_model.impact_of_cavity_insulation : nil, impact_of_loft_insulation: @view_model.respond_to?(:impact_of_loft_insulation) ? @view_model.impact_of_loft_insulation : nil, impact_of_solid_wall_insulation: @view_model.respond_to?(:impact_of_solid_wall_insulation) ? @view_model.impact_of_solid_wall_insulation : nil, } end |
#metadata ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/presenter/export/base.rb', line 58 def = {} [:address_id] = @assessment.get(:address_id) [:created_at] = if @assessment.get(:created_at).nil? Time.new(2020, 9, 27, 8, 30).to_formatted_s(:iso8601) else Time .parse(@assessment.get(:created_at).to_s) .to_formatted_s(:iso8601) end [:opt_out] = @assessment.get(:opt_out) [:cancelled_at] = @assessment.get(:cancelled_at) [:not_for_issue_at] = @assessment.get(:not_for_issue_at) end |