Class: AirportEvents::Watcher

Inherits:
Object
  • Object
show all
Includes:
Publisher
Defined in:
lib/airport_events.rb

Instance Method Summary collapse

Methods included from Publisher

included

Instance Method Details

#on(event, &blk) ⇒ Object



30
31
32
# File 'lib/airport_events.rb', line 30

def on event, &blk
  subscribe event, &blk
end

#startObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/airport_events.rb', line 10

def start
  Airport.ensure_airport_command!

  if Airport.connected?
    connected DateTime.now
  else
    disconnected DateTime.now
  end

  @kernel_log_parser = KernelLogParser.new

  @kernel_log_parser.subscribe :connected do |date|
    connected date
  end

  @kernel_log_parser.subscribe :disconnected do |date|
    disconnected date
  end
end