Sha256: d033d4960e55106cb69eb6334cafe6a331af39e76a85030aaead14c1737ddde2

Contents?: true

Size: 752 Bytes

Versions: 10

Compression:

Stored size: 752 Bytes

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
m3u8-0.7.0 lib/m3u8/map_item.rb
m3u8-0.6.9 lib/m3u8/map_item.rb
m3u8-0.6.8 lib/m3u8/map_item.rb
m3u8-0.6.7 lib/m3u8/map_item.rb
m3u8-0.6.6 lib/m3u8/map_item.rb
m3u8-0.6.5 lib/m3u8/map_item.rb
m3u8-0.6.4 lib/m3u8/map_item.rb
m3u8-0.6.3 lib/m3u8/map_item.rb
m3u8-0.6.2 lib/m3u8/map_item.rb
m3u8-0.6.1 lib/m3u8/map_item.rb