Class: CoreMIDI::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/coremidi/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, options = {}, &block) ⇒ Entity

Returns a new instance of Entity.

Parameters:

  • resource (FFI::Pointer)

    A pointer to the underlying entity

  • options (Hash) (defaults to: {})


14
15
16
17
18
19
20
21
# File 'lib/coremidi/entity.rb', line 14

def initialize(resource, options = {}, &block)
  @endpoints = { 
    :source => [], 
    :destination => [] 
  }
  @resource = resource
  populate
end

Instance Attribute Details

#endpointsObject (readonly)

Returns the value of attribute endpoints.



5
6
7
# File 'lib/coremidi/entity.rb', line 5

def endpoints
  @endpoints
end

#is_onlineObject (readonly)

Returns the value of attribute is_online.



5
6
7
# File 'lib/coremidi/entity.rb', line 5

def is_online
  @is_online
end

#manufacturerObject (readonly)

Returns the value of attribute manufacturer.



5
6
7
# File 'lib/coremidi/entity.rb', line 5

def manufacturer
  @manufacturer
end

#modelObject (readonly)

Returns the value of attribute model.



5
6
7
# File 'lib/coremidi/entity.rb', line 5

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/coremidi/entity.rb', line 5

def name
  @name
end

#resourceObject (readonly)

Returns the value of attribute resource.



5
6
7
# File 'lib/coremidi/entity.rb', line 5

def resource
  @resource
end

Instance Method Details

#online?Boolean

Is the entity online?

Returns:

  • (Boolean)


37
38
39
# File 'lib/coremidi/entity.rb', line 37

def online?
  get_property(:offline, :type => :int) == 0
end

#populate_endpoint_ids(starting_id) ⇒ Fixnum

Assign all of this Entity’s endpoints an consecutive local id

Parameters:

  • starting_id (Fixnum)

Returns:

  • (Fixnum)


26
27
28
29
30
31
32
33
# File 'lib/coremidi/entity.rb', line 26

def populate_endpoint_ids(starting_id)
  counter = 0
  @endpoints.values.flatten.each do |endpoint|  
    endpoint.id = counter + starting_id
    counter += 1
  end
  counter
end