Class: M3u8::SessionDataItem

Inherits:
Object
  • Object
show all
Extended by:
M3u8
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

intialize_with_byterange, parse_attributes, parse_float, parse_yes_no, to_yes_no

Constructor Details

#initialize(params = {}) ⇒ SessionDataItem

Returns a new instance of SessionDataItem.



8
9
10
11
12
# File 'lib/m3u8/session_data_item.rb', line 8

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

Instance Attribute Details

#data_idObject

Returns the value of attribute data_id.



6
7
8
# File 'lib/m3u8/session_data_item.rb', line 6

def data_id
  @data_id
end

#languageObject

Returns the value of attribute language.



6
7
8
# File 'lib/m3u8/session_data_item.rb', line 6

def language
  @language
end

#uriObject

Returns the value of attribute uri.



6
7
8
# File 'lib/m3u8/session_data_item.rb', line 6

def uri
  @uri
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/m3u8/session_data_item.rb', line 6

def value
  @value
end

Class Method Details

.parse(text) ⇒ Object



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

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_sObject



21
22
23
24
25
26
27
# File 'lib/m3u8/session_data_item.rb', line 21

def to_s
  attributes = [data_id_format,
                value_format,
                uri_format,
                language_format].compact.join(',')
  "#EXT-X-SESSION-DATA:#{attributes}"
end