Class: M3u8::TimeItem

Inherits:
Object
  • Object
show all
Extended by:
M3u8
Defined in:
lib/m3u8/time_item.rb

Overview

TimeItem represents EXT-X-PROGRAM-DATE-TIME

Constant Summary

Constants included from M3u8

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from M3u8

intialize_with_byterange, parse_attributes, parse_float, parse_yes_no, to_yes_no

Constructor Details

#initialize(params = {}) ⇒ TimeItem

Returns a new instance of TimeItem.



8
9
10
11
12
# File 'lib/m3u8/time_item.rb', line 8

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

Instance Attribute Details

#timeObject

Returns the value of attribute time.



6
7
8
# File 'lib/m3u8/time_item.rb', line 6

def time
  @time
end

Class Method Details

.parse(text) ⇒ Object



14
15
16
17
18
# File 'lib/m3u8/time_item.rb', line 14

def self.parse(text)
  time = text.gsub('#EXT-X-PROGRAM-DATE-TIME:', '')
  options = { time: Time.parse(time) }
  TimeItem.new(options)
end

Instance Method Details

#to_sObject



20
21
22
# File 'lib/m3u8/time_item.rb', line 20

def to_s
  %(#EXT-X-PROGRAM-DATE-TIME:#{time_format})
end