Class: FileWatch::ReadMode::Handlers::Base

Inherits:
Object
  • Object
show all
Includes:
LogStash::Util::Loggable
Defined in:
lib/filewatch/read_mode/handlers/base.rb

Direct Known Subclasses

ReadFile, ReadZipFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor, sincedb_collection, observer, settings) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
# File 'lib/filewatch/read_mode/handlers/base.rb', line 10

def initialize(processor, sincedb_collection, observer, settings)
  @settings = settings
  @processor = processor
  @sincedb_collection = sincedb_collection
  @observer = observer
end

Instance Attribute Details

#sincedb_collectionObject (readonly)

Returns the value of attribute sincedb_collection.



8
9
10
# File 'lib/filewatch/read_mode/handlers/base.rb', line 8

def sincedb_collection
  @sincedb_collection
end

Instance Method Details

#handle(watched_file) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/filewatch/read_mode/handlers/base.rb', line 21

def handle(watched_file)
  logger.trace? && logger.trace("handling:", :path => watched_file.path)
  unless watched_file.has_listener?
    watched_file.set_listener(@observer)
  end
  handle_specifically(watched_file)
end

#handle_specifically(watched_file) ⇒ Object



29
30
31
# File 'lib/filewatch/read_mode/handlers/base.rb', line 29

def handle_specifically(watched_file)
  # some handlers don't need to define this method
end

#quit?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/filewatch/read_mode/handlers/base.rb', line 17

def quit?
  @processor.watch.quit?
end