Class: M3u8::Reader
- Inherits:
-
Object
- Object
- M3u8::Reader
- Defined in:
- lib/m3u8/reader.rb
Overview
Reader provides parsing of m3u8 playlists
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
-
#master ⇒ Object
Returns the value of attribute master.
-
#open ⇒ Object
Returns the value of attribute open.
-
#playlist ⇒ Object
Returns the value of attribute playlist.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(strict: false) ⇒ Reader
constructor
A new instance of Reader.
-
#read(input) ⇒ Playlist
Parse an m3u8 playlist from a String or IO.
Constructor Details
#initialize(strict: false) ⇒ Reader
Returns a new instance of Reader.
8 9 10 11 12 13 14 15 16 |
# File 'lib/m3u8/reader.rb', line 8 def initialize(strict: false) @strict = strict @has_endlist = false @tags = [, , , , ].inject(:merge) end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
6 7 8 |
# File 'lib/m3u8/reader.rb', line 6 def item @item end |
#master ⇒ Object
Returns the value of attribute master.
6 7 8 |
# File 'lib/m3u8/reader.rb', line 6 def master @master end |
#open ⇒ Object
Returns the value of attribute open.
6 7 8 |
# File 'lib/m3u8/reader.rb', line 6 def open @open end |
#playlist ⇒ Object
Returns the value of attribute playlist.
6 7 8 |
# File 'lib/m3u8/reader.rb', line 6 def playlist @playlist end |
#tags ⇒ Object
Returns the value of attribute tags.
6 7 8 |
# File 'lib/m3u8/reader.rb', line 6 def @tags end |
Instance Method Details
#read(input) ⇒ Playlist
Parse an m3u8 playlist from a String or IO.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/m3u8/reader.rb', line 21 def read(input) @playlist = Playlist.new @has_endlist = false lines = input.is_a?(String) ? input : input.read lines.split(/\r\n|\r|\n/).each_with_index do |line, index| if index.zero? validate_file_format(line) next end parse_line(line) end playlist.live = !@has_endlist unless master playlist.freeze end |