Module: MTP

Defined in:
lib/mtp.rb,
lib/mtp/fuse.rb,
lib/mtp/track.rb,
lib/mtp/device.rb,
lib/mtp/object.rb,
lib/mtp/storage.rb,
lib/mtp/datacode.rb,
lib/mtp/playlist.rb,
lib/mtp/protocol.rb,
lib/mtp/container.rb,
lib/mtp/datatypes.rb,
lib/mtp/properties.rb,
lib/mtp/association.rb,
lib/mtp/podcast.rb

Overview

Access to MTP compatible device

MTP::Device.find.first.open do |device|

  # fetch the first track artist
  puts device.tracks.first.artist

  # copy each track to local file
  device.tracks.each do |track|
    File.open(track.filename, "w") do |file| 
      device.get(track, file) { |rd, tot| printf("%u/%u", rd, tot) }
    end
  end

  # create a new playlist and assings some tracks
  playlist = Playlist.new
  device.send(playlist)
  playlist.name = 'my playlist'
  playlist << device.tracks[0]
  playlist << device.tracks[1]

end

Defined Under Namespace

Classes: Association, CommandError, Container, Data, Datacode, Device, DeviceError, DeviceNotFound, Event, FileSystem, InvalidObject, MP3Track, MTPError, Object, ParametersContainer, Playlist, Podcast, Properties, Protocol, Request, Response, Storage, Track, UnsupportedProperty, UnsupportedRequest, WriteError, WrongDeviceType

Constant Summary collapse

DATA_TYPES =
{
  0x0000 => "Undefined",
  0x0001 => "INT8",
  0x0002 => "UINT8",
  0x0003 => "INT16",
  0x0004 => "UINT16",
  0x0005 => "INT32",
  0x0006 => "UINT32",
  0x0007 => "INT64",
  0x0008 => "UINT64",
  0x0009 => "INT128",
  0x000A => "UINT128",
  0x4001 => "AINT8",
  0x4002 => "AUINT8",
  0x4003 => "AINT16",
  0x4004 => "AUINT16",
  0x4005 => "AINT32",
  0x4006 => "AUINT32",
  0x4007 => "AINT64",
  0x4008 => "AUINT64",
  0x4009 => "AINT128",
  0x400A => "AUINT128",
  0xFFFF => "String"
}
DATA_TYPE_PACK =
{
  0x0000 => "",
  0x0001 => "c",
  0x0002 => "C",
  0x0003 => "s",
  0x0004 => "S",
  0x0005 => "v",
  0x0006 => "V",
  0x0007 => "q",
  0x0008 => "Q",
  0x0009 => "y",
  0x000A => "Y",
  0x4001 => "c+",
  0x4002 => "C+",
  0x4003 => "s+",
  0x4004 => "S+",
  0x4005 => "v+",
  0x4006 => "V+",
  0x4007 => "q+",
  0x4008 => "Q+",
  0x4009 => "y+",
  0x400A => "Y+",
  0xFFFF => "J"
}
@@logger =
Logger.new(STDERR)

Class Method Summary collapse

Class Method Details

.hd(str) ⇒ Object

use hd to dump a hexadecimal view of a string



43
44
45
46
47
# File 'lib/mtp.rb', line 43

def self.hd(str)
  IO.popen('hd', 'w') do |hd|
    hd.write(str)
  end
end

.loggerObject



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

def self.logger
  @@logger
end