Class: Www::FloorPlanDisplayPresenter
Instance Attribute Summary
#current_account, #options, #url_helper
Instance Method Summary
collapse
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Constructor Details
Returns a new instance of FloorPlanDisplayPresenter.
2
3
4
5
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 2
def initialize(floor_plan_display, view_context)
@floor_plan_display = floor_plan_display
@view_context = view_context
end
|
Instance Method Details
#breadcrumb_items ⇒ Object
99
100
101
102
103
104
105
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 99
def breadcrumb_items
[
{ name: 'Home', url: @view_context.root_path },
{ name: 'Floor Plan Displays', url: @view_context.floor_plan_displays_path },
{ name: @floor_plan_display.name, url: @view_context.floor_plan_display_path(@floor_plan_display) }
]
end
|
#display_description ⇒ Object
19
20
21
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 19
def display_description
@floor_plan_display.description.presence || 'No description available.'
end
|
#display_name ⇒ Object
15
16
17
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 15
def display_name
@floor_plan_display.name
end
|
#image_summary ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 35
def image_summary
count = @floor_plan_display.images.count
case count
when 0
'No images available'
when 1
'1 image'
else
"#{count} images"
end
end
|
#images_with_details ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 84
def images_with_details
@floor_plan_display.images.order(:position).map do |image|
{
id: image.id,
title: image.title,
url: image.attachment.url,
size: image.attachment_size,
size_display: @view_context.number_to_human_size(image.attachment_size),
reference_number: image.reference_number,
from_room_config: image.tags&.include?('room-configuration'),
position: image.position
}
end
end
|
#main_image_url ⇒ Object
66
67
68
69
70
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 66
def main_image_url
return nil unless @floor_plan_display.main_image.present?
@floor_plan_display.main_image.attachment.url
end
|
11
12
13
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 11
def meta_description
@floor_plan_display.seo_description.presence || truncate_description(@floor_plan_display.description)
end
|
#operating_cost_display ⇒ Object
47
48
49
50
51
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 47
def operating_cost_display
return 'Cost not available' if @floor_plan_display.total_cost_to_operate.zero?
"$#{@view_context.number_with_precision(@floor_plan_display.total_cost_to_operate, precision: 2)}"
end
|
#room_configuration_summary ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 23
def room_configuration_summary
count = @floor_plan_display.room_configurations.count
case count
when 0
'No room configurations'
when 1
'1 room configuration'
else
"#{count} room configurations"
end
end
|
#room_configurations_with_details ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 72
def room_configurations_with_details
@floor_plan_display.floor_plan_display_room_configurations.includes(:room_configuration).map do |fpdr|
{
room_name: fpdr.room_name,
room_description: fpdr.room_description,
cost_to_operate: fpdr.cost_to_operate,
reference_number: fpdr.room_configuration.reference_number,
operating_cost_display: "$#{@view_context.number_with_precision(fpdr.cost_to_operate, precision: 2)}"
}
end
end
|
#social_share_data ⇒ Object
107
108
109
110
111
112
113
114
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 107
def social_share_data
{
title: title,
description: meta_description,
image: main_image_url,
url: @view_context.floor_plan_display_url(@floor_plan_display)
}
end
|
#state_display ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 53
def state_display
case @floor_plan_display.state
when 'published'
'Published'
when 'draft'
'Draft'
when 'archived'
'Archived'
else
@floor_plan_display.state.humanize
end
end
|
#title ⇒ Object
7
8
9
|
# File 'app/presenters/www/floor_plan_display_presenter.rb', line 7
def title
@floor_plan_display.seo_title.presence || @floor_plan_display.name
end
|