class Shmidi::Switch

Constants

CTYPE

Attributes

switch_state[R]

Public Class Methods

new(id, socket, channel, note, led_note = nil) click to toggle source
Calls superclass method Shmidi::LedButton::new
# File lib/shmidi/switch.rb, line 6
def initialize(id, socket, channel, note, led_note = nil)
  super(id, socket, channel, note, led_note)
  @switch_state = false
  @on_switch = []
end

Public Instance Methods

on_switch_state(&block) click to toggle source
# File lib/shmidi/switch.rb, line 12
def on_switch_state(&block)
  @on_switch << block
end

Protected Instance Methods

on_button_press(button) click to toggle source
# File lib/shmidi/switch.rb, line 18
def on_button_press(button)
  (@switch_state = !@switch_state) ? @led.turn_on : @led.turn_off
  Shmidi.TRACE {"#{CTYPE}\t#{@id}\tSTATE\t#{@switch_state ? :ON : :OFF}"}
  @on_switch.each { |b| b.call(self) }
end
on_button_release(button) click to toggle source
# File lib/shmidi/switch.rb, line 24
def on_button_release(button)
  nil
end