Class: Pdf::Document::RoomConfigurationLegacy

Inherits:
BaseService
  • Object
show all
Includes:
Base
Defined in:
app/services/pdf/document/room_configuration_legacy.rb

Overview

Service object: room configuration installation plan (LEGACY pre-modernization layout).
Used for both individual install plans and multizone plans. Preserved verbatim so
generate_pdf can fall back to the v1 look per option.

Defined Under Namespace

Classes: Result

Constant Summary

Constants included from Base

Base::FONT, Base::NIMBUS_SANS_PATH, Base::NIMBUS_SANS_PATH_BOLD, Base::WY_LOGO_PATH

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



12
13
14
# File 'app/services/pdf/document/room_configuration_legacy.rb', line 12

def self.call(...)
  new.call(...)
end

Instance Method Details

#call(room_configuration, install_plan) ⇒ Object



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
# File 'app/services/pdf/document/room_configuration_legacy.rb', line 16

def call(room_configuration, install_plan)
  @rc           = room_configuration
  @install_plan = install_plan
  @hep          = Item::HeatingElementPlan.new_from_room_configuration(@rc)
  @controls     = @hep.electrical_plan_controls.map(&:item).uniq

  @page_size = case install_plan.template
               when 'letter_landscape'
                 [0, 0, 792, 612]
               when 'legacy_letter_portrait'
                 [0, 0, 612, 792]
               end
  @orientation = case install_plan.template
                 when 'letter_landscape'
                   :landscape
                 when 'legacy_letter_portrait'
                   :portrait
                 end
  if install_plan.template.include?('legacy')
    @footer     = ['24/7 Technical Support', '(800) 875-5285', 'www.WarmlyYours.com/support']
    @margin_top = 1
  else
    @footer     = []
    @margin_top = 15
  end
  @representative = @rc.main_rep ? "Account Manager: #{@rc.main_rep.name_and_phone}" : 'for assistance please contact Customer Service at (800) 875-5285'
  @op_cost_text   = @hep.electrical_consumption ? "#{ActionController::Base.helpers.number_to_currency(@hep.electrical_consumption[:rate])}/hour @ #{ActionController::Base.helpers.number_to_currency(@hep.electrical_consumption[:avg_rate])}/kWh" : nil

  Result.new(pdf: generate_pdf)
end