Sha256: 5a73757af762482452acdb6e32c13b35b13e25165c45c70b87d6f86cbc38cddf
Contents?: true
Size: 1.14 KB
Versions: 4
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true module M3u8 # SessionDataItem represents a set of EXT-X-SESSION-DATA attributes class SessionDataItem extend M3u8 attr_accessor :data_id, :value, :uri, :language def initialize(params = {}) params.each do |key, value| instance_variable_set("@#{key}", value) end end 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 def to_s attributes = [data_id_format, value_format, uri_format, language_format].compact.join(',') "#EXT-X-SESSION-DATA:#{attributes}" end private def data_id_format %(DATA-ID="#{data_id}") end def value_format return if value.nil? %(VALUE="#{value}") end def uri_format return if uri.nil? %(URI="#{uri}") end def language_format return if language.nil? %(LANGUAGE="#{language}") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
m3u8-0.8.2 | lib/m3u8/session_data_item.rb |
m3u8-0.8.1 | lib/m3u8/session_data_item.rb |
m3u8-0.8.0 | lib/m3u8/session_data_item.rb |
m3u8-0.7.1 | lib/m3u8/session_data_item.rb |