Class: HLSKey

Inherits:
Object
  • Object
show all
Includes:
HLSConstants
Defined in:
lib/hls_manifest.rb

Constant Summary

Constants included from HLSConstants

HLSConstants::EXTINF, HLSConstants::EXTM3U, HLSConstants::EXT_X_ALLOW_CACHE, HLSConstants::EXT_X_CUE_IN, HLSConstants::EXT_X_CUE_OUT, HLSConstants::EXT_X_DISCONTINUITY, HLSConstants::EXT_X_ENDLIST, HLSConstants::EXT_X_FAXS_CM, HLSConstants::EXT_X_KEY, HLSConstants::EXT_X_KEY_ATTRS, HLSConstants::EXT_X_MEDIA, HLSConstants::EXT_X_MEDIA_SEQUENCE, HLSConstants::EXT_X_PLAYLIST_TYPE, HLSConstants::EXT_X_STREAM_INF, HLSConstants::EXT_X_STREAM_INF_ATTRS, HLSConstants::EXT_X_TARGETDURATION, HLSConstants::EXT_X_VERSION, HLSConstants::FIXNUM_MAX, HLSConstants::SUPPORTED_M3U8_VERSIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method = "NONE", uri = nil, iv = nil) ⇒ HLSKey

Returns a new instance of HLSKey.



91
92
93
94
95
# File 'lib/hls_manifest.rb', line 91

def initialize(method = "NONE", uri = nil, iv = nil)
  @method = method
  @uri = uri
  @iv = iv
end

Instance Attribute Details

#ivObject

Returns the value of attribute iv.



89
90
91
# File 'lib/hls_manifest.rb', line 89

def iv
  @iv
end

#methodObject

Returns the value of attribute method.



87
88
89
# File 'lib/hls_manifest.rb', line 87

def method
  @method
end

#uriObject

Returns the value of attribute uri.



88
89
90
# File 'lib/hls_manifest.rb', line 88

def uri
  @uri
end

Instance Method Details

#buildObject



97
98
99
100
101
102
103
104
105
106
# File 'lib/hls_manifest.rb', line 97

def build
  attributes = []
  attributes.push("#{EXT_X_KEY_ATTRS[:METHOD]}=#{@method}") if @method
  attributes.push("#{EXT_X_KEY_ATTRS[:URI]}=\"#{@uri}\"") if @uri
  attributes.push("#{EXT_X_KEY_ATTRS[:IV]}=0x#{@iv.to_s(16)}") if @iv

  "    \#{EXT_X_KEY + \":\" + attributes.join(\",\") unless attributes.empty?}\n  EOT\nend\n".remove_extra_spaces