Module: CoreMIDI::Endpoint
Overview
A MIDI source or destination, owned by an entity.
Instance Attribute Summary collapse
-
#enabled ⇒ Object
(also: #enabled?)
readonly
has the endpoint been initialized?.
-
#entity ⇒ Object
readonly
has the endpoint been initialized?.
-
#id ⇒ Object
has the endpoint been initialized?.
-
#resource_id ⇒ Object
readonly
has the endpoint been initialized?.
-
#type ⇒ Object
readonly
has the endpoint been initialized?.
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
- #initialize(resource_id, entity) ⇒ Object
-
#online? ⇒ Boolean
Is this endpoint online?.
Instance Attribute Details
#enabled ⇒ Object (readonly) Also known as: enabled?
has the endpoint been initialized?
8 9 10 |
# File 'lib/coremidi/endpoint.rb', line 8 def enabled @enabled end |
#entity ⇒ Object (readonly)
has the endpoint been initialized?
8 9 10 |
# File 'lib/coremidi/endpoint.rb', line 8 def entity @entity end |
#id ⇒ Object
has the endpoint been initialized?
8 9 10 |
# File 'lib/coremidi/endpoint.rb', line 8 def id @id end |
#resource_id ⇒ Object (readonly)
has the endpoint been initialized?
8 9 10 |
# File 'lib/coremidi/endpoint.rb', line 8 def resource_id @resource_id end |
#type ⇒ Object (readonly)
has the endpoint been initialized?
8 9 10 |
# File 'lib/coremidi/endpoint.rb', line 8 def type @type end |
Class Method Details
.all ⇒ Array<Destination, Source>
All endpoints of both types
75 76 77 |
# File 'lib/coremidi/endpoint.rb', line 75 def self.all Device.all.map(&:endpoints).flatten end |
.all_by_type ⇒ Hash
A Hash of :source and :destination endpoints
66 67 68 69 70 71 |
# File 'lib/coremidi/endpoint.rb', line 66 def self.all_by_type { :source => sources, :destination => destinations } end |
.destinations ⇒ Array<Destination>
All destination endpoints
60 61 62 |
# File 'lib/coremidi/endpoint.rb', line 60 def self.destinations Device.all.map { |d| d.endpoints[:destination] }.flatten end |
.first(type) ⇒ Destination, Source
Select the first endpoint of the specified type
42 43 44 |
# File 'lib/coremidi/endpoint.rb', line 42 def self.first(type) all_by_type[type].first end |
.get_class(type) ⇒ Class
Get the class for the given endpoint type name
82 83 84 85 86 87 |
# File 'lib/coremidi/endpoint.rb', line 82 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
48 49 50 |
# File 'lib/coremidi/endpoint.rb', line 48 def self.last(type) all_by_type[type].last end |
.sources ⇒ Array<Source>
All source endpoints
54 55 56 |
# File 'lib/coremidi/endpoint.rb', line 54 def self.sources Device.all.map { |d| d.endpoints[:source] }.flatten end |
Instance Method Details
#initialize(resource_id, entity) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/coremidi/endpoint.rb', line 20 def initialize(resource_id, entity) @entity = entity @resource_id = resource_id @type = get_type @enabled = false end |
#online? ⇒ Boolean
Is this endpoint online?
29 30 31 |
# File 'lib/coremidi/endpoint.rb', line 29 def online? @entity.online? && connect? end |