Class: FileScheduler::Playlist

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Playlist

Returns a new instance of Playlist.



8
9
10
11
12
13
14
15
# File 'lib/file_scheduler/playlist.rb', line 8

def initialize(attributes = {})
  if String === attributes 
    attributes = 
      { (attributes.url? ? :url : :content) => attributes }
  end

  attributes.each { |k,v| send "#{k}=", v }
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/file_scheduler/playlist.rb', line 6

def content
  @content
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/file_scheduler/playlist.rb', line 6

def url
  @url
end

Instance Method Details

#contentsObject



25
26
27
28
29
# File 'lib/file_scheduler/playlist.rb', line 25

def contents
  lines.collect do |path|
    FileScheduler::URL.new :path => path, :url => full_url(path)
  end.delete_if(&:hidden?)
end

#full_url(path) ⇒ Object



31
32
33
# File 'lib/file_scheduler/playlist.rb', line 31

def full_url(path)
  URI.join url, path if url
end

#linesObject



21
22
23
# File 'lib/file_scheduler/playlist.rb', line 21

def lines
  @lines ||= content.split
end