Module: UniMIDI::CongruousApiAdapter::Device
- Included in:
- UniMIDI::CongruousApiInput, UniMIDI::CongruousApiOutput
- Defined in:
- lib/unimidi/congruous_api_adapter.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#close(*a) ⇒ Object
close the device.
- #enabled? ⇒ Boolean
- #initialize(device_obj) ⇒ Object
-
#open(*a, &block) ⇒ Object
enable the device for use, can be passed a block to which the device will be passed back.
- #pretty_name ⇒ Object
Class Method Details
.included(base) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 44 def self.included(base) base.send(:attr_reader, :name) base.send(:attr_reader, :id) base.send(:attr_reader, :type) base.send(:alias_method, :direction, :type) end |
Instance Method Details
#close(*a) ⇒ Object
close the device
40 41 42 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 40 def close(*a) @device.close(*a) end |
#enabled? ⇒ Boolean
14 15 16 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 14 def enabled? @device.enabled end |
#initialize(device_obj) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 7 def initialize(device_obj) @device = device_obj @id = @device.id @name = @device.name populate_type end |
#open(*a, &block) ⇒ Object
enable the device for use, can be passed a block to which the device will be passed back
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 19 def open(*a, &block) @device.open(*a) unless enabled? if block_given? begin yield(self) ensure close end else at_exit do close end self end end |
#pretty_name ⇒ Object
35 36 37 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 35 def pretty_name "#{id}) #{name}" end |