Module: Myreplicator::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#chronos(secs) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/helpers/myreplicator/application_helper.rb', line 11

def chronos(secs)
  [[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
    if secs > 0
      secs, n = secs.divmod(count)
      "#{n.to_i} #{name}"
    end
  }.compact.reverse.join(', ')
end

#err_countObject



20
21
22
23
# File 'app/helpers/myreplicator/application_helper.rb', line 20

def err_count
  total = Log.where(:state => 'error').count
  return total
end

#run_countObject



26
27
28
29
# File 'app/helpers/myreplicator/application_helper.rb', line 26

def run_count
  total = Log.where(:state => 'running').count
  return total
end

#sortable(column, title = nil) ⇒ Object



4
5
6
7
8
9
# File 'app/helpers/myreplicator/application_helper.rb', line 4

def sortable(column, title = nil)
  title ||= column.titleize
  css_class = column == sort_column ? "current #{sort_direction}" : nil
  direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
  link_to (:span, title), {:sort => column, :direction => direction}, {:class => css_class}
end