Module: SolidQueueWeb::ApplicationHelper

Defined in:
app/helpers/solid_queue_web/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_duration(seconds) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/solid_queue_web/application_helper.rb', line 9

def format_duration(seconds)
  s = seconds.to_i
  return "< 1s" if s < 1

  if s < 60
    "#{s}s"
  elsif s < 3600
    "#{s / 60}m #{s % 60}s"
  else
    "#{s / 3600}h #{(s % 3600) / 60}m"
  end
end

#inline_stylesObject



3
4
5
6
7
# File 'app/helpers/solid_queue_web/application_helper.rb', line 3

def inline_styles
  dir = SolidQueueWeb::Engine.root.join("app/assets/stylesheets/solid_queue_web")
  css = dir.glob("_*.css").sort.map(&:read).join("\n")
  (:style, css.html_safe)
end