Class: CoreMIDI::Entity

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

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

A new instance of Entity



16
17
18
19
20
21
22
23
24
# File 'lib/coremidi/entity.rb', line 16

def initialize(resource, options = {}, &block)
  @endpoints = { :input => [], :output => [] }
  @resource = resource
  @manufacturer = get_property(:manufacturer)
  @model = get_property(:model)
  @name = "#{@manufacturer} #{@model}"
  @is_online = get_property(:offline, :type => :int) == 0
  [:input, :output].each { |type| populate_endpoints(type) }
end

Instance Attribute Details

- (Object) endpoints (readonly)

Returns the value of attribute endpoints



7
8
9
# File 'lib/coremidi/entity.rb', line 7

def endpoints
  @endpoints
end

- (Object) is_online (readonly) Also known as: online?

Returns the value of attribute is_online



7
8
9
# File 'lib/coremidi/entity.rb', line 7

def is_online
  @is_online
end

- (Object) manufacturer (readonly)

Returns the value of attribute manufacturer



7
8
9
# File 'lib/coremidi/entity.rb', line 7

def manufacturer
  @manufacturer
end

- (Object) model (readonly)

Returns the value of attribute model



7
8
9
# File 'lib/coremidi/entity.rb', line 7

def model
  @model
end

- (Object) name (readonly)

Returns the value of attribute name



7
8
9
# File 'lib/coremidi/entity.rb', line 7

def name
  @name
end

- (Object) resource (readonly)

Returns the value of attribute resource



7
8
9
# File 'lib/coremidi/entity.rb', line 7

def resource
  @resource
end

Instance Method Details

- (Object) populate_endpoint_ids(starting_id)

assign all of this Entity's endpoints an consecutive id



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

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