Sha256: b5522fe6a3b9bfacbd36051d8b0128fb1d7005c4b5143ec1df50a1ab6a3ab468

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

class M3Uzi
  class Tag < Item

    attr_reader :name
    attr_accessor :value

    VALID_TAGS = %w{PLAYLIST-TYPE ALLOW-CACHE}

    # Unsupported tags: MEDIA-SEQUENCE, I-FRAMES-ONLY, PLAYLIST-TYPE
    # Autogenerated tags: EXTM3U, VERSION, ENDLIST, BYTERANGE, TARGETDURATION

    def name=(n)
      @name = n.to_s.upcase.gsub("_", "-")
    end

    def format
      string << "#EXT-X-#{name}"
      string << ":#{value}" if value
      string
    end

    def valid?
      case name
      when 'PLAYLIST-TYPE'
        ['EVENT','VOD'].include?(value)
      when 'ALLOW-CACHE'
        ['YES','NO'].include?(value)
      else
        true
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
m3uzi-0.4.3 lib/m3uzi/tag.rb
m3uzi-0.4.2 lib/m3uzi/tag.rb