Sha256: be676252c56e19364fb67e2b881e351cfd897999b1aedab7e5625461b88b5868

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

require 'open-uri'

module FileScheduler
  class Playlist

    attr_accessor :url, :content

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

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

    def content
      @content ||= open(url, &:read)
    end

    def lines
      @lines ||= content.split
    end

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
file_scheduler-0.0.2 lib/file_scheduler/playlist.rb