Module: CoreMIDI::Endpoint

Extended by:
Forwardable
Included in:
Destination, Source
Defined in:
lib/coremidi/endpoint.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) enabled (readonly) Also known as: enabled?

has the endpoint been initialized?



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

def enabled
  @enabled
end

- (Object) entity (readonly)

has the endpoint been initialized?



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

def entity
  @entity
end

- (Object) id

has the endpoint been initialized?



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

def id
  @id
end

- (Object) resource_id (readonly)

has the endpoint been initialized?



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

def resource_id
  @resource_id
end

- (Object) type (readonly)

has the endpoint been initialized?



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

def type
  @type
end

Class Method Details

+ (Object) all

All endpoints of both types



53
54
55
# File 'lib/coremidi/endpoint.rb', line 53

def self.all
  Device.all.map { |d| d.endpoints }.flatten
end

+ (Object) all_by_type

A Hash of :source and :destination endpoints



45
46
47
48
49
50
# File 'lib/coremidi/endpoint.rb', line 45

def self.all_by_type
  {
    :source => Device.all.map { |d| d.endpoints[:source] }.flatten,
    :destination => Device.all.map { |d| d.endpoints[:destination] }.flatten
  }
end

+ (Object) first(type)

Select the first endpoint of the specified type



35
36
37
# File 'lib/coremidi/endpoint.rb', line 35

def self.first(type)
  all_by_type[type].first
end

+ (Object) last(type)

Select the last endpoint of the specified type



40
41
42
# File 'lib/coremidi/endpoint.rb', line 40

def self.last(type)
  all_by_type[type].last
end

Instance Method Details

- (Object) initialize(resource_id, entity, options = {}, &block)



17
18
19
20
21
22
# File 'lib/coremidi/endpoint.rb', line 17

def initialize(resource_id, entity, options = {}, &block)
  @entity = entity
  @resource_id = resource_id
  @type = self.class.name.split('::').last.downcase.to_sym
  @enabled = false
end

- (Boolean) online?

Is this endpoint online?

Returns:

  • (Boolean)


25
26
27
# File 'lib/coremidi/endpoint.rb', line 25

def online?
  @entity.online? && connect?
end