foalfetch/app/helpers/application_helper.rb

17 lines
431 B
Ruby
Raw Normal View History

2024-04-04 10:21:23 +02:00
# frozen_string_literal: true
module ApplicationHelper
# https://infusion.media/content-marketing/how-to-calculate-reading-time/
def reading_time(words)
minutes = words / 200.0
distance_of_time_in_words(minutes * 60.0)
end
def render_time
diff = ((Time.zone.now - @start_time) * 1000.0).round(2)
diff < 1000 ? "#{diff}ms" : "#{(diff / 1000.0).round(2)}s"
rescue StandardError
'unknown ms'
end
end