class Orocos::Async::EventListener

Attributes

event[R]
last_args[R]

Public Class Methods

new(obj,event,use_last_value=true,&block) click to toggle source
# File lib/orocos/async/object_base.rb, line 7
def initialize(obj,event,use_last_value=true,&block)
    @block = block
    if !obj
        raise ArgumentError, "no object given"
    end
    @obj = obj
    @event = event
    @use_last_value = use_last_value
    @last_args
end

Public Instance Methods

call(*args) click to toggle source

calls the callback

# File lib/orocos/async/object_base.rb, line 49
def call(*args)
    @last_args = args
    @block.call *args
end
listening?() click to toggle source

return true if the listener is listing to the event

# File lib/orocos/async/object_base.rb, line 44
def listening?
    @obj.listener?(self)
end
start(use_last_value = @use_last_value) click to toggle source

start listing to the event

# File lib/orocos/async/object_base.rb, line 36
def start(use_last_value = @use_last_value)
    @use_last_value = use_last_value
    @obj.add_listener(self)
    self
end
stop() click to toggle source

stop listing to the event

# File lib/orocos/async/object_base.rb, line 29
def stop
    @last_args = nil
    @obj.remove_listener(self)
    self
end
use_last_value?() click to toggle source

returns true if the listener shall be called with the last available value when started

# File lib/orocos/async/object_base.rb, line 20
def use_last_value?
    !!@use_last_value
end