Class: M3u8::Reader

Inherits:
Object
  • Object
show all
Includes:
M3u8
Defined in:
lib/m3u8/reader.rb

Overview

Reader provides parsing of m3u8 playlists

Constant Summary

Constants included from M3u8

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from M3u8

#intialize_with_byterange, #parse_attributes, #parse_float, #parse_yes_no, #to_yes_no

Constructor Details

#initializeReader

Returns a new instance of Reader.



8
9
10
11
12
13
14
# File 'lib/m3u8/reader.rb', line 8

def initialize(*)
  @tags = [basic_tags,
           media_segment_tags,
           media_playlist_tags,
           master_playlist_tags,
           universal_tags].inject(:merge)
end

Instance Attribute Details

#itemObject

Returns the value of attribute item.



6
7
8
# File 'lib/m3u8/reader.rb', line 6

def item
  @item
end

#masterObject

Returns the value of attribute master.



6
7
8
# File 'lib/m3u8/reader.rb', line 6

def master
  @master
end

#openObject

Returns the value of attribute open.



6
7
8
# File 'lib/m3u8/reader.rb', line 6

def open
  @open
end

#playlistObject

Returns the value of attribute playlist.



6
7
8
# File 'lib/m3u8/reader.rb', line 6

def playlist
  @playlist
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/m3u8/reader.rb', line 6

def tags
  @tags
end

Instance Method Details

#read(input) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/m3u8/reader.rb', line 16

def read(input)
  @playlist = Playlist.new
  input.each_line.with_index do |line, index|
    validate_file_format(line) if index.zero?
    parse_line(line)
  end
  playlist
end