Class: M3u8::MediaItem
- Inherits:
-
Object
- Object
- M3u8::MediaItem
- 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
Instance Attribute Summary collapse
-
#assoc_language ⇒ Object
Returns the value of attribute assoc_language.
-
#autoselect ⇒ Object
Returns the value of attribute autoselect.
-
#default ⇒ Object
Returns the value of attribute default.
-
#forced ⇒ Object
Returns the value of attribute forced.
-
#group_id ⇒ Object
Returns the value of attribute group_id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ MediaItem
constructor
A new instance of MediaItem.
- #to_s ⇒ Object
Methods included from M3u8
intialize_with_byterange, parse_attributes, parse_yes_no
Constructor Details
#initialize(params = {}) ⇒ MediaItem
Returns a new instance of MediaItem.
8 9 10 11 12 |
# File 'lib/m3u8/media_item.rb', line 8 def initialize(params = {}) params.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#assoc_language ⇒ Object
Returns the value of attribute assoc_language.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def assoc_language @assoc_language end |
#autoselect ⇒ Object
Returns the value of attribute autoselect.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def autoselect @autoselect end |
#default ⇒ Object
Returns the value of attribute default.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def default @default end |
#forced ⇒ Object
Returns the value of attribute forced.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def forced @forced end |
#group_id ⇒ Object
Returns the value of attribute group_id.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def group_id @group_id end |
#language ⇒ Object
Returns the value of attribute language.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def language @language end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def type @type end |
#uri ⇒ Object
Returns the value of attribute uri.
5 6 7 |
# File 'lib/m3u8/media_item.rb', line 5 def uri @uri end |
Class Method Details
.parse(text) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/m3u8/media_item.rb', line 14 def self.parse(text) attributes = parse_attributes text = { 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'] } MediaItem.new end |
Instance Method Details
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/m3u8/media_item.rb', line 27 def to_s attributes = [type_format, group_id_format, language_format, assoc_language_format, name_format, autoselect_format, default_format, uri_format, forced_format].compact.join(',') "#EXT-X-MEDIA:#{attributes}" end |