Class: M3u8::MediaItem

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

Overview

MediaItem represents a set of EXT-X-MEDIA attributes

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

Constructor Details

#initialize(params = {}) ⇒ MediaItem

Returns a new instance of MediaItem.



10
11
12
13
14
# File 'lib/m3u8/media_item.rb', line 10

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

Instance Attribute Details

#assoc_languageObject

Returns the value of attribute assoc_language.



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

def assoc_language
  @assoc_language
end

#autoselectObject

Returns the value of attribute autoselect.



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

def autoselect
  @autoselect
end

#channelsObject

Returns the value of attribute channels.



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

def channels
  @channels
end

#characteristicsObject

Returns the value of attribute characteristics.



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

def characteristics
  @characteristics
end

#defaultObject

Returns the value of attribute default.



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

def default
  @default
end

#forcedObject

Returns the value of attribute forced.



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

def forced
  @forced
end

#group_idObject

Returns the value of attribute group_id.



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

def group_id
  @group_id
end

#instream_idObject

Returns the value of attribute instream_id.



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

def instream_id
  @instream_id
end

#languageObject

Returns the value of attribute language.



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

def language
  @language
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#uriObject

Returns the value of attribute uri.



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

def uri
  @uri
end

Class Method Details

.parse(text) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/m3u8/media_item.rb', line 16

def self.parse(text)
  attributes = parse_attributes(text)
  options = { type: attributes['TYPE'], group_id: attributes['GROUP-ID'],
              language: attributes['LANGUAGE'],
              assoc_language: attributes['ASSOC-LANGUAGE'],
              name: attributes['NAME'],
              autoselect: parse_yes_no(attributes['AUTOSELECT']),
              default: parse_yes_no(attributes['DEFAULT']),
              forced: parse_yes_no(attributes['FORCED']),
              uri: attributes['URI'],
              instream_id: attributes['INSTREAM-ID'],
              characteristics: attributes['CHARACTERISTICS'],
              channels: attributes['CHANNELS'] }
  MediaItem.new(options)
end

Instance Method Details

#to_sObject



32
33
34
# File 'lib/m3u8/media_item.rb', line 32

def to_s
  "#EXT-X-MEDIA:#{formatted_attributes.join(',')}"
end