Sha256: 3548ad0ad453558f73e710155c67b13b93b9151876e0b9c5b8d6e98cd3122cae
Contents?: true
Size: 371 Bytes
Versions: 43
Compression:
Stored size: 371 Bytes
Contents
class File def tail(n) buffer = 1024 idx = size > buffer ? size - buffer : 0 chunks = [] lines = 0 begin seek(idx) chunk = read(buffer) break unless chunk lines += chunk.count("\n") chunks.unshift chunk idx -= buffer end while lines < ( n + 1 ) && idx >= 0 chunks.join('').split(/\n/).last(n) end end
Version data entries
43 entries across 43 versions & 1 rubygems
Version | Path |
---|---|
tailog-0.1.6 | lib/tailog/ext/file.rb |
tailog-0.1.5 | lib/tailog/ext/file.rb |
tailog-0.1.4 | lib/tailog/ext/file.rb |