Class: UniMIDI::CongruousApiOutput

Inherits:
Object
  • Object
show all
Extended by:
UniMIDI::CongruousApiAdapter::Device::ClassMethods
Includes:
UniMIDI::CongruousApiAdapter::Device
Defined in:
lib/unimidi/congruous_api_adapter.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UniMIDI::CongruousApiAdapter::Device::ClassMethods

[], all, all_by_type, defer_to, device_class, each, find_by_name, first, gets, input_class, last, list, output_class, populate, use

Methods included from UniMIDI::CongruousApiAdapter::Device

#close, #enabled?, included, #initialize, #open, #pretty_name

Class Method Details

.allObject

returns all outputs



311
312
313
# File 'lib/unimidi/congruous_api_adapter.rb', line 311

def self.all
  UniMIDI::Device.all_by_type[:output]
end

Instance Method Details

#puts(*a) ⇒ Object

sends a message to the output. the message can be:

bytes eg output.puts(0x90, 0x40, 0x40) an array of bytes eg output.puts([0x90, 0x40, 0x40]) or a string eg output.puts(“904040”) if none of those types are found, unimidi will attempt to call to_bytes and then to_a on the object



282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/unimidi/congruous_api_adapter.rb', line 282

def puts(*a)
  case a.first
    when Array then puts_bytes(*a.first)
    when Numeric then puts_bytes(*a)
    when String then puts_s(*a)
    else
      if a.first.respond_to?(:to_bytes)
        puts_bytes(*a.first.to_bytes.flatten)
      elsif a.first.respond_to?(:to_a) 
        puts_bytes(*a.first.to_a.flatten)
      end
  end
end

#puts_bytes(*a) ⇒ Object

sends a message to the output in a form of bytes eg output.puts_bytes(0x90, 0x40, 0x40). this method does not do type checking and therefore is more performant than puts



306
307
308
# File 'lib/unimidi/congruous_api_adapter.rb', line 306

def puts_bytes(*a)
  @device.puts_bytes(*a)
end

#puts_s(*a) ⇒ Object Also known as: puts_bytestr, puts_hex

sends a message to the output in a form of a string eg “904040”. this method does not do type checking and therefore is more performant than puts



298
299
300
# File 'lib/unimidi/congruous_api_adapter.rb', line 298

def puts_s(*a)
  @device.puts_s(*a)
end