Class: Search::LocatorRecordPresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
Presenters::Timeable
Defined in:
app/presenters/search/locator_record_presenter.rb

Overview

Presenter: locator record presenter.

Direct Known Subclasses

LocatorRecordTextPresenter

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from BasePresenter

Instance Method Details

#confirmed_atObject



49
50
51
# File 'app/presenters/search/locator_record_presenter.rb', line 49

def confirmed_at
  h.render_date r.confirmed_at
end


16
17
18
# File 'app/presenters/search/locator_record_presenter.rb', line 16

def customer_link
  h.link_to(r.customer_name, h.customer_path(r.customer_id))
end

#distanceObject



20
21
22
# File 'app/presenters/search/locator_record_presenter.rb', line 20

def distance
  "#{r.distance.to_f.round(2)} mi."
end

#featuresObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/presenters/search/locator_record_presenter.rb', line 24

def features
  feats = []
  feats << "Retailer" if r.is_retailer
  feats << "Installer" if r.is_installer
  feats << "Electrician" if r.is_electrician
  feats << "Remodeller/Contractor" if r.is_remodel_contractor
  feats << "Maintains WY Stock" if r.maintains_wy_stock
  feats << "Has WY In Floor Display" if r.has_in_floor_display
  feats << "Has WY Countertop Display" if r.has_countertop_display
  feats << "Has WY Marketing Materials" if r.has_marketing_materials
  feats << "Has had WY Visit on #{h.render_date(r.date_of_wy_visit)}" if r.has_had_wy_visit
  feats << "Supports Flooring" if r.supports_flooring
  feats << "Supports Snow Melting" if r.supports_snowmelting
  feats << "Supports Roof Deicing" if r.supports_roof_deicing
  feats << "Supports Comfort Products" if r.supports_comfort_products
  feats.join(', ')
end

#full_addressObject



53
54
55
56
57
58
59
# File 'app/presenters/search/locator_record_presenter.rb', line 53

def full_address
  address = []
  address << r.street1 if r.has_columns?(:street1)
  address << r.street2 if r.has_columns?(:street2)
  address << "#{r.city}, #{r.state_code} #{r.zip}" if r.has_columns?(:city, :state_code, :zip)
  (:p, address.filter_map(&:presence).join("<br>").html_safe, class: 'text-nowrap')
end

#is_inactiveObject



8
9
10
# File 'app/presenters/search/locator_record_presenter.rb', line 8

def is_inactive
  h.y r.is_inactive
end

#star_status_levelObject



42
43
44
45
46
47
# File 'app/presenters/search/locator_record_presenter.rb', line 42

def star_status_level
  status = r.star_status_level || 0
  h.capture do
    status.times { h.concat h.fa_icon('star', style: 'color: gold') }
  end
end

#stateObject



12
13
14
# File 'app/presenters/search/locator_record_presenter.rb', line 12

def state
  LocatorRecord.human_state_name(r.state)
end