Class: M3u8::PartItem

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

Overview

PartItem represents an EXT-X-PART tag for Low-Latency HLS partial segments.

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

Returns a new instance of PartItem.

Parameters:

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

    attribute key-value pairs



20
21
22
# File 'lib/m3u8/part_item.rb', line 20

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

Instance Attribute Details

#byterangeString, ...

Returns:

  • (String, nil)

    partial segment URI

  • (Float, nil)

    partial segment duration

  • (Boolean, nil)

    whether segment is independent

  • (ByteRange, nil)

    byte range

  • (Boolean, nil)

    whether segment is a gap



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

def byterange
  @byterange
end

#durationString, ...

Returns:

  • (String, nil)

    partial segment URI

  • (Float, nil)

    partial segment duration

  • (Boolean, nil)

    whether segment is independent

  • (ByteRange, nil)

    byte range

  • (Boolean, nil)

    whether segment is a gap



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

def duration
  @duration
end

#gapString, ...

Returns:

  • (String, nil)

    partial segment URI

  • (Float, nil)

    partial segment duration

  • (Boolean, nil)

    whether segment is independent

  • (ByteRange, nil)

    byte range

  • (Boolean, nil)

    whether segment is a gap



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

def gap
  @gap
end

#independentString, ...

Returns:

  • (String, nil)

    partial segment URI

  • (Float, nil)

    partial segment duration

  • (Boolean, nil)

    whether segment is independent

  • (ByteRange, nil)

    byte range

  • (Boolean, nil)

    whether segment is a gap



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

def independent
  @independent
end

#uriString, ...

Returns:

  • (String, nil)

    partial segment URI

  • (Float, nil)

    partial segment duration

  • (Boolean, nil)

    whether segment is independent

  • (ByteRange, nil)

    byte range

  • (Boolean, nil)

    whether segment is a gap



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

def uri
  @uri
end

Class Method Details

.parse(text) ⇒ PartItem

Parse an EXT-X-PART tag.

Parameters:

  • text (String)

    raw tag line

Returns:



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

def self.parse(text)
  attributes = parse_attributes(text)
  range_value = attributes['BYTERANGE']
  range = ByteRange.parse(range_value) unless range_value.nil?
  PartItem.new(
    uri: attributes['URI'],
    duration: attributes['DURATION'].to_f,
    independent: parse_yes_no(attributes['INDEPENDENT']),
    byterange: range,
    gap: parse_yes_no(attributes['GAP'])
  )
end

Instance Method Details

#to_sString

Render as an m3u8 EXT-X-PART tag.

Returns:

  • (String)


42
43
44
# File 'lib/m3u8/part_item.rb', line 42

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