Class: Pdf::Document::RoomConfiguration

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

Defined Under Namespace

Classes: Result

Constant Summary collapse

LANDSCAPE_PAGE_HEIGHT =
612
LANDSCAPE_MARGIN =
15
LANDSCAPE_CONTENT_WIDTH =
762
LANDSCAPE_CONTENT_HEIGHT =
LANDSCAPE_PAGE_HEIGHT - (LANDSCAPE_MARGIN * 2)
LANDSCAPE_DISCLAIMER_HEIGHT =
15
LANDSCAPE_MIN_PLAN_HEIGHT =

Keep the former detailed-plan frame as the readability floor. Details that
need more room move to their own page instead of shrinking the plan below it.

411
LANDSCAPE_INLINE_DETAILS_HEIGHT =
LANDSCAPE_CONTENT_HEIGHT -
LANDSCAPE_DISCLAIMER_HEIGHT -
LANDSCAPE_MIN_PLAN_HEIGHT
LANDSCAPE_BRAND_HEIGHT =
50
LANDSCAPE_SUPPORT_HEIGHT =
40
LANDSCAPE_DETAILS_CELL_PADDING =
5

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



24
25
26
# File 'app/services/pdf/document/room_configuration.rb', line 24

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

Instance Method Details

#call(room_configuration, install_plan) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/services/pdf/document/room_configuration.rb', line 28

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, LANDSCAPE_PAGE_HEIGHT]
               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 = LANDSCAPE_MARGIN
  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