class Argus::NavMonitor
Attributes
streamer[R]
Public Class Methods
new(controller, remote_host, opts={})
click to toggle source
# File lib/argus/nav_monitor.rb 6 def initialize(controller, remote_host, opts={}) 7 @controller = controller 8 @streamer = opts.fetch(:streamer) { NavStreamer.new(remote_host: remote_host) } 9 @callbacks = [] 10 @mutex = Mutex.new 11 @nav_data = nil 12 @nav_options = {} 13 end
Public Instance Methods
callback(callback=nil, &block)
click to toggle source
# File lib/argus/nav_monitor.rb 35 def callback(callback=nil, &block) 36 @mutex.synchronize do 37 @callbacks << callback unless callback.nil? 38 @callbacks << block if block_given? 39 end 40 end
data()
click to toggle source
# File lib/argus/nav_monitor.rb 42 def data 43 @mutex.synchronize { @nav_data } 44 end
join()
click to toggle source
# File lib/argus/nav_monitor.rb 30 def join 31 stop 32 @nav_thread.join 33 end
option(tag)
click to toggle source
# File lib/argus/nav_monitor.rb 46 def option(tag) 47 @mutex.synchronize { @nav_options[tag] } 48 end
start()
click to toggle source
# File lib/argus/nav_monitor.rb 15 def start 16 @streamer.start 17 @running = true 18 @nav_thread = Thread.new do 19 while @running 20 data = @streamer.receive_data 21 update_nav_data(data) if data 22 end 23 end 24 end
stop()
click to toggle source
# File lib/argus/nav_monitor.rb 26 def stop 27 @running = false 28 end
Private Instance Methods
do_callbacks(data)
click to toggle source
# File lib/argus/nav_monitor.rb 77 def do_callbacks(data) 78 @callbacks.each do |callback| 79 callback.call(data) 80 end 81 end