Class: M3u8::MapItem

Inherits:
Object
  • Object
show all
Extended by:
M3u8
Includes:
M3u8, AttributeFormatter, Serializable
Defined in:
lib/m3u8/map_item.rb

Overview

MapItem represents a EXT-X-MAP tag which specifies how to obtain the Media Initialization Section

Constant Summary

Constants included from M3u8

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from M3u8

initialize_with_byterange, parse_attributes, parse_float, parse_int, parse_yes_no, to_yes_no

Methods included from AttributeFormatter

#boolean_format, #decimal_format, #quoted_format, #unquoted_format

Methods included from Serializable

#as_json, serialize, #to_h, #to_json

Constructor Details

#initialize(params = {}) ⇒ MapItem

Returns a new instance of MapItem.

Parameters:

  • params (Hash) (defaults to: {})

    attribute key-value pairs



17
18
19
# File 'lib/m3u8/map_item.rb', line 17

def initialize(params = {})
  initialize_with_byterange(params)
end

Instance Attribute Details

#byterangeString, ...

Returns:

  • (String, nil)

    URI of the initialization section

  • (ByteRange, nil)

    byte range within the resource



14
15
16
# File 'lib/m3u8/map_item.rb', line 14

def byterange
  @byterange
end

#uriString, ...

Returns:

  • (String, nil)

    URI of the initialization section

  • (ByteRange, nil)

    byte range within the resource



14
15
16
# File 'lib/m3u8/map_item.rb', line 14

def uri
  @uri
end

Class Method Details

.parse(text) ⇒ MapItem

Parse an EXT-X-MAP tag.

Parameters:

  • text (String)

    raw tag line

Returns:



24
25
26
27
28
29
30
# File 'lib/m3u8/map_item.rb', line 24

def self.parse(text)
  attributes = parse_attributes(text)
  range_value = attributes['BYTERANGE']
  range = ByteRange.parse(range_value) unless range_value.nil?
  options = { uri: attributes['URI'], byterange: range }
  MapItem.new(options)
end

Instance Method Details

#to_sString

Render as an m3u8 EXT-X-MAP tag.

Returns:

  • (String)


34
35
36
# File 'lib/m3u8/map_item.rb', line 34

def to_s
  "#EXT-X-MAP:#{formatted_attributes.compact.join(',')}"
end