Module: MIDICommunications::Device::InstanceMethods
Overview
Instance Attribute Summary collapse
-
#direction ⇒ Symbol
readonly
The device direction (:input or :output).
-
#display_name ⇒ String
readonly
The device display name.
-
#enabled ⇒ Boolean
readonly
Whether the device is currently open.
-
#id ⇒ Integer
readonly
The device ID.
-
#manufacturer ⇒ String
readonly
The device manufacturer name.
-
#model ⇒ String
readonly
The device model name.
-
#name ⇒ String
readonly
The device name.
Instance Method Summary collapse
-
#close(*args) ⇒ Boolean
Closes the device.
-
#closed? ⇒ Boolean
Returns true if the device is closed (not enabled).
-
#enabled? ⇒ Boolean
Alias for #enabled.
-
#initialize(device) ⇒ Object
private
Creates a new device wrapper.
-
#open(*args) {|device| ... } ⇒ Input, Output
Opens the device for use.
-
#type ⇒ Symbol
Alias for #direction.
Instance Attribute Details
#direction ⇒ Symbol (readonly)
Returns the device direction (:input or :output).
|
|
# File 'lib/midi-communications/device.rb', line 245
|
#display_name ⇒ String (readonly)
Returns the device display name.
|
|
# File 'lib/midi-communications/device.rb', line 263
|
#enabled ⇒ Boolean (readonly)
Returns whether the device is currently open.
|
|
# File 'lib/midi-communications/device.rb', line 248
|
#id ⇒ Integer (readonly)
Returns the device ID.
|
|
# File 'lib/midi-communications/device.rb', line 251
|
#manufacturer ⇒ String (readonly)
Returns the device manufacturer name.
|
|
# File 'lib/midi-communications/device.rb', line 254
|
#model ⇒ String (readonly)
Returns the device model name.
|
|
# File 'lib/midi-communications/device.rb', line 257
|
#name ⇒ String (readonly)
Returns the device name.
|
|
# File 'lib/midi-communications/device.rb', line 260
|
Instance Method Details
#close(*args) ⇒ Boolean
Closes the device.
228 229 230 231 232 233 234 235 236 |
# File 'lib/midi-communications/device.rb', line 228 def close(*args) if @enabled @device.close(*args) @enabled = false true else false end end |
#closed? ⇒ Boolean
Returns true if the device is closed (not enabled).
241 242 243 |
# File 'lib/midi-communications/device.rb', line 241 def closed? !@enabled end |
#enabled? ⇒ Boolean
Returns alias for #enabled.
|
|
# File 'lib/midi-communications/device.rb', line 266
|
#initialize(device) ⇒ Object
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.
Creates a new device wrapper.
177 178 179 180 181 182 |
# File 'lib/midi-communications/device.rb', line 177 def initialize(device) @device = device @enabled = false populate_from_device end |
#open(*args) {|device| ... } ⇒ Input, Output
Opens the device for use.
When a block is given, the device is automatically closed when the block exits. Otherwise, the device is closed at program exit.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/midi-communications/device.rb', line 202 def open(*args) unless @enabled @device.open(*args) @enabled = true end if block_given? begin yield(self) ensure close end else at_exit do close end end self end |