Module: Vnstat::Utils
- Defined in:
- lib/vnstat/utils.rb
Overview
A module containing several utility methods.
Class Method Summary collapse
-
.call_executable(*args, &block) ⇒ Object
Calls the vnstat CLI with the given arguments.
-
.call_executable_returning_status(*args) ⇒ true, false
Calls the vnstat CLI with the given arguments and returning whether the command has been executed successfully.
-
.system_call(*args) ⇒ Object
Initiates a system call with the given arguments.
-
.system_call_returning_status(*args) ⇒ Boolean
Initiates a system call with the given arguments and returning whether the command has been executed successfully.
Class Method Details
.call_executable(*args) ⇒ String .call_executable(*args) {|error_result| ... } ⇒ Object
Calls the vnstat CLI with the given arguments.
58 59 60 |
# File 'lib/vnstat/utils.rb', line 58 def call_executable(*args, &block) system_call(Vnstat.config.executable_path, *args, &block) end |
.call_executable_returning_status(*args) ⇒ true, false
Calls the vnstat CLI with the given arguments and returning whether the command has been executed successfully.
69 70 71 |
# File 'lib/vnstat/utils.rb', line 69 def call_executable_returning_status(*args) system_call_returning_status(Vnstat.config.executable_path, *args) end |
.system_call(*args) ⇒ String .system_call(*args) {|error_result| ... } ⇒ Object
Initiates a system call with the given arguments.
25 26 27 28 29 30 31 |
# File 'lib/vnstat/utils.rb', line 25 def system_call(*args) result = SystemCall.call(*args) return result.success_result if result.success? return yield(result.error_result) if block_given? result.error_result end |
.system_call_returning_status(*args) ⇒ Boolean
Initiates a system call with the given arguments and returning whether the command has been executed successfully.
40 41 42 |
# File 'lib/vnstat/utils.rb', line 40 def system_call_returning_status(*args) SystemCall.call(*args).success? end |