Class: Argus::NavMonitor
- Inherits:
-
Object
- Object
- Argus::NavMonitor
- Defined in:
- lib/argus/nav_monitor.rb
Instance Attribute Summary collapse
-
#streamer ⇒ Object
readonly
Returns the value of attribute streamer.
Instance Method Summary collapse
- #callback(callback = nil, &block) ⇒ Object
- #data ⇒ Object
-
#initialize(controller, remote_host) ⇒ NavMonitor
constructor
A new instance of NavMonitor.
- #join ⇒ Object
- #option(tag) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(controller, remote_host) ⇒ NavMonitor
Returns a new instance of NavMonitor.
6 7 8 9 10 11 12 13 |
# File 'lib/argus/nav_monitor.rb', line 6 def initialize(controller, remote_host) @controller = controller @streamer = NavStreamer.new(remote_host: remote_host) @callbacks = [] @mutex = Mutex.new @nav_data = nil @nav_options = {} end |
Instance Attribute Details
#streamer ⇒ Object (readonly)
Returns the value of attribute streamer.
4 5 6 |
# File 'lib/argus/nav_monitor.rb', line 4 def streamer @streamer end |
Instance Method Details
#callback(callback = nil, &block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/argus/nav_monitor.rb', line 34 def callback(callback=nil, &block) @mutex.synchronize do @callbacks << callback unless callback.nil? @callbacks << block if block_given? end end |
#data ⇒ Object
41 42 43 |
# File 'lib/argus/nav_monitor.rb', line 41 def data @mutex.synchronize { @nav_data } end |
#join ⇒ Object
30 31 32 |
# File 'lib/argus/nav_monitor.rb', line 30 def join @nav_thread.join end |
#option(tag) ⇒ Object
45 46 47 |
# File 'lib/argus/nav_monitor.rb', line 45 def option(tag) @mutex.synchronize { @nav_options[tag] } end |
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/argus/nav_monitor.rb', line 15 def start @streamer.start @running = true @nav_thread = Thread.new do while @running data = @streamer.receive_data update_nav_data(data) if data end end end |
#stop ⇒ Object
26 27 28 |
# File 'lib/argus/nav_monitor.rb', line 26 def stop @running = false end |