Class: Livelist::Playlist
- Inherits:
-
Object
- Object
- Livelist::Playlist
- Defined in:
- lib/livelist/playlist.rb
Overview
A Playlist m3u8
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ Playlist
constructor
A new instance of Playlist.
- #path ⇒ Object
-
#to_s ⇒ Object
Return a string version of m3u8 file.
-
#write ⇒ Object
Write the m3u8 file.
Constructor Details
#initialize(path, options = {}) ⇒ Playlist
Returns a new instance of Playlist.
14 15 16 17 18 19 |
# File 'lib/livelist/playlist.rb', line 14 def initialize(path, = {}) @path = path = @tag = "#EXTM3U" raise Exceptions::InvalidFormat unless File.extname(path) == '.m3u8' end |
Instance Method Details
#path ⇒ Object
21 22 23 |
# File 'lib/livelist/playlist.rb', line 21 def path @path end |
#to_s ⇒ Object
Return a string version of m3u8 file
40 41 42 43 44 45 46 47 48 |
# File 'lib/livelist/playlist.rb', line 40 def to_s [ @tag, version, media_sequence, allow_cache?, target_duration ].join("\n") end |
#write ⇒ Object
Write the m3u8 file
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/livelist/playlist.rb', line 26 def write File.open(@path, 'w') do |file| [ @tag, type, version, media_sequence, allow_cache?, target_duration, ].each { |tag| file.puts tag } end end |