Class: EventHub::Pidfile
- Inherits:
-
Object
- Object
- EventHub::Pidfile
- Defined in:
- lib/eventhub/pidfile.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#delete ⇒ Object
Try to delete file, ignore all errors.
-
#initialize(file) ⇒ Pidfile
constructor
A new instance of Pidfile.
-
#write(pid) ⇒ Object
write the pid to the file specified in the initializer.
Constructor Details
#initialize(file) ⇒ Pidfile
Returns a new instance of Pidfile.
3 4 5 |
# File 'lib/eventhub/pidfile.rb', line 3 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
2 3 4 |
# File 'lib/eventhub/pidfile.rb', line 2 def file @file end |
Instance Method Details
#delete ⇒ Object
Try to delete file, ignore all errors
14 15 16 17 18 19 20 |
# File 'lib/eventhub/pidfile.rb', line 14 def delete begin File.delete(file) rescue # ignore end end |
#write(pid) ⇒ Object
write the pid to the file specified in the initializer
8 9 10 11 |
# File 'lib/eventhub/pidfile.rb', line 8 def write(pid) FileUtils.makedirs(File.dirname(file)) IO.write(file, pid.to_s) end |