Module: MIDICommunicationsWindows::Device::InstanceMethods
Overview
Methods on an individual port.
Instance Attribute Summary collapse
- #enabled ⇒ Object (also: #enabled?) readonly
-
#id ⇒ Integer
readonly
The port's WinMM index within its direction; see the note on identity in MIDICommunicationsWindows::Device.
-
#name ⇒ String
readonly
The port's name, as WinMM reports it, truncated to 31 characters.
Instance Method Summary collapse
-
#close ⇒ Boolean
Closes the port.
-
#display_name ⇒ String
The name to show a person choosing a port.
- #initialize(id, name) ⇒ Object private
-
#manufacturer ⇒ nil
Who made the device.
-
#model ⇒ nil
The device model.
-
#open {|self| ... } ⇒ self
(also: #enable, #start)
Opens the port.
- #to_s ⇒ String
-
#type ⇒ Symbol
The port's direction.
Instance Attribute Details
#enabled ⇒ Object (readonly) Also known as: enabled?
98 |
# File 'lib/midi-communications-windows/device.rb', line 98 attr_reader :id, :name, :enabled |
#id ⇒ Integer (readonly)
Returns the port's WinMM index within its direction; see the note on identity in MIDICommunicationsWindows::Device.
98 99 100 |
# File 'lib/midi-communications-windows/device.rb', line 98 def id @id end |
#name ⇒ String (readonly)
Returns the port's name, as WinMM reports it, truncated to 31 characters. Not unique: see the note on names in MIDICommunicationsWindows::Device.
98 |
# File 'lib/midi-communications-windows/device.rb', line 98 attr_reader :id, :name, :enabled |
Instance Method Details
#close ⇒ Boolean
Closes the port.
181 182 183 184 185 186 187 188 |
# File 'lib/midi-communications-windows/device.rb', line 181 def close return false unless @enabled disconnect @enabled = false true end |
#display_name ⇒ String
The name to show a person choosing a port.
This is the port name unchanged. On macOS the display name is built as "manufacturer model (name)", which here would render as a name wrapped in the punctuation of two absent fields.
146 147 148 |
# File 'lib/midi-communications-windows/device.rb', line 146 def display_name @name end |
#initialize(id, name) ⇒ 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.
107 108 109 110 111 |
# File 'lib/midi-communications-windows/device.rb', line 107 def initialize(id, name) @id = id @name = name @enabled = false end |
#manufacturer ⇒ nil
Who made the device.
Always nil on Windows. See the note in MIDICommunicationsWindows::Device for why this is not
derived from wMid.
126 127 128 |
# File 'lib/midi-communications-windows/device.rb', line 126 def manufacturer nil end |
#model ⇒ nil
The device model.
Always nil on Windows, for the same reason as #manufacturer.
135 136 137 |
# File 'lib/midi-communications-windows/device.rb', line 135 def model nil end |
#open {|self| ... } ⇒ self Also known as: enable, start
Opens the port.
Opening twice is not an error and does nothing the second time, which
is what midi-communications relies on when it opens a port a caller
may already hold.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/midi-communications-windows/device.rb', line 159 def open unless @enabled connect @enabled = true end if block_given? begin yield self ensure close end end self end |
#to_s ⇒ String
191 192 193 |
# File 'lib/midi-communications-windows/device.rb', line 191 def to_s "#{self.class.name.split('::').last} #{@id}: #{@name}" end |
#type ⇒ Symbol
The port's direction.
116 117 118 |
# File 'lib/midi-communications-windows/device.rb', line 116 def type self.class.direction end |