class Tailnudge::Reader

Public Class Methods

extract(line) click to toggle source
# File lib/tailnudge/reader.rb, line 5
def self.extract(line)
  Tailnudge.patterns.each do |pattern|
    match = pattern.match(line)
    if match
      return Result.new(match, line)
    end
  end
  nil
end
new(path, startpos=-1) click to toggle source
Calls superclass method
# File lib/tailnudge/reader.rb, line 15
def initialize(path, startpos=-1)
  super(path, startpos)
  @buffer = BufferedTokenizer.new
end

Public Instance Methods

receive_data(data) click to toggle source
# File lib/tailnudge/reader.rb, line 20
def receive_data(data)
  @buffer.extract(data).each do |line|
    result = self.class.extract(line)
    if result
      Notification.create(result)
    end
  end
end