Class: CoreMIDI::Entity
- Inherits:
-
Object
- Object
- CoreMIDI::Entity
- Defined in:
- lib/coremidi/entity.rb
Overview
A MIDI entity can have any number of MIDI endpoints, each of which is a source or destination of a 16-channel MIDI stream. By grouping a device’s endpoints into entities, the system has enough information for an application to make reasonable default assumptions about how to communicate in a bi-directional manner with each entity, as is necessary in MIDI librarian applications.
Instance Attribute Summary collapse
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#manufacturer ⇒ Object
readonly
Returns the value of attribute manufacturer.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(resource, options = {}) ⇒ Entity
constructor
A new instance of Entity.
-
#online? ⇒ Boolean
Is the entity online?.
-
#populate_endpoint_ids(starting_id) ⇒ Integer
Assign all of this Entity’s endpoints an consecutive local id.
Constructor Details
#initialize(resource, options = {}) ⇒ Entity
Returns a new instance of Entity.
21 22 23 24 25 26 27 28 |
# File 'lib/coremidi/entity.rb', line 21 def initialize(resource, = {}) @endpoints = { source: [], destination: [] } @resource = resource populate() end |
Instance Attribute Details
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
12 13 14 |
# File 'lib/coremidi/entity.rb', line 12 def endpoints @endpoints end |
#manufacturer ⇒ Object (readonly)
Returns the value of attribute manufacturer.
12 13 14 |
# File 'lib/coremidi/entity.rb', line 12 def manufacturer @manufacturer end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
12 13 14 |
# File 'lib/coremidi/entity.rb', line 12 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/coremidi/entity.rb', line 12 def name @name end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
12 13 14 |
# File 'lib/coremidi/entity.rb', line 12 def resource @resource end |
Instance Method Details
#online? ⇒ Boolean
Is the entity online?
44 45 46 |
# File 'lib/coremidi/entity.rb', line 44 def online? get_int(:offline) == 0 end |
#populate_endpoint_ids(starting_id) ⇒ Integer
Assign all of this Entity’s endpoints an consecutive local id
33 34 35 36 37 38 39 40 |
# File 'lib/coremidi/entity.rb', line 33 def populate_endpoint_ids(starting_id) counter = 0 @endpoints.values.flatten.each do |endpoint| endpoint.id = counter + starting_id counter += 1 end counter end |