Module: MIDICommunicationsMacOS::Endpoint
- Extended by:
- Forwardable
- Included in:
- Destination, Source
- Defined in:
- lib/midi-communications-macos/endpoint.rb
Overview
A source or destination of a 16-channel MIDI stream.
This module provides shared functionality for both Source (input) and Destination (output) endpoints. Each endpoint represents a single point of MIDI communication within an Entity.
Instance Attribute Summary collapse
-
#enabled ⇒ Boolean
(also: #enabled?)
readonly
Whether the endpoint has been initialized.
-
#entity ⇒ Entity
readonly
The parent entity.
-
#id ⇒ Integer
Unique local numeric ID of the endpoint.
-
#resource_id ⇒ Integer
readonly
Core MIDI resource identifier.
- #type ⇒ Object readonly
Class Method Summary collapse
-
.all ⇒ Array<Destination, Source>
All endpoints of both types.
-
.all_by_type ⇒ Hash
A Hash of :source and :destination endpoints.
-
.destinations ⇒ Array<Destination>
All destination endpoints.
-
.first(type) ⇒ Destination, Source
Select the first endpoint of the specified type.
-
.get_class(type) ⇒ Class
Get the class for the given endpoint type name.
-
.last(type) ⇒ Destination, Source
Select the last endpoint of the specified type.
-
.sources ⇒ Array<Source>
All source endpoints.
Instance Method Summary collapse
-
#display_name ⇒ String
Formatted display name (delegated to entity).
- #initialize(resource_id, entity) ⇒ Object
-
#manufacturer ⇒ String
Device manufacturer name (delegated to entity).
-
#model ⇒ String
Device model name (delegated to entity).
-
#name ⇒ String
Endpoint name (delegated to entity).
-
#online? ⇒ Boolean
Is this endpoint online?.
Instance Attribute Details
#enabled ⇒ Boolean (readonly) Also known as: enabled?
Returns whether the endpoint has been initialized.
24 25 26 |
# File 'lib/midi-communications-macos/endpoint.rb', line 24 def enabled @enabled end |
#entity ⇒ Entity (readonly)
Returns the parent entity.
24 25 26 27 28 |
# File 'lib/midi-communications-macos/endpoint.rb', line 24 attr_reader :enabled, :entity, :id, :resource_id, :type |
#id ⇒ Integer
Returns unique local numeric ID of the endpoint.
24 25 26 27 28 |
# File 'lib/midi-communications-macos/endpoint.rb', line 24 attr_reader :enabled, :entity, :id, :resource_id, :type |
#resource_id ⇒ Integer (readonly)
Returns Core MIDI resource identifier.
24 25 26 27 28 |
# File 'lib/midi-communications-macos/endpoint.rb', line 24 attr_reader :enabled, :entity, :id, :resource_id, :type |
#type ⇒ Object (readonly)
24 25 26 27 28 |
# File 'lib/midi-communications-macos/endpoint.rb', line 24 attr_reader :enabled, :entity, :id, :resource_id, :type |
Class Method Details
.all ⇒ Array<Destination, Source>
All endpoints of both types
106 107 108 |
# File 'lib/midi-communications-macos/endpoint.rb', line 106 def self.all Device.all.map(&:endpoints).flatten end |
.all_by_type ⇒ Hash
A Hash of :source and :destination endpoints
97 98 99 100 101 102 |
# File 'lib/midi-communications-macos/endpoint.rb', line 97 def self.all_by_type { source: sources, destination: destinations } end |
.destinations ⇒ Array<Destination>
All destination endpoints
91 92 93 |
# File 'lib/midi-communications-macos/endpoint.rb', line 91 def self.destinations Device.all.map { |d| d.endpoints[:destination] }.flatten end |
.first(type) ⇒ Destination, Source
Select the first endpoint of the specified type
73 74 75 |
# File 'lib/midi-communications-macos/endpoint.rb', line 73 def self.first(type) all_by_type[type].first end |
.get_class(type) ⇒ Class
Get the class for the given endpoint type name
113 114 115 116 117 118 |
# File 'lib/midi-communications-macos/endpoint.rb', line 113 def self.get_class(type) case type when :source then Source when :destination then Destination end end |
.last(type) ⇒ Destination, Source
Select the last endpoint of the specified type
79 80 81 |
# File 'lib/midi-communications-macos/endpoint.rb', line 79 def self.last(type) all_by_type[type].last end |
Instance Method Details
#display_name ⇒ String
Returns formatted display name (delegated to entity).
38 |
# File 'lib/midi-communications-macos/endpoint.rb', line 38 def_delegators :entity, :manufacturer, :model, :name, :display_name |
#initialize(resource_id, entity) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/midi-communications-macos/endpoint.rb', line 46 def initialize(resource_id, entity) @entity = entity @resource_id = resource_id @type = get_type @enabled = false @name = nil @threads_sync_semaphore = Mutex.new @threads_waiting = [] end |
#manufacturer ⇒ String
Returns device manufacturer name (delegated to entity).
38 |
# File 'lib/midi-communications-macos/endpoint.rb', line 38 def_delegators :entity, :manufacturer, :model, :name, :display_name |
#model ⇒ String
Returns device model name (delegated to entity).
38 |
# File 'lib/midi-communications-macos/endpoint.rb', line 38 def_delegators :entity, :manufacturer, :model, :name, :display_name |
#name ⇒ String
Returns endpoint name (delegated to entity).
38 |
# File 'lib/midi-communications-macos/endpoint.rb', line 38 def_delegators :entity, :manufacturer, :model, :name, :display_name |
#online? ⇒ Boolean
Is this endpoint online?
60 61 62 |
# File 'lib/midi-communications-macos/endpoint.rb', line 60 def online? @entity.online? && connect? end |