Sha256: 5b4661220ab87ce74c4fb987d1a05db0d7667e7a7b7a8bf6e41c0cb996dcc96d
Contents?: true
Size: 844 Bytes
Versions: 1
Compression:
Stored size: 844 Bytes
Contents
require 'playlist' class Radiodan class MPD module PlaylistParser def self.parse(attributes={}, tracks=[]) options = parse_attributes(attributes) options[:tracks] = parse_tracks(tracks) Playlist.new(options) end private def self.parse_attributes(attributes) options = {} options[:state] = attributes['state'].to_sym options[:mode] = parse_mode(attributes) options[:repeat] = attributes['repeat'] == '1' options[:position] = attributes['song'].to_i options[:seek] = attributes['elapsed'].to_f options[:volume] = attributes['volume'].to_i options end def self.parse_tracks(tracks) tracks.collect{ |t| Track.new(t) } rescue [] end def self.parse_mode(attributes) attributes['random'] == '1' ? :random : :sequential end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radiodan-0.0.4 | lib/radiodan/adapter/mpd/playlist_parser.rb |