Class: Search::LocatorRecordPresenter

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

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



47
48
49
# File 'app/presenters/search/locator_record_presenter.rb', line 47

def confirmed_at
  h.render_date r.confirmed_at
end


14
15
16
# File 'app/presenters/search/locator_record_presenter.rb', line 14

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

#distanceObject



18
19
20
# File 'app/presenters/search/locator_record_presenter.rb', line 18

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

#featuresObject



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

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



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

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.map(&:presence).compact.join("<br>").html_safe, class: 'text-nowrap')
end

#is_inactiveObject



6
7
8
# File 'app/presenters/search/locator_record_presenter.rb', line 6

def is_inactive
  h.y r.is_inactive
end

#star_status_levelObject



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

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



10
11
12
# File 'app/presenters/search/locator_record_presenter.rb', line 10

def state
  LocatorRecord.human_state_name(r.state)
end