Sha256: e37ccd677e6c8f707a6e85bec10d43042f994fb884484672d352870d441c99b2

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true
module M3u8
  # PlaybackStart represents a #EXT-X-START tag and attributes
  class PlaybackStart
    include M3u8
    attr_accessor :time_offset, :precise

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

    def parse(text)
      attributes = parse_attributes(text)
      @time_offset = attributes['TIME-OFFSET'].to_f
      precise = attributes['PRECISE']
      @precise = parse_yes_no(precise) unless precise.nil?
    end

    def to_s
      attributes = ["TIME-OFFSET=#{time_offset}",
                    precise_format].compact.join(',')
      "#EXT-X-START:#{attributes}"
    end

    private

    def precise_format
      return if precise.nil?
      "PRECISE=#{to_yes_no(precise)}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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