Module: PgBouncerHero::ApplicationHelper
- Defined in:
- app/helpers/pg_bouncer_hero/application_helper.rb
Instance Method Summary collapse
- #alert_class_for(flash_type) ⇒ Object
- #humanize_ms(millis) ⇒ Object
- #is_active(action_name) ⇒ Object
Instance Method Details
#alert_class_for(flash_type) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/pg_bouncer_hero/application_helper.rb', line 6 def alert_class_for(flash_type) case flash_type when 'success' 'success' when 'error' 'error' when 'notice' 'info' when 'warning' 'warning' else nil end end |
#humanize_ms(millis) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/helpers/pg_bouncer_hero/application_helper.rb', line 20 def humanize_ms(millis) [[1000, :ms], [60, :s], [60, :min], [24, :h], [1000, :d]].map{ |count, name| if millis > 0 millis, n = millis.divmod(count) "#{n.to_i} #{name}" end }.compact.reverse.join(' ') end |
#is_active(action_name) ⇒ Object
3 4 5 |
# File 'app/helpers/pg_bouncer_hero/application_helper.rb', line 3 def is_active(action_name) params[:action] == action_name ? 'active' : nil end |