Sha256: c0c240a8d95e91db36526a0baca63aed1c1a1b409e831b6a2c92f0381452bc11
Contents?: true
Size: 822 Bytes
Versions: 11
Compression:
Stored size: 822 Bytes
Contents
# frozen_string_literal: true module Facter module Resolvers module Utils 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
11 entries across 11 versions & 1 rubygems