Class: RakeUp::Utilities::ProcessCheck
- Inherits:
-
Object
- Object
- RakeUp::Utilities::ProcessCheck
- Defined in:
- lib/rakeup/utilities/process_check.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(pid) ⇒ ProcessCheck
constructor
A new instance of ProcessCheck.
- #run ⇒ Object
- #running? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(pid) ⇒ ProcessCheck
Returns a new instance of ProcessCheck.
6 7 8 |
# File 'lib/rakeup/utilities/process_check.rb', line 6 def initialize(pid) @pid = pid.to_i end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/rakeup/utilities/process_check.rb', line 4 def error @error end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
4 5 6 |
# File 'lib/rakeup/utilities/process_check.rb', line 4 def pid @pid end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rakeup/utilities/process_check.rb', line 10 def run begin info = Process.getpgid(pid) @running = true rescue Errno::ESRCH => error @running = false @error = error end end |
#running? ⇒ Boolean
20 21 22 |
# File 'lib/rakeup/utilities/process_check.rb', line 20 def running? @running end |
#to_s ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rakeup/utilities/process_check.rb', line 24 def to_s if running? "Found process running with pid #{pid}" else "Unable to find process with pid #{pid}: #{@error}" end end |