Class: MIDICommunicationsMacOS::Entity
- Inherits:
-
Object
- Object
- MIDICommunicationsMacOS::Entity
- Defined in:
- lib/midi-communications-macos/entity.rb
Overview
A logical grouping of MIDI endpoints within a device.
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 applications to make reasonable default assumptions about bidirectional communication.
Instance Attribute Summary collapse
-
#endpoints ⇒ Hash{Symbol => Array<Endpoint>}
readonly
Endpoints grouped by :source and :destination.
-
#manufacturer ⇒ String
readonly
Device manufacturer name.
-
#model ⇒ String
readonly
Device model name.
-
#name ⇒ String
readonly
Entity name.
- #resource ⇒ Object readonly
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.
32 33 34 35 36 37 38 39 |
# File 'lib/midi-communications-macos/entity.rb', line 32 def initialize(resource, include_offline: false) @endpoints = { source: [], destination: [] } @resource = resource populate(include_offline: include_offline) end |
Instance Attribute Details
#endpoints ⇒ Hash{Symbol => Array<Endpoint>} (readonly)
Returns endpoints grouped by :source and :destination.
24 25 26 |
# File 'lib/midi-communications-macos/entity.rb', line 24 def endpoints @endpoints end |
#manufacturer ⇒ String (readonly)
Returns device manufacturer name.
24 25 26 27 28 |
# File 'lib/midi-communications-macos/entity.rb', line 24 attr_reader :endpoints, :manufacturer, :model, :name, :resource |
#model ⇒ String (readonly)
Returns device model name.
24 25 26 27 28 |
# File 'lib/midi-communications-macos/entity.rb', line 24 attr_reader :endpoints, :manufacturer, :model, :name, :resource |
#name ⇒ String (readonly)
Returns entity name.
24 25 26 27 28 |
# File 'lib/midi-communications-macos/entity.rb', line 24 attr_reader :endpoints, :manufacturer, :model, :name, :resource |
#resource ⇒ Object (readonly)
24 25 26 27 28 |
# File 'lib/midi-communications-macos/entity.rb', line 24 attr_reader :endpoints, :manufacturer, :model, :name, :resource |
Instance Method Details
#display_name ⇒ String
Construct a display name for the entity
61 62 63 |
# File 'lib/midi-communications-macos/entity.rb', line 61 def display_name "#{@manufacturer} #{@model} (#{@name})" end |
#online? ⇒ Boolean
Is the entity online?
55 56 57 |
# File 'lib/midi-communications-macos/entity.rb', line 55 def online? get_int(:offline).zero? end |
#populate_endpoint_ids(starting_id) ⇒ Integer
Assign all of this Entity's endpoints an consecutive local id
44 45 46 47 48 49 50 51 |
# File 'lib/midi-communications-macos/entity.rb', line 44 def populate_endpoint_ids(starting_id) counter = 0 @endpoints.values.flatten.each do |endpoint| endpoint.id = counter + starting_id counter += 1 end counter end |