Module: EventMachine::Gpio::Callbacks
- Included in:
- Pin
- Defined in:
- lib/em-gpio/callbacks.rb
Constant Summary collapse
- VALID_ON_OPTIONS =
[:change, :high, :low]
Instance Method Summary collapse
Instance Method Details
#callback(options = {}, &handler) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/em-gpio/callbacks.rb', line 7 def callback(={}, &handler) callback_wrapper do event = .fetch(:on, :change) raise(ArgumentError, "Unknown event #{on.inspect} specified") unless VALID_ON_OPTIONS.include?(event) instance_variable_set("@on_#{event}", handler) end self end |