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
-
#divider ⇒ Object
readonly
Returns the value of attribute divider.
Attributes included from State
Instance Method Summary collapse
-
#listen(divider = nil, &block) ⇒ Object
These delegate to #_listen and #_stop_listener, which should be defined in the including class.
- #stop ⇒ Object
Methods included from Callbacks
#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update
Methods included from State
Methods included from Lifecycle
Instance Attribute Details
#divider ⇒ Object (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 |
#stop ⇒ Object
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 |