Class: Siding::Watch::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/siding/watch.rb

Class Method Summary collapse

Instance Method Summary collapse

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_labelObject



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

#stopObject



101
102
103
# File 'lib/siding/watch.rb', line 101

def stop
  @executor&.stop
end

#watching?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/siding/watch.rb', line 90

def watching?
  @attempted && alive?
end