Class: M3u8::PreloadHintItem

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

Overview

PreloadHintItem represents an EXT-X-PRELOAD-HINT tag which allows a server to indicate a resource that will be needed soon.

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 = {}) ⇒ PreloadHintItem

Returns a new instance of PreloadHintItem.

Parameters:

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

    attribute key-value pairs



18
19
20
21
22
# File 'lib/m3u8/preload_hint_item.rb', line 18

def initialize(params = {})
  params.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#byterange_lengthString, ...

Returns:

  • (String, nil)

    hint type (PART or MAP)

  • (String, nil)

    hint resource URI

  • (Integer, nil)

    byte range start offset

  • (Integer, nil)

    byte range length



15
16
17
# File 'lib/m3u8/preload_hint_item.rb', line 15

def byterange_length
  @byterange_length
end

#byterange_startString, ...

Returns:

  • (String, nil)

    hint type (PART or MAP)

  • (String, nil)

    hint resource URI

  • (Integer, nil)

    byte range start offset

  • (Integer, nil)

    byte range length



15
16
17
# File 'lib/m3u8/preload_hint_item.rb', line 15

def byterange_start
  @byterange_start
end

#typeString, ...

Returns:

  • (String, nil)

    hint type (PART or MAP)

  • (String, nil)

    hint resource URI

  • (Integer, nil)

    byte range start offset

  • (Integer, nil)

    byte range length



15
16
17
# File 'lib/m3u8/preload_hint_item.rb', line 15

def type
  @type
end

#uriString, ...

Returns:

  • (String, nil)

    hint type (PART or MAP)

  • (String, nil)

    hint resource URI

  • (Integer, nil)

    byte range start offset

  • (Integer, nil)

    byte range length



15
16
17
# File 'lib/m3u8/preload_hint_item.rb', line 15

def uri
  @uri
end

Class Method Details

.parse(text) ⇒ PreloadHintItem

Parse an EXT-X-PRELOAD-HINT tag.

Parameters:

  • text (String)

    raw tag line

Returns:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/m3u8/preload_hint_item.rb', line 27

def self.parse(text)
  attributes = parse_attributes(text)
  PreloadHintItem.new(
    type: attributes['TYPE'],
    uri: attributes['URI'],
    byterange_start:
      parse_int(attributes['BYTERANGE-START']),
    byterange_length:
      parse_int(attributes['BYTERANGE-LENGTH'])
  )
end

Instance Method Details

#to_sString

Render as an m3u8 EXT-X-PRELOAD-HINT tag.

Returns:

  • (String)


41
42
43
# File 'lib/m3u8/preload_hint_item.rb', line 41

def to_s
  "#EXT-X-PRELOAD-HINT:#{formatted_attributes}"
end