Class: M3u8::BitrateItem
- Inherits:
-
Object
- Object
- M3u8::BitrateItem
- Includes:
- Serializable
- Defined in:
- lib/m3u8/bitrate_item.rb
Overview
BitrateItem represents an EXT-X-BITRATE tag that indicates the approximate bitrate of the following media segments in kbps.
Instance Attribute Summary collapse
-
#bitrate ⇒ Integer?
Approximate bitrate in kbps.
Class Method Summary collapse
-
.parse(text) ⇒ BitrateItem
Parse an EXT-X-BITRATE tag.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ BitrateItem
constructor
A new instance of BitrateItem.
-
#to_s ⇒ String
Render as an m3u8 EXT-X-BITRATE tag.
Methods included from Serializable
#as_json, serialize, #to_h, #to_json
Constructor Details
#initialize(params = {}) ⇒ BitrateItem
Returns a new instance of BitrateItem.
13 14 15 16 17 |
# File 'lib/m3u8/bitrate_item.rb', line 13 def initialize(params = {}) params.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#bitrate ⇒ Integer?
Returns approximate bitrate in kbps.
10 11 12 |
# File 'lib/m3u8/bitrate_item.rb', line 10 def bitrate @bitrate end |
Class Method Details
.parse(text) ⇒ BitrateItem
Parse an EXT-X-BITRATE tag.
22 23 24 25 |
# File 'lib/m3u8/bitrate_item.rb', line 22 def self.parse(text) value = text.gsub('#EXT-X-BITRATE:', '').strip BitrateItem.new(bitrate: value.to_i) end |
Instance Method Details
#to_s ⇒ String
Render as an m3u8 EXT-X-BITRATE tag.
29 30 31 |
# File 'lib/m3u8/bitrate_item.rb', line 29 def to_s "#EXT-X-BITRATE:#{bitrate}" end |