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)

Returns a new instance of Entity



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

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

Instance Attribute Details

- (Object) endpoints (readonly)

Returns the value of attribute endpoints



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

def endpoints
  @endpoints
end

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

Returns the value of attribute is_online



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

def is_online
  @is_online
end

- (Object) manufacturer (readonly)

Returns the value of attribute manufacturer



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

def manufacturer
  @manufacturer
end

- (Object) model (readonly)

Returns the value of attribute model



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

def model
  @model
end

- (Object) name (readonly)

Returns the value of attribute name



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

def name
  @name
end

- (Object) resource (readonly)

Returns the value of attribute resource



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

def resource
  @resource
end

Instance Method Details

- (Object) populate_endpoint_ids(starting_id)

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



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

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