Class: FormatParser::M3UParser

Inherits:
Object
  • Object
show all
Includes:
IOUtils
Defined in:
lib/parsers/m3u_parser.rb

Constant Summary collapse

HEADER =
'#EXTM3U'
M3U8_MIME_TYPE =
'application/vnd.apple.mpegurl'

Constants included from IOUtils

IOUtils::INTEGER_DIRECTIVES

Instance Method Summary collapse

Methods included from IOUtils

#read_bytes, #read_fixed_point, #read_int, #safe_read, #safe_skip, #skip_bytes

Instance Method Details

#call(io) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/parsers/m3u_parser.rb', line 11

def call(io)
  io = FormatParser::IOConstraint.new(io)

  header = safe_read(io, 7)
  return unless HEADER.eql?(header)

  FormatParser::Text.new(
    format: :m3u,
    content_type: M3U8_MIME_TYPE,
  )
end

#likely_match?(filename) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/parsers/m3u_parser.rb', line 7

def likely_match?(filename)
  filename =~ /\.m3u8?$/i
end