Class: ProconBypassMan::Uptime
- Inherits:
-
Object
- Object
- ProconBypassMan::Uptime
- Defined in:
- lib/procon_bypass_man/support/uptime.rb
Class Method Summary collapse
Instance Method Summary collapse
- #from_boot ⇒ Integer
-
#initialize(uptime_cmd_result:) ⇒ Uptime
constructor
A new instance of Uptime.
Constructor Details
#initialize(uptime_cmd_result:) ⇒ Uptime
Returns a new instance of Uptime.
11 12 13 |
# File 'lib/procon_bypass_man/support/uptime.rb', line 11 def initialize(uptime_cmd_result: ) @result = uptime_cmd_result end |
Class Method Details
.from_boot ⇒ Integer
6 7 8 |
# File 'lib/procon_bypass_man/support/uptime.rb', line 6 def self.from_boot new(uptime_cmd_result: `uptime -s`.chomp).from_boot end |
Instance Method Details
#from_boot ⇒ Integer
16 17 18 19 20 21 22 23 |
# File 'lib/procon_bypass_man/support/uptime.rb', line 16 def from_boot return -1 if @result == '' # darwin系だとsオプションが使えない boot_time = Time.parse(@result).to_i return Time.now.to_i - boot_time.to_i rescue => e ProconBypassMan.logger.error(e) return -1 end |