Module: Facter::Util::Resolvers::UptimeHelper
- Defined in:
- lib/facter/util/resolvers/uptime_helper.rb
Overview
Class Method Summary collapse
Class Method Details
.build_uptime_text(days, hours, minutes) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/facter/util/resolvers/uptime_helper.rb', line 20 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 |
.create_uptime_hash(seconds) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/facter/util/resolvers/uptime_helper.rb', line 8 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 |