Class: M3u8::Writer
- Inherits:
-
Object
- Object
- M3u8::Writer
- Defined in:
- lib/m3u8/writer.rb
Overview
Writer provides generation of text output of playlists in m3u8 format
Instance Attribute Summary collapse
-
#io ⇒ IO
Output stream.
Instance Method Summary collapse
-
#initialize(io) ⇒ Writer
constructor
A new instance of Writer.
-
#write(playlist) ⇒ void
Write a playlist to the output stream.
- #write_footer(playlist) ⇒ Object
- #write_header(playlist) ⇒ Object
Constructor Details
#initialize(io) ⇒ Writer
Returns a new instance of Writer.
10 11 12 |
# File 'lib/m3u8/writer.rb', line 10 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ IO
Returns output stream.
7 8 9 |
# File 'lib/m3u8/writer.rb', line 7 def io @io end |
Instance Method Details
#write(playlist) ⇒ void
This method returns an undefined value.
Write a playlist to the output stream.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/m3u8/writer.rb', line 17 def write(playlist) validate(playlist) write_header(playlist) playlist.items.each do |item| io.puts item.to_s end (playlist) end |
#write_footer(playlist) ⇒ Object
28 29 30 31 32 |
# File 'lib/m3u8/writer.rb', line 28 def (playlist) return if playlist.live? || playlist.master? io.puts '#EXT-X-ENDLIST' end |
#write_header(playlist) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/m3u8/writer.rb', line 34 def write_header(playlist) io.puts '#EXTM3U' if playlist.master? write_master_playlist_header(playlist) else write_media_playlist_header(playlist) end end |