Class: M3u8::PlaylistItem

Inherits:
Object
  • Object
show all
Defined in:
lib/m3u8/playlist_item.rb

Constant Summary collapse

MISSING_CODEC_MESSAGE =
'Audio or video codec info should be provided.'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ PlaylistItem

Returns a new instance of PlaylistItem.



7
8
9
10
11
# File 'lib/m3u8/playlist_item.rb', line 7

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

Instance Attribute Details

#audioObject

Returns the value of attribute audio.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def audio
  @audio
end

#bitrateObject

Returns the value of attribute bitrate.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def bitrate
  @bitrate
end

#codecsObject

Returns the value of attribute codecs.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def codecs
  @codecs
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def height
  @height
end

#levelObject

Returns the value of attribute level.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def level
  @level
end

#playlistObject

Returns the value of attribute playlist.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def playlist
  @playlist
end

#profileObject

Returns the value of attribute profile.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def profile
  @profile
end

#program_idObject

Returns the value of attribute program_id.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def program_id
  @program_id
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/m3u8/playlist_item.rb', line 3

def width
  @width
end

Instance Method Details

#resolutionObject



13
14
15
16
# File 'lib/m3u8/playlist_item.rb', line 13

def resolution
  return if width.nil?
  "#{width}x#{height}"
end

#to_sObject



35
36
37
38
39
# File 'lib/m3u8/playlist_item.rb', line 35

def to_s
  validate
  "#EXT-X-STREAM-INF:PROGRAM-ID=#{program_id},#{resolution_format}" +
    %(CODECS="#{codecs}",BANDWIDTH=#{bitrate}\n#{playlist})
end