Class: MTP::Playlist
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/mtp/playlist.rb
Constant Summary
Constants inherited
from Object
Object::PROTECTION_STATUS
Instance Attribute Summary
Attributes inherited from Object
#association, #compressed_size, #data, #date_created, #date_modified, #filename, #format, #id, #image_bit_depth, #image_pix_height, #image_pix_with, #keywords, #ph, #properties, #protection_status, #sequence_number, #thumb_compressed_size, #thumb_format, #thumb_pix_height, #thumb_pix_width
Instance Method Summary
collapse
Methods inherited from Object
#<=>, #after_sending, #before_sending, #dump_properties, #inspect, load, #new_object?, #pack, property_accessor, property_reader, property_writer, register_format, #valid?
Constructor Details
Returns a new instance of Playlist.
8
9
10
11
12
13
|
# File 'lib/mtp/playlist.rb', line 8
def initialize
super
self.format = "AbstractAudioVideoPlaylist"
self.compressed_size = 0
@data = Data.new("\0\0")
end
|
Instance Method Details
#<<(object) ⇒ Object
28
29
30
31
32
|
# File 'lib/mtp/playlist.rb', line 28
def <<(object)
current_ids = map { |o| o.id }
current_ids << object.id
store_references(current_ids)
end
|
#delete(object) ⇒ Object
34
35
36
37
38
|
# File 'lib/mtp/playlist.rb', line 34
def delete(object)
current_ids = select { |o| o.id != object.id }
current_ids.map! { |o| o.id }
store_references(current_ids)
end
|
19
20
21
22
23
24
25
26
|
# File 'lib/mtp/playlist.rb', line 19
def each
MTP.logger.info("retrieving playlist reference")
t = @ph.transaction.get_object_references(id)
t.expect("OK")
t.data.payload.unpack("V+").first.each do |object_id|
yield @ph.device[object_id] unless @ph.device[object_id].nil?
end
end
|
#load(ph, id, payload) ⇒ Object
15
16
17
|
# File 'lib/mtp/playlist.rb', line 15
def load(ph, id, payload)
super(ph, id, payload)
end
|
#sort!(&block) ⇒ Object
40
41
42
43
|
# File 'lib/mtp/playlist.rb', line 40
def sort!(&block)
current_ids = sort(&block).map { |o| o.id }
store_references(current_ids)
end
|
#sort_by!(&block) ⇒ Object
45
46
47
48
|
# File 'lib/mtp/playlist.rb', line 45
def sort_by!(&block)
current_ids = sort_by(&block).map { |o| o.id }
store_references(current_ids)
end
|