Sha256: 4f20dd7d0e62573b62dd8b2c2547ca2c67ca594ddfa530fc52cd7f529bd39180
Contents?: true
Size: 821 Bytes
Versions: 39
Compression:
Stored size: 821 Bytes
Contents
# frozen_string_literal: true module Facter module Util module Resolvers module UptimeHelper class << self def create_uptime_hash(seconds) results = {} minutes = (seconds / 60) % 60 results[:seconds] = seconds results[:hours] = seconds / (60 * 60) results[:days] = results[:hours] / 24 results[:uptime] = build_uptime_text(results[:days], results[:hours], minutes) results end def build_uptime_text(days, hours, minutes) case days when 0 then "#{hours}:#{format('%<minutes>02d', minutes: minutes)} hours" when 1 then '1 day' else "#{days} days" end end end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems