Class: ContentBlockTools::Presenters::BlockPresenters::Contact::TelephonePresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
BlockLevelContactItem
Defined in:
lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb

Constant Summary

Constants included from BlockLevelContactItem

BlockLevelContactItem::BASE_TAG_TYPE

Constants inherited from BasePresenter

BasePresenter::BASE_TAG_TYPE

Instance Attribute Summary

Attributes inherited from BasePresenter

#item

Instance Method Summary collapse

Methods included from BlockLevelContactItem

#initialize, #title, #wrapper

Methods inherited from BasePresenter

#initialize

Methods included from Govspeak

#render_govspeak

Instance Method Details

#bsl_detailsObject



51
52
53
54
55
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 51

def bsl_details
  bsl_guidance = item[:bsl_guidance] || {}

  render_govspeak(bsl_guidance[:value], root_class: "content-block__body") if bsl_guidance[:show]
end


67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 67

def call_charges_link
  call_charges = item[:call_charges] || {}

  if call_charges[:show_call_charges_info_url]
    (:p) do
      concat (:a,
                         call_charges[:label],
                         class: "content-block__link",
                         href: call_charges[:call_charges_info_url])
    end
  end
end

#descriptionObject



23
24
25
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 23

def description
  render_govspeak(item[:description], root_class: "content-block__body")
end

#number_listObject



27
28
29
30
31
32
33
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 27

def number_list
  (:ul, class: "content-block__list") do
    item[:telephone_numbers].each do |number|
      concat number_list_item(number)
    end
  end
end

#number_list_item(number) ⇒ Object



35
36
37
38
39
40
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 35

def number_list_item(number)
  (:li) do
    concat (:span, "#{number[:label]}: ")
    concat (:span, number[:telephone_number], { class: "tel" })
  end
end

#opening_hoursObject



57
58
59
60
61
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 57

def opening_hours
  opening_hours = item[:opening_hours] || {}

  render_govspeak(opening_hours[:opening_hours], root_class: "content-block__body") if opening_hours[:show_opening_hours]
end

#opening_hours_list_item(item) ⇒ Object



63
64
65
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 63

def opening_hours_list_item(item)
  (:li, "#{item[:day_from]} to #{item[:day_to]}, #{item[:time_from]} to #{item[:time_to]}")
end

#renderObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 10

def render
  wrapper do
    (:div) do
      concat description if item[:description].present?
      concat number_list
      concat video_relay_service
      concat bsl_details
      concat opening_hours
      concat call_charges_link
    end
  end
end

#video_relay_serviceObject



42
43
44
45
46
47
48
49
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 42

def video_relay_service
  video_relay_service = item[:video_relay_service] || {}

  if video_relay_service[:show]
    content = "#{video_relay_service[:prefix]} #{video_relay_service[:telephone_number]}"
    render_govspeak(content, root_class: "content-block__body")
  end
end