lib/liberty_buildpack/util/format_duration.rb
def duration
    remainder = self

    hours = (remainder / HOUR).to_int
    remainder -= HOUR * hours

    minutes = (remainder / MINUTE).to_int
    remainder -= MINUTE * minutes

    return "#{hours}h #{minutes}m" if hours > 0

    seconds = (remainder / SECOND).to_int
    remainder -= SECOND * seconds

    return "#{minutes}m #{seconds}s" if minutes > 0

    tenths = (remainder / TENTH).to_int
    "#{seconds}.#{tenths}s"
  end
# Formats a number as a user-readable duration
#
# @return [String] a user-readable duration. Follows the following algorithm
#                   1. If more than an hour, print hours and minutes
#                   2. If less than an hour and more than a minute, print minutes and seconds
#                   3. If less than a minute and more than a second, print seconds.tenths
Formats a number as a user-readable duration
Formats a number as a user - readable duration
def duration
    remainder = self
    hours = (remainder / HOUR).to_int
    remainder -= HOUR * hours
    minutes = (remainder / MINUTE).to_int
    remainder -= MINUTE * minutes
    return "#{hours}h #{minutes}m" if hours > 0
    seconds = (remainder / SECOND).to_int
    remainder -= SECOND * seconds
    return "#{minutes}m #{seconds}s" if minutes > 0
    tenths = (remainder / TENTH).to_int
    "#{seconds}.#{tenths}s"
  end
def duration remainder = self hours = ( remainder / HOUR ) . to_int remainder -= HOUR * hours minutes = ( remainder / MINUTE ) . to_int remainder -= MINUTE * minutes return "#{hours}h #{minutes}m" if hours > 0 seconds = ( remainder / SECOND ) . to_int remainder -= SECOND * seconds return "#{minutes}m #{seconds}s" if minutes > 0 tenths = ( remainder / TENTH ) . to_int "#{seconds}.#{tenths}s" end
Formats a number as a user-readable duration
Formats a number as a user - readable duration
a user-readable duration. Follows the following algorithm 1. If more than an hour, print hours and minutes 2. If less than an hour and more than a minute, print minutes and seconds 3. If less than a minute and more than a second, print seconds.tenths
a user - readable duration . Follows the following algorithm 1 . If more than an hour print hours and minutes 2 . If less than an hour and more than a minute print minutes and seconds 3 . If less than a minute and more than a second print seconds . tenths
String