Class: Sh::Playlist
Class Method Summary collapse
Instance Method Summary collapse
- #<<(song) ⇒ Object
-
#initialize(dir) ⇒ Playlist
constructor
A new instance of Playlist.
- #songs ⇒ Object
Constructor Details
#initialize(dir) ⇒ Playlist
Returns a new instance of Playlist.
3 4 5 6 |
# File 'lib/sh_playlist.rb', line 3 def initialize dir @dir = dir @songs = [] end |
Class Method Details
.parse(path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sh_playlist.rb', line 8 def Playlist.parse(path) list = Playlist.new(File.dirname(path)) open(path) do |f| while line = f.gets line.strip! unless line[0] == ?# or line.empty? ref = File.(line.gsub('\\', '/'), File.dirname(path)) if File.exists? ref if Sh::Global::SUPPORTED_EXTENSIONS.include? File.extname(ref) list << ($db.songs(:path => ref).first || Sh::Song.new(ref).) end else puts "Not found: " + ref end end end end return list end |