Sha256: 5518488d07933d173b283a907543716c7a6c62572b27c1ab2ca2077281560ac9

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

Contents

module WebMidi
  class Input
    include Native

    alias_native :connection
    alias_native :manufacturer
    alias_native :name
    alias_native :state
    alias_native :type
    alias_native :version

    def initialize(input)
      super(input)
    end

    def on_change_state(&block)
      `#{@native}.onchangestate = #{block}`
    end

    def on_message(&block)
      callback = lambda do |message|
        block.call Message.new(message)
      end
      `#{@native}.onmidimessage = #{callback}`
    end

    def send(*_args)
      fail "Can't send messages to Input"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-web-midi-0.0.2 opal/web_midi/input.rb
opal-web-midi-0.0.1 opal/web_midi/input.rb