Module: Ductwork::ApplicationHelper
- Defined in:
- app/helpers/ductwork/application_helper.rb
Instance Method Summary collapse
- #first_page? ⇒ Boolean
- #formatted_time_distance(started_at, completed_at) ⇒ Object
- #next_page_path ⇒ Object
- #previous_page_path ⇒ Object
Instance Method Details
#first_page? ⇒ Boolean
17 18 19 |
# File 'app/helpers/ductwork/application_helper.rb', line 17 def first_page? params[:page].to_i.zero? end |
#formatted_time_distance(started_at, completed_at) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/ductwork/application_helper.rb', line 5 def formatted_time_distance(started_at, completed_at) elapsed = completed_at - started_at hours = (elapsed / 3600).floor minutes = ((elapsed % 3600) / 60).floor seconds = (elapsed % 60).round(2) hours_string = hours.zero? ? "" : "#{hours}h " minutes_string = minutes.zero? ? "" : "#{minutes}m " seconds_string = seconds.zero? ? "" : "#{seconds}s" "#{hours_string}#{minutes_string}#{seconds_string}" end |
#next_page_path ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/helpers/ductwork/application_helper.rb', line 21 def next_page_path next_page = params[:page].to_i + 1 next_params = params .permit(:controller, :action, :id, :klass, :status, :page) .merge(page: next_page) url_for(**next_params) end |
#previous_page_path ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/helpers/ductwork/application_helper.rb', line 30 def previous_page_path previous_page = params[:page].to_i - 1 previous_params = params .permit(:controller, :action, :id, :klass, :status, :page) .merge(page: previous_page) url_for(**previous_params) end |