Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/file/tail.rb
Overview
File::Tail - Tailing files in Ruby
Description
This is a small ruby library that allows it to “tail” files in Ruby, including following a file, that still is growing like the unix command ‘tail -f’ can.
Author
Florian Frank [email protected]
License
This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation: www.gnu.org/copyleft/gpl.html
Download
The latest version of File::Tail (file-tail) can be found at
rubyforge.org/frs/?group_id=393
Online Documentation should be located at
Usage
File::Tail is a module in the File class. A lightweight class interface for logfiles can be seen under File::Tail::Logfile.
Direct extension of File objects with File::Tail works like that:
File.open(filename) do |log|
log.extend(File::Tail)
log.interval = 10
log.backward(10)
log.tail { |line| puts line }
end
It’s also possible to mix File::Tail in your own File classes (see also File::Tail::Logfile):
class MyFile < File
include File::Tail
end
log = MyFile.new("myfile")
log.interval = 10
log.backward(10)
log.tail { |line| print line }
The forward/backward method returns self, so it’s possible to chain methods together like that:
log.backward(10).tail { |line| puts line }
Direct Known Subclasses
Defined Under Namespace
Modules: Tail
Instance Method Summary collapse
-
#rewind(*args) ⇒ Object
The rewind method is deprecated and will be removed soon, use backward instead.
Instance Method Details
#rewind(*args) ⇒ Object
The rewind method is deprecated and will be removed soon, use backward instead. At the moment rewind accidentially overwrites the IO#rewind method, after the removal of the ol rewind mixin method, this will be no longer the case.
412 413 414 415 416 |
# File 'lib/file/tail.rb', line 412 def rewind(*args) warn "File::Tail#rewind method is deprecated and will be removed soon, "\ "use backward instead" backward *args end |