class LogTimer::Log

Represents a log file

Attributes

path[RW]

Public Class Methods

new(path) click to toggle source
# File lib/log_timer/log.rb, line 6
def initialize(path)
  @path = path
end

Public Instance Methods

modification_date() click to toggle source
# File lib/log_timer/log.rb, line 10
def modification_date
  File.mtime(@path)
end
older?(reference_time) click to toggle source

Checks if the log file is older than the given datetime

# File lib/log_timer/log.rb, line 15
def older?(reference_time)
  File.mtime(@path) < reference_time
end
tail(lines = 10) click to toggle source

Returns the last n lines from the log file Implementing this directly in Ruby is annoyingly complicated (and/or slow) it seems

# File lib/log_timer/log.rb, line 21
def tail(lines = 10)
  `tail -n #{lines} #{@path}`.split("\n")
end