Class: M3u8::PlaybackStart

Inherits:
Object
  • Object
show all
Extended by:
M3u8
Includes:
AttributeFormatter, Serializable
Defined in:
lib/m3u8/playback_start.rb

Overview

PlaybackStart represents a #EXT-X-START tag and attributes

Constant Summary

Constants included from M3u8

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from M3u8

initialize_with_byterange, parse_attributes, parse_float, parse_int, parse_yes_no, to_yes_no

Methods included from AttributeFormatter

#boolean_format, #decimal_format, #quoted_format, #unquoted_format

Methods included from Serializable

#as_json, serialize, #to_h, #to_json

Constructor Details

#initialize(options = {}) ⇒ PlaybackStart

Returns a new instance of PlaybackStart.

Parameters:

  • options (Hash) (defaults to: {})

    attribute key-value pairs



15
16
17
18
19
# File 'lib/m3u8/playback_start.rb', line 15

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

Instance Attribute Details

#preciseFloat, ...

Returns:

  • (Float, nil)

    time offset in seconds

  • (Boolean, nil)

    whether start is precise



12
13
14
# File 'lib/m3u8/playback_start.rb', line 12

def precise
  @precise
end

#time_offsetFloat, ...

Returns:

  • (Float, nil)

    time offset in seconds

  • (Boolean, nil)

    whether start is precise



12
13
14
# File 'lib/m3u8/playback_start.rb', line 12

def time_offset
  @time_offset
end

Class Method Details

.parse(text) ⇒ PlaybackStart

Parse an EXT-X-START tag.

Parameters:

  • text (String)

    raw tag line

Returns:



24
25
26
27
28
29
30
31
32
# File 'lib/m3u8/playback_start.rb', line 24

def self.parse(text)
  attributes = parse_attributes(text)
  precise = attributes['PRECISE']
  options = {
    time_offset: attributes['TIME-OFFSET'].to_f,
    precise: precise.nil? ? nil : parse_yes_no(precise)
  }
  PlaybackStart.new(options)
end

Instance Method Details

#to_sString

Render as an m3u8 EXT-X-START tag.

Returns:

  • (String)


36
37
38
39
40
# File 'lib/m3u8/playback_start.rb', line 36

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