Sha256: 0e9246fe3460668addcbd3ef5a7b53f73be045b4a85ae1d935795313ed95f622
Contents?: true
Size: 847 Bytes
Versions: 3
Compression:
Stored size: 847 Bytes
Contents
module M3u8 class Writer attr_accessor :io def initialize(io) self.io = io end def write(playlist) validate playlist io.puts '#EXTM3U' write_header(playlist) unless playlist.master? playlist.items.each do |item| io.puts item.to_s end return if playlist.master? io.puts '#EXT-X-ENDLIST' end private def validate(playlist) return if playlist.valid? fail PlaylistTypeError, 'Playlist is invalid.' end def write_header(playlist) io.puts "#EXT-X-VERSION:#{playlist.version}" io.puts "#EXT-X-MEDIA-SEQUENCE:#{playlist.sequence}" io.puts "#EXT-X-ALLOW-CACHE:#{cache(playlist)}" io.puts "#EXT-X-TARGETDURATION:#{playlist.target}" end def cache(playlist) playlist.cache ? 'YES' : 'NO' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
m3u8-0.3.2 | lib/m3u8/writer.rb |
m3u8-0.3.1 | lib/m3u8/writer.rb |
m3u8-0.3.0 | lib/m3u8/writer.rb |