Class: Siding::Watch::Watcher
- Inherits:
-
Object
- Object
- Siding::Watch::Watcher
- Defined in:
- lib/siding/watch.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(executor:, label:, attempted:) ⇒ Watcher
constructor
A new instance of Watcher.
- #mode_label ⇒ Object
- #stop ⇒ Object
- #watching? ⇒ Boolean
Constructor Details
#initialize(executor:, label:, attempted:) ⇒ Watcher
Returns a new instance of Watcher.
84 85 86 87 88 |
# File 'lib/siding/watch.rb', line 84 def initialize(executor:, label:, attempted:) @executor = executor @label = label @attempted = attempted end |
Class Method Details
.active(executor, mode) ⇒ Object
77 78 79 80 |
# File 'lib/siding/watch.rb', line 77 def self.active(executor, mode) label = mode == POLL ? "poll (watchcat)" : "events (watchcat)" new(executor:, label:, attempted: true) end |
.unavailable(reason) ⇒ Object
82 |
# File 'lib/siding/watch.rb', line 82 def self.unavailable(reason) = new(executor: nil, label: "poll -- watchcat could not start: #{reason}", attempted: false) |
Instance Method Details
#mode_label ⇒ Object
94 95 96 97 98 99 |
# File 'lib/siding/watch.rb', line 94 def mode_label return @label if @attempted && alive? return @label unless @attempted "poll -- watchcat watcher thread died" end |
#stop ⇒ Object
101 102 103 |
# File 'lib/siding/watch.rb', line 101 def stop @executor&.stop end |
#watching? ⇒ Boolean
90 91 92 |
# File 'lib/siding/watch.rb', line 90 def watching? @attempted && alive? end |