plugins/resource_management/app/helpers/resource_management/application_helper.rb
# Given a number of timestamps from ResourceManagement::Resource#updated_at,
# calculates a string representation of the data age, such as
#     "between 3 days and 1 hour ago"
Given a number of timestamps from ResourceManagement::Resource#updated_at,
calculates a string representation of the data age, such as
"between 3 days and 1 hour ago"
Given a number of timestamps from ResourceManagement :: Resource#updated_at calculates a string representation of the data age such as " between 3 days and 1 hour ago "
def data_age_as_string(*update_times)
      return "" if update_times.empty?
      max_age = age_to_string(update_times.min())
      min_age = age_to_string(update_times.max())
      if min_age == max_age
        return "#{min_age} ago"
      else
        min_age_unit = min_age.split(/\s+/).last 
        max_age_unit = max_age.split(/\s+/).last
        if min_age_unit == max_age_unit || "#{min_age_unit}s" == max_age_unit
          min_age = min_age.gsub(/(?<=\d)\s+\S+$/, '')
        end
        return "between #{min_age} and #{max_age} ago"
      end
    end
def data_age_as_string ( * update_times ) return "" if update_times . empty? max_age = age_to_string ( update_times . min ( ) ) min_age = age_to_string ( update_times . max ( ) ) if min_age == max_age return "#{min_age} ago" else min_age_unit = min_age . split ( / \s + / ) . last max_age_unit = max_age . split ( / \s + / ) . last if min_age_unit == max_age_unit || "#{min_age_unit}s" == max_age_unit min_age = min_age . gsub ( / (?<= \d ) \s + \S +$ / , '' ) end return "between #{min_age} and #{max_age} ago" end end
Given a number of timestamps from ResourceManagement::Resource#updated_at,
calculates a string representation of the data age, such as
"between 3 days and 1 hour ago"
Given a number of timestamps from ResourceManagement :: Resource#updated_at calculates a string representation of the data age such as " between 3 days and 1 hour ago "
# don't repeat unit if identical for both # NOTE: may be singular
update_times
<not_specific>