Class: Riser::StatusFile
- Inherits:
-
Object
- Object
- Riser::StatusFile
- Defined in:
- lib/riser/daemon.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(filename) ⇒ StatusFile
constructor
A new instance of StatusFile.
- #lock ⇒ Object
- #open ⇒ Object
- #write(text) ⇒ Object
Constructor Details
#initialize(filename) ⇒ StatusFile
Returns a new instance of StatusFile.
10 11 12 |
# File 'lib/riser/daemon.rb', line 10 def initialize(filename) @filename = filename end |
Instance Method Details
#close ⇒ Object
19 20 21 22 |
# File 'lib/riser/daemon.rb', line 19 def close @file.close nil end |
#lock ⇒ Object
24 25 26 |
# File 'lib/riser/daemon.rb', line 24 def lock @file.flock(File::LOCK_EX | File::LOCK_NB) end |
#open ⇒ Object
14 15 16 17 |
# File 'lib/riser/daemon.rb', line 14 def open @file = File.open(@filename, File::WRONLY | File::CREAT, 0644) self end |
#write(text) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/riser/daemon.rb', line 28 def write(text) @file.truncate(0) @file.seek(0) ret_val = @file.write(text) @file.flush ret_val end |