Class: M3u8::SessionDataItem

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

Overview

SessionDataItem represents a set of EXT-X-SESSION-DATA attributes

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

Returns a new instance of SessionDataItem.

Parameters:

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

    attribute key-value pairs



17
18
19
20
21
# File 'lib/m3u8/session_data_item.rb', line 17

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

Instance Attribute Details

#data_idString?

Returns:

  • (String, nil)

    DATA-ID value

  • (String, nil)

    VALUE attribute

  • (String, nil)

    URI attribute

  • (String, nil)

    LANGUAGE attribute



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

def data_id
  @data_id
end

#languageString?

Returns:

  • (String, nil)

    DATA-ID value

  • (String, nil)

    VALUE attribute

  • (String, nil)

    URI attribute

  • (String, nil)

    LANGUAGE attribute



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

def language
  @language
end

#uriString?

Returns:

  • (String, nil)

    DATA-ID value

  • (String, nil)

    VALUE attribute

  • (String, nil)

    URI attribute

  • (String, nil)

    LANGUAGE attribute



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

def uri
  @uri
end

#valueString?

Returns:

  • (String, nil)

    DATA-ID value

  • (String, nil)

    VALUE attribute

  • (String, nil)

    URI attribute

  • (String, nil)

    LANGUAGE attribute



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

def value
  @value
end

Class Method Details

.parse(text) ⇒ SessionDataItem

Parse an EXT-X-SESSION-DATA tag.

Parameters:

  • text (String)

    raw tag line

Returns:



26
27
28
29
30
31
# File 'lib/m3u8/session_data_item.rb', line 26

def self.parse(text)
  attributes = parse_attributes text
  options = { data_id: attributes['DATA-ID'], value: attributes['VALUE'],
              uri: attributes['URI'], language: attributes['LANGUAGE'] }
  M3u8::SessionDataItem.new options
end

Instance Method Details

#to_sString

Render as an m3u8 EXT-X-SESSION-DATA tag.

Returns:

  • (String)


35
36
37
38
39
40
41
# File 'lib/m3u8/session_data_item.rb', line 35

def to_s
  attributes = [quoted_format('DATA-ID', data_id),
                quoted_format('VALUE', value),
                quoted_format('URI', uri),
                quoted_format('LANGUAGE', language)].compact.join(',')
  "#EXT-X-SESSION-DATA:#{attributes}"
end