Module: UniMIDI::Loader

Extended by:
Loader
Included in:
Loader
Defined in:
lib/unimidi/loader.rb

Overview

Populate UniMIDI devices using the underlying device objects from the platform-specific gems

Instance Method Summary collapse

Instance Method Details

#devices(options = {}) ⇒ Array<Input>, Array<Output>

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :direction (Symbol)

    Return only a particular direction of device eg :input, :output

Returns:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/unimidi/loader.rb', line 17

def devices(options = {})
  if @devices.nil?
    inputs = @loader.inputs.map { |device| ::UniMIDI::Input.new(device) }
    outputs = @loader.outputs.map { |device| ::UniMIDI::Output.new(device) }
    @devices = {
      :input => inputs,
      :output => outputs
    }
  end
  options[:direction].nil? ? @devices.values.flatten : @devices[options[:direction]]
end

#use(loader) ⇒ Object

Use the given platform-specific adapter to load devices

Parameters:

  • loader (UniMIDI::Adapter::Loader)


10
11
12
# File 'lib/unimidi/loader.rb', line 10

def use(loader)
  @loader = loader
end