Sha256: fc4bb58676f9053be637898bce936c048e83a44e78cf8c6ab4a713014ad7e56c

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

module M3u8
  # Encapsulates logic common to encryption key tags
  module Encryptable
    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

    def attributes_to_s
      [method_format,
       uri_format,
       iv_format,
       key_format_format,
       key_format_versions_format].compact.join(',')
    end

    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

    def method_format
      "METHOD=#{method}"
    end

    def uri_format
      %(URI="#{uri}") unless uri.nil?
    end

    def iv_format
      "IV=#{iv}" unless iv.nil?
    end

    def key_format_format
      %(KEYFORMAT="#{key_format}") unless key_format.nil?
    end

    def key_format_versions_format
      return if key_format_versions.nil?

      %(KEYFORMATVERSIONS="#{key_format_versions}")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
m3u8-0.7.0 lib/m3u8/encryptable.rb
m3u8-0.6.9 lib/m3u8/encryptable.rb
m3u8-0.6.8 lib/m3u8/encryptable.rb
m3u8-0.6.7 lib/m3u8/encryptable.rb
m3u8-0.6.6 lib/m3u8/encryptable.rb
m3u8-0.6.5 lib/m3u8/encryptable.rb
m3u8-0.6.4 lib/m3u8/encryptable.rb
m3u8-0.6.3 lib/m3u8/encryptable.rb
m3u8-0.6.2 lib/m3u8/encryptable.rb