Class: File::Tail::Tailer

Inherits:
Thread
  • Object
show all
Defined in:
lib/file/tail/tailer.rb

Overview

This class supervises activity on a tailed fail and collects newly read lines until the Tail::Group fetches and processes them.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args, &block) ⇒ Object

Return the thread local variable id if it is defined.



27
28
29
30
31
32
33
# File 'lib/file/tail/tailer.rb', line 27

def method_missing(id, *args, &block)
  if args.empty? && !(value = self[id]).nil?
    value
  else
    super
  end
end

Instance Method Details

#pending_linesObject

Fetch all the pending lines from this Tailer and thereby remove them from the Tailer’s queue.



14
15
16
# File 'lib/file/tail/tailer.rb', line 14

def pending_lines
  Array.new(queue.size) { queue.deq(true) }
end

#pending_lines?Boolean

True if there are any lines pending on this Tailer, false otherwise.

Returns:

  • (Boolean)


8
9
10
# File 'lib/file/tail/tailer.rb', line 8

def pending_lines?
  !queue.empty?
end

#respond_to?(id) ⇒ Boolean

Return true if the thread local variable id is defined or if this object responds to the method id.

Returns:

  • (Boolean)


22
23
24
# File 'lib/file/tail/tailer.rb', line 22

def respond_to?(id)
  !self[id].nil? || super
end