Class: MIDICommunicationsMacOS::Entity
- Inherits:
-
Object
- Object
- MIDICommunicationsMacOS::Entity
- Defined in:
- lib/midi-communications-macos/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
-
#display_name ⇒ String
Construct a display name for the entity.
-
#initialize(resource, include_offline: false) ⇒ 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, include_offline: false) ⇒ Entity
Returns a new instance of Entity.
18 19 20 21 22 23 24 25 |
# File 'lib/midi-communications-macos/entity.rb', line 18 def initialize(resource, include_offline: false) @endpoints = { source: [], destination: [] } @resource = resource populate(include_offline: include_offline) end |
Instance Attribute Details
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
10 11 12 |
# File 'lib/midi-communications-macos/entity.rb', line 10 def endpoints @endpoints end |
#manufacturer ⇒ Object (readonly)
Returns the value of attribute manufacturer.
10 11 12 |
# File 'lib/midi-communications-macos/entity.rb', line 10 def manufacturer @manufacturer end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
10 11 12 |
# File 'lib/midi-communications-macos/entity.rb', line 10 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/midi-communications-macos/entity.rb', line 10 def name @name end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
10 11 12 |
# File 'lib/midi-communications-macos/entity.rb', line 10 def resource @resource end |
Instance Method Details
#display_name ⇒ String
Construct a display name for the entity
47 48 49 |
# File 'lib/midi-communications-macos/entity.rb', line 47 def display_name "#{@manufacturer} #{@model} (#{@name})" end |
#online? ⇒ Boolean
Is the entity online?
41 42 43 |
# File 'lib/midi-communications-macos/entity.rb', line 41 def online? get_int(:offline).zero? end |
#populate_endpoint_ids(starting_id) ⇒ Integer
Assign all of this Entity’s endpoints an consecutive local id
30 31 32 33 34 35 36 37 |
# File 'lib/midi-communications-macos/entity.rb', line 30 def populate_endpoint_ids(starting_id) counter = 0 @endpoints.values.flatten.each do |endpoint| endpoint.id = counter + starting_id counter += 1 end counter end |