Class: M3u8::DefineItem
- Inherits:
-
Object
- Object
- M3u8::DefineItem
- Extended by:
- M3u8
- Includes:
- Serializable
- Defined in:
- lib/m3u8/define_item.rb
Overview
DefineItem represents an EXT-X-DEFINE tag which provides variable definitions for variable substitution. Supports three mutually exclusive modes: NAME/VALUE, IMPORT, or QUERYPARAM.
Constant Summary
Constants included from M3u8
Instance Attribute Summary collapse
Class Method Summary collapse
-
.parse(text) ⇒ DefineItem
Parse an EXT-X-DEFINE tag.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ DefineItem
constructor
A new instance of DefineItem.
-
#to_s ⇒ String
Render as an m3u8 EXT-X-DEFINE tag.
Methods included from M3u8
initialize_with_byterange, parse_attributes, parse_float, parse_int, parse_yes_no, to_yes_no
Methods included from Serializable
#as_json, serialize, #to_h, #to_json
Constructor Details
#initialize(params = {}) ⇒ DefineItem
Returns a new instance of DefineItem.
18 19 20 21 22 |
# File 'lib/m3u8/define_item.rb', line 18 def initialize(params = {}) params.each do |key, val| instance_variable_set("@#{key}", val) end end |
Instance Attribute Details
#import ⇒ String?
15 16 17 |
# File 'lib/m3u8/define_item.rb', line 15 def import @import end |
#name ⇒ String?
15 16 17 |
# File 'lib/m3u8/define_item.rb', line 15 def name @name end |
#queryparam ⇒ String?
15 16 17 |
# File 'lib/m3u8/define_item.rb', line 15 def queryparam @queryparam end |
#value ⇒ String?
15 16 17 |
# File 'lib/m3u8/define_item.rb', line 15 def value @value end |
Class Method Details
.parse(text) ⇒ DefineItem
Parse an EXT-X-DEFINE tag.
27 28 29 30 31 32 33 34 35 |
# File 'lib/m3u8/define_item.rb', line 27 def self.parse(text) attributes = parse_attributes(text) DefineItem.new( name: attributes['NAME'], value: attributes['VALUE'], import: attributes['IMPORT'], queryparam: attributes['QUERYPARAM'] ) end |
Instance Method Details
#to_s ⇒ String
Render as an m3u8 EXT-X-DEFINE tag.
39 40 41 |
# File 'lib/m3u8/define_item.rb', line 39 def to_s "#EXT-X-DEFINE:#{formatted_attributes}" end |