Class: M3u8::SegmentItem
- Inherits:
-
Object
- Object
- M3u8::SegmentItem
- Includes:
- M3u8, AttributeFormatter, Serializable
- Defined in:
- lib/m3u8/segment_item.rb
Overview
SegmentItem represents EXTINF attributes with the URI that follows, optionally allowing an EXT-X-BYTERANGE tag to be set.
Constant Summary
Constants included from M3u8
Instance Attribute Summary collapse
- #byterange ⇒ Float, ...
- #comment ⇒ Float, ...
- #duration ⇒ Float, ...
- #program_date_time ⇒ Float, ...
- #segment ⇒ Float, ...
Class Method Summary collapse
-
.parse(text) ⇒ SegmentItem
Parse an EXTINF tag line.
Instance Method Summary collapse
- #date_format ⇒ Object
-
#initialize(params = {}) ⇒ SegmentItem
constructor
A new instance of SegmentItem.
-
#to_s ⇒ String
Render as an m3u8 EXTINF tag with segment URI.
Methods included from Serializable
#as_json, serialize, #to_h, #to_json
Methods included from AttributeFormatter
#boolean_format, #decimal_format, #quoted_format, #unquoted_format
Methods included from M3u8
#initialize_with_byterange, #parse_attributes, #parse_float, #parse_int, #parse_yes_no, #to_yes_no
Constructor Details
#initialize(params = {}) ⇒ SegmentItem
Returns a new instance of SegmentItem.
19 20 21 |
# File 'lib/m3u8/segment_item.rb', line 19 def initialize(params = {}) initialize_with_byterange(params) end |
Instance Attribute Details
#byterange ⇒ Float, ...
16 17 18 |
# File 'lib/m3u8/segment_item.rb', line 16 def byterange @byterange end |
#comment ⇒ Float, ...
16 17 18 |
# File 'lib/m3u8/segment_item.rb', line 16 def comment @comment end |
#duration ⇒ Float, ...
16 17 18 |
# File 'lib/m3u8/segment_item.rb', line 16 def duration @duration end |
#program_date_time ⇒ Float, ...
16 17 18 |
# File 'lib/m3u8/segment_item.rb', line 16 def program_date_time @program_date_time end |
#segment ⇒ Float, ...
16 17 18 |
# File 'lib/m3u8/segment_item.rb', line 16 def segment @segment end |
Class Method Details
.parse(text) ⇒ SegmentItem
Parse an EXTINF tag line.
26 27 28 29 30 31 32 |
# File 'lib/m3u8/segment_item.rb', line 26 def self.parse(text) values = text.gsub('#EXTINF:', '') .tr("\n", ',').split(',') = { duration: values[0].to_f } [:comment] = values[1] unless values[1].nil? SegmentItem.new() end |
Instance Method Details
#date_format ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/m3u8/segment_item.rb', line 41 def date_format return if program_date_time.nil? pdt = if program_date_time.is_a?(TimeItem) program_date_time else TimeItem.new(time: program_date_time) end "#{pdt}\n" end |
#to_s ⇒ String
Render as an m3u8 EXTINF tag with segment URI.
36 37 38 39 |
# File 'lib/m3u8/segment_item.rb', line 36 def to_s "#EXTINF:#{decimal_format(duration)},#{comment}#{byterange_format}" \ "\n#{date_format}#{segment}" end |