Class: MPD::Playlist

Inherits:
Array
  • Object
show all
Defined in:
lib/mpd/playlist.rb

Overview

Array<SongInfo> with some useful methods

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Playlist

data - array of hashes from MPD



16
17
18
# File 'lib/mpd/playlist.rb', line 16

def initialize(data)
  super(data.map { |info| Song.new(info) })
end

Class Method Details

.from_response(response) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/mpd/playlist.rb', line 6

def self.from_response(response)
  data = [{}]
  response.key_value_pairs.each do |k, v|
    data.push({}) if data.last.key?(k) # next song reached
    data.last[k] = v
  end
  new(data)
end