Module: Denko::Behaviors::Listener

Includes:
Callbacks
Included in:
AnalogIO::Input, DigitalIO::Input
Defined in:
lib/denko/behaviors/listener.rb

Constant Summary

Constants included from Lifecycle

Denko::Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary collapse

Attributes included from State

#state

Instance Method Summary collapse

Methods included from Callbacks

#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update

Methods included from State

#update_state

Methods included from Lifecycle

included

Instance Attribute Details

#dividerObject (readonly)

Returns the value of attribute divider.



6
7
8
# File 'lib/denko/behaviors/listener.rb', line 6

def divider
  @divider
end

Instance Method Details

#listen(divider = nil, &block) ⇒ Object

These delegate to #_listen and #_stop_listener, which should be defined in the including class.



12
13
14
15
16
17
18
# File 'lib/denko/behaviors/listener.rb', line 12

def listen(divider=nil, &block)
  @divider = divider
  stop
  add_callback(:listen, &block) if block_given?
  _listen(@divider)
  @listening = true
end

#stopObject



20
21
22
23
24
25
# File 'lib/denko/behaviors/listener.rb', line 20

def stop
  begin; super; rescue NoMethodError; end
  _stop_listener
  remove_callbacks :listen
  @listening = false
end