Module: KBL::Serializable::Playlist

Included in:
Playlist
Defined in:
lib/kbl/serializable/playlist.rb

Instance Method Summary collapse

Instance Method Details

#to_kbl_nodeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kbl/serializable/playlist.rb', line 5

def to_kbl_node
  node = Nokogiri::XML.parse(<<-XML, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
    <playlist>
      <playlist_id>#{ self.id }</playlist_id>
      <playlist_name>#{ self.name }</playlist_name>
      <playlist_descr>#{ self.description }</playlist_descr>
      <playlist_data></playlist_data>
    </playlist>
  XML

  data_node = node.css("playlist_data").first

  @songs.each do |song|
    data_node << song.to_kbl_node
  end

  node.root
end