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 249
|
#display_name ⇒ String (readonly)
Returns the device display name.
|
|
# File 'lib/midi-communications/device.rb', line 267
|
#enabled ⇒ Boolean (readonly)
Returns whether the device is currently open.
|
|
# File 'lib/midi-communications/device.rb', line 252
|
#id ⇒ Integer (readonly)
Returns the device ID.
|
|
# File 'lib/midi-communications/device.rb', line 255
|
#manufacturer ⇒ String (readonly)
Returns the device manufacturer name.
|
|
# File 'lib/midi-communications/device.rb', line 258
|
#model ⇒ String (readonly)
Returns the device model name.
|
|
# File 'lib/midi-communications/device.rb', line 261
|
#name ⇒ String (readonly)
Returns the device name.
|
|
# File 'lib/midi-communications/device.rb', line 264
|
Instance Method Details
#close(*args) ⇒ Boolean
Closes the device.
232 233 234 235 236 237 238 239 240 |
# File 'lib/midi-communications/device.rb', line 232 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).
245 246 247 |
# File 'lib/midi-communications/device.rb', line 245 def closed? !@enabled end |
#enabled? ⇒ Boolean
Returns alias for #enabled.
|
|
# File 'lib/midi-communications/device.rb', line 270
|
#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.
181 182 183 184 185 186 |
# File 'lib/midi-communications/device.rb', line 181 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.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/midi-communications/device.rb', line 206 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 |