Class: FileWatch::Ext::XlsxTail
- Inherits:
-
TailBase
- Object
- TailBase
- FileWatch::Ext::XlsxTail
- Defined in:
- lib/filewatch/ext/xlsxtail.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ XlsxTail
constructor
A new instance of XlsxTail.
- #subscribe(&block) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ XlsxTail
Returns a new instance of XlsxTail.
8 9 10 11 |
# File 'lib/filewatch/ext/xlsxtail.rb', line 8 def initialize(opts={}) @pos = {} super end |
Instance Method Details
#subscribe(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/filewatch/ext/xlsxtail.rb', line 14 def subscribe(&block) # subscribe(stat_interval = 1, discover_interval = 5, &block) @watch.subscribe(@opts[:stat_interval], @opts[:discover_interval]) do |event, path| case event when :create, :create_initial if @files.member?(path) @logger.debug("#{event} for #{path}: already exists in @files") next end if _open_file(path, event) _read_file(path, &block) end when :modify @logger.debug(":modify for #{path}") when :delete @logger.debug(":delete for #{path}, deleted from @files") _progressdb_delete(path, &block) if @opts[:progressdb] && @opts[:progressdb_del] @files.delete(path) _sincedb_delete(path) @statcache.delete(path) else @logger.warn("unknown event type #{event} for #{path}") end end # @watch.subscribe end |