Sha256: 9093c1bfa915bd4b1e508b6866c458cc5f241481af83af952d0b3d1ee3a2ddf6

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
m3u8-0.7.0 lib/m3u8/playback_start.rb