Sha256: 9b29e4d36d1957b857676bfc73a5dda8a71e266a66b588ab4807fbfd8d808b1e

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

module M3u8
  class PlaylistItem
    attr_accessor :program_id, :width, :height, :codecs, :bitrate, :playlist

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

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

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

    private

    def resolution_format
      return if resolution.nil?
      "RESOLUTION=#{resolution},"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
m3u8-0.2.0 lib/m3u8/playlist_item.rb