Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactored the get_seconds private method to use the builtin boot_tim…

…e method instead of repeating that code.
  • Loading branch information...
commit 42aaa2db2e8100cbe26b88a565694b23eb88fcd5 1 parent e9fbe90
@djberg96 authored
Showing with 1 addition and 18 deletions.
  1. +1 −18 lib/windows/sys/uptime.rb
View
19 lib/windows/sys/uptime.rb
@@ -139,24 +139,7 @@ def self.get_dhms(host)
# Returns the number of seconds since boot.
#
def self.get_seconds(host)
- cs = "winmgmts://#{host}/root/cimv2"
- begin
- wmi = WIN32OLE.connect(cs)
- rescue WIN32OLERuntimeError => e
- raise Error, e
- else
- query = "select LastBootupTime from Win32_OperatingSystem"
- results = wmi.ExecQuery(query)
- now = Time.now
-
- results.each{ |ole|
- time_array = parse_ms_date(ole.LastBootupTime)
- boot_time = Time.mktime(*time_array)
- break
- }
- end
-
- (now - boot_time).to_i
+ (Time.now - boot_time).to_i
end
private_class_method :get_seconds
Please sign in to comment.
Something went wrong with that request. Please try again.