Sha256: eec16082429c9f23548fe988e71cc7304b7627c568f778e4bf52140a0a12125f

Contents?: true

Size: 664 Bytes

Versions: 4

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true
module M3u8
  # SegmentItem represents EXTINF attributes with the URI that follows,
  # optionally allowing an EXT-X-BYTERANGE tag to be set.
  class SegmentItem
    include M3u8
    attr_accessor :duration, :segment, :comment, :program_date_time, :byterange

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

    def to_s
      date = "#{program_date_time}\n" unless program_date_time.nil?
      "#EXTINF:#{duration},#{comment}#{byterange_format}\n#{date}#{segment}"
    end

    private

    def byterange_format
      return if byterange.nil?
      "\n#EXT-X-BYTERANGE:#{byterange}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
m3u8-0.8.2 lib/m3u8/segment_item.rb
m3u8-0.8.1 lib/m3u8/segment_item.rb
m3u8-0.8.0 lib/m3u8/segment_item.rb
m3u8-0.7.1 lib/m3u8/segment_item.rb