lib/output_helper/runtime.rb
# return runtime as string (1h 4m 4s)
#
# @param precision [Integer] miliseconds precision
return runtime as string (1h 4m 4s)
return runtime as string ( 1h 4m 4s )
def runtime precision: 4
      result = []
      if (hours = self/60/60).to_i > 0
        result << sprintf("%ih", hours)
      end
      if (minutes = self/60%60).to_i >0
        result << sprintf("%im", minutes)
      end
      if (seconds = self%60%60) > 0 and (seconds-seconds.to_i) > 0 and precision > 0
        result << sprintf("%.#{precision}fs", seconds)
      elsif seconds.to_i > 0
        result << sprintf("%is", seconds)
      end
      result.join(" ")
    end
def runtime precision : 4 result = [ ] if ( hours = self / 60 / 60 ) . to_i > 0 result << sprintf ( "%ih" , hours ) end if ( minutes = self / 60 % 60 ) . to_i > 0 result << sprintf ( "%im" , minutes ) end if ( seconds = self % 60 % 60 ) > 0 and ( seconds - seconds . to_i ) > 0 and precision > 0 result << sprintf ( "%.#{precision}fs" , seconds ) elsif seconds . to_i > 0 result << sprintf ( "%is" , seconds ) end result . join ( " " ) end
return runtime as string (1h 4m 4s)
return runtime as string ( 1h 4m 4s )
precision
None