module M3u8::Encryptable

Encapsulates logic common to encryption key tags

Public Class Methods

included(base) click to toggle source
# File lib/m3u8/encryptable.rb, line 5
def self.included(base)
  base.send :attr_accessor, :method
  base.send :attr_accessor, :uri
  base.send :attr_accessor, :iv
  base.send :attr_accessor, :key_format
  base.send :attr_accessor, :key_format_versions
end

Public Instance Methods

attributes_to_s() click to toggle source
# File lib/m3u8/encryptable.rb, line 13
def attributes_to_s
  [method_format,
   uri_format,
   iv_format,
   key_format_format,
   key_format_versions_format].compact.join(',')
end
convert_key_names(attributes) click to toggle source
# File lib/m3u8/encryptable.rb, line 21
def convert_key_names(attributes)
  { method: attributes['METHOD'], uri: attributes['URI'],
    iv: attributes['IV'], key_format: attributes['KEYFORMAT'],
    key_format_versions: attributes['KEYFORMATVERSIONS'] }
end

Private Instance Methods

iv_format() click to toggle source
# File lib/m3u8/encryptable.rb, line 37
def iv_format
  "IV=#{iv}" unless iv.nil?
end
key_format_format() click to toggle source
# File lib/m3u8/encryptable.rb, line 41
def key_format_format
  %(KEYFORMAT="#{key_format}") unless key_format.nil?
end
key_format_versions_format() click to toggle source
# File lib/m3u8/encryptable.rb, line 45
def key_format_versions_format
  return if key_format_versions.nil?

  %(KEYFORMATVERSIONS="#{key_format_versions}")
end
method_format() click to toggle source
# File lib/m3u8/encryptable.rb, line 29
def method_format
  "METHOD=#{method}"
end
uri_format() click to toggle source
# File lib/m3u8/encryptable.rb, line 33
def uri_format
  %(URI="#{uri}") unless uri.nil?
end