Class: MIDICommunications::Loader Private
- Inherits:
-
Object
- Object
- MIDICommunications::Loader
- Defined in:
- lib/midi-communications/loader.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Populates MIDI devices using platform-specific adapters.
This class lazily loads and caches MIDI devices from the underlying platform adapter (macOS, Linux, Windows, or JRuby).
Class Method Summary collapse
-
.devices(options = {}) ⇒ Array<Input>, Array<Output>
private
Returns all MIDI devices, optionally filtered by direction.
-
.use(loader) ⇒ Module
private
Sets the platform-specific loader to use.
Class Method Details
.devices(options = {}) ⇒ Array<Input>, Array<Output>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all MIDI devices, optionally filtered by direction.
Lazily loads and caches devices from the platform adapter on first call.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/midi-communications/loader.rb', line 25 def devices( = {}) if @devices.nil? inputs = @loader.inputs.map { |device| ::MIDICommunications::Input.new(device) } outputs = @loader.outputs.map { |device| ::MIDICommunications::Output.new(device) } @devices = { input: inputs, output: outputs } end [:direction].nil? ? @devices.values.flatten : @devices[[:direction]] end |
.use(loader) ⇒ Module
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets the platform-specific loader to use.
14 15 16 |
# File 'lib/midi-communications/loader.rb', line 14 def use(loader) @loader = loader end |