Module: Resque::Plugins::JobStats::Server::Helpers

Defined in:
lib/resque-job-stats/server.rb

Instance Method Summary collapse

Instance Method Details

#check_or_cross_stat(value) ⇒ Object



48
49
50
# File 'lib/resque-job-stats/server.rb', line 48

def check_or_cross_stat(value)
  value ? "✓" : "✗"
end

#display_stat(stat, stat_name, format) ⇒ Object



41
42
43
44
45
46
# File 'lib/resque-job-stats/server.rb', line 41

def display_stat(stat, stat_name, format)
  if(display_stat?(stat_name))
    formatted_stat = self.send(format, stat.send(stat_name))
    "<td>#{formatted_stat}</td>"
  end
end

#display_stat?(stat_name) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/resque-job-stats/server.rb', line 22

def display_stat?(stat_name)
  self.class.job_stats_to_display == :all ||
    [self.class.job_stats_to_display].flatten.map(&:to_sym).include?(stat_name.to_sym)
end

#number_display(num) ⇒ Object



31
32
33
# File 'lib/resque-job-stats/server.rb', line 31

def number_display(num)
  num.zero? ? "" : num
end

#stat_header(stat_name) ⇒ Object



35
36
37
38
39
# File 'lib/resque-job-stats/server.rb', line 35

def stat_header(stat_name)
  if(display_stat?(stat_name))
    "<th>" + stat_name.to_s.gsub(/_/,' ').capitalize + "</th>"
  end
end

#time_display(float) ⇒ Object



27
28
29
# File 'lib/resque-job-stats/server.rb', line 27

def time_display(float)
  float.zero? ? "" : ("%.2f" % float.to_s) + "s"
end