Class: RawMIDI::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/rawmidi/card.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Card

Returns a new instance of Card.



13
14
15
16
# File 'lib/rawmidi/card.rb', line 13

def initialize(id)
  @id = id
  @name = API::Card.get_name(id)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/rawmidi/card.rb', line 7

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/rawmidi/card.rb', line 7

def name
  @name
end

Class Method Details

.allObject



9
10
11
# File 'lib/rawmidi/card.rb', line 9

def self.all
  API::Card.each_id.map { |id| new(id) }
end

Instance Method Details

#handle_nameObject



18
19
20
# File 'lib/rawmidi/card.rb', line 18

def handle_name
  "hw:#{@id}"
end

#inputsObject



22
23
24
25
26
# File 'lib/rawmidi/card.rb', line 22

def inputs
  API::Device.each(@id).select { |_, info| info[:input] }.map do |id, info|
    Input.new(self, id, name: info[:name])
  end
end

#inspectObject



38
39
40
# File 'lib/rawmidi/card.rb', line 38

def inspect
  "#<#{self.class.name}:#{"0x%014x" % object_id} #{handle_name} #{@name.inspect}>"
end

#longnameObject



34
35
36
# File 'lib/rawmidi/card.rb', line 34

def longname
  API::Card.get_longname(@id)
end

#outputsObject



28
29
30
31
32
# File 'lib/rawmidi/card.rb', line 28

def outputs
  API::Device.each(@id).select { |_, info| info[:output] }.map do |id, info|
    Output.new(self, id, name: info[:name])
  end
end