Module: TimelineHelper

Defined in:
app/helpers/timeline_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_timeline_time(event) ⇒ Object



22
23
24
25
26
# File 'app/helpers/timeline_helper.rb', line 22

def format_timeline_time(event)
  event.time.strftime("%-I:%M %p")
    .gsub(/ AM/, "a")
    .gsub(/ PM/, "p")
end

#icon_for_resolution(resolution) ⇒ Object



15
16
17
18
19
20
# File 'app/helpers/timeline_helper.rb', line 15

def icon_for_resolution(resolution)
  case resolution
  when nil, "", "fixed" then "fa fa-ok"
  else "fa fa-minus"
  end
end

#render_timeline_date(date) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/timeline_helper.rb', line 28

def render_timeline_date(date)
  "  <div class=\"timeline-date\">\n    <span class=\"weekday\">\#{date.strftime(\"%a\")}</span>\n    <span class=\"month\">\#{date.strftime(\"%b\")}</span>\n    <span class=\"day\">\#{date.strftime(\"%e\")}</span>\n    <span class=\"year\">\#{date.strftime(\"%Y\")}</span>\n  </div>\n  HTML\nend\n".html_safe

#render_timeline_gap_for(date_range) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/timeline_helper.rb', line 3

def render_timeline_gap_for(date_range)
  days = date_range.end - date_range.begin
  if days < 3
    date_range.inject("") { |html, date| html << render_timeline_date(date) }.html_safe
  else
    "    <div class=\"timeline-date-gap\"></div>\n    \#{render_timeline_date(date_range.begin)}\n    HTML\n  end\nend\n".html_safe