struct Tail::File

Defined in:

tail.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(file : ::File) #

Tail a file IO.


[View source]

Class Method Detail

def self.open(file : Path | String, & : File -> ) #

Open a file to tail into it.


[View source]

Instance Method Detail

def follow(lines = 0, line_size = 1024, delay = 0.1, &block : String -> _) #

Follows the end of a file.

Tail::File.open "file", &.follow do |str|
  print str
end

[View source]
def last_lines(lines = 10, line_size = 1024) : Array(String) #

Gets the last n lines. line_size is used to extract the end of the file, and then calculate the trailing lines.

Tail::File.open "file", &.last_lines

[View source]
def watch(lines = 0, line_size = 1024, &block : String -> _) #

Watchs for newly added bytes to the file by using inotify.


[View source]