Class: RuVim::Stream::Follow
- Inherits:
-
RuVim::Stream
- Object
- RuVim::Stream
- RuVim::Stream::Follow
- Defined in:
- lib/ruvim/stream/follow.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
Returns the value of attribute backend.
-
#watcher ⇒ Object
Returns the value of attribute watcher.
Attributes inherited from RuVim::Stream
Instance Method Summary collapse
-
#initialize(path:, buffer_id:, queue:, stop_handler: nil, ¬ify) ⇒ Follow
constructor
A new instance of Follow.
- #status ⇒ Object
- #stop! ⇒ Object
Methods inherited from RuVim::Stream
Constructor Details
#initialize(path:, buffer_id:, queue:, stop_handler: nil, ¬ify) ⇒ Follow
Returns a new instance of Follow.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruvim/stream/follow.rb', line 7 def initialize(path:, buffer_id:, queue:, stop_handler: nil, ¬ify) super(stop_handler: stop_handler) @state = :live @watcher = FileWatcher.create(path) do |type, data| case type when :data queue << { type: :follow_data, buffer_id: buffer_id, data: data } when :truncated queue << { type: :follow_truncated, buffer_id: buffer_id } when :deleted queue << { type: :follow_deleted, buffer_id: buffer_id } end notify.call end @backend = @watcher.backend @watcher.start end |
Instance Attribute Details
#backend ⇒ Object
Returns the value of attribute backend.
5 6 7 |
# File 'lib/ruvim/stream/follow.rb', line 5 def backend @backend end |
#watcher ⇒ Object
Returns the value of attribute watcher.
5 6 7 |
# File 'lib/ruvim/stream/follow.rb', line 5 def watcher @watcher end |
Instance Method Details
#status ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ruvim/stream/follow.rb', line 25 def status case @state when :live @backend == :inotify ? "follow/i" : "follow" when :error then "follow/error" end end |
#stop! ⇒ Object
33 34 35 36 37 38 |
# File 'lib/ruvim/stream/follow.rb', line 33 def stop! watcher = @watcher; @watcher = nil watcher&.stop @backend = nil @state = nil end |