Sha256: d07c67742119a3c81d5931868b449082465fd1f143278c7e956aebd0325f5db2

Contents?: true

Size: 784 Bytes

Versions: 3

Compression:

Stored size: 784 Bytes

Contents

# frozen_string_literal: true
module M3u8
  # MapItem represents a EXT-X-MAP tag which specifies how to obtain the Media
  # Initialization Section
  class MapItem
    extend M3u8
    include M3u8
    attr_accessor :uri, :byterange

    def initialize(params = {})
      intialize_with_byterange(params)
    end

    def self.parse(text)
      attributes = parse_attributes(text)
      range_value = attributes['BYTERANGE']
      range = ByteRange.parse(range_value) unless range_value.nil?
      options = { uri: attributes['URI'], byterange: range }
      MapItem.new(options)
    end

    def to_s
      %(#EXT-X-MAP:URI="#{uri}"#{byterange_format})
    end

    private

    def byterange_format
      return if byterange.nil?
      %(,BYTERANGE="#{byterange}")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
m3u8-0.8.2 lib/m3u8/map_item.rb
m3u8-0.8.1 lib/m3u8/map_item.rb
m3u8-0.8.0 lib/m3u8/map_item.rb