Class: M3u8::ByteRange
- Inherits:
-
Object
- Object
- M3u8::ByteRange
- Defined in:
- lib/m3u8/byte_range.rb
Overview
ByteRange represents sub range of a resource
Instance Attribute Summary collapse
-
#length ⇒ Object
Returns the value of attribute length.
-
#start ⇒ Object
Returns the value of attribute start.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ ByteRange
constructor
A new instance of ByteRange.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ ByteRange
6 7 8 9 10 |
# File 'lib/m3u8/byte_range.rb', line 6 def initialize(params = {}) params.each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#length ⇒ Object
Returns the value of attribute length.
4 5 6 |
# File 'lib/m3u8/byte_range.rb', line 4 def length @length end |
#start ⇒ Object
Returns the value of attribute start.
4 5 6 |
# File 'lib/m3u8/byte_range.rb', line 4 def start @start end |
Class Method Details
.parse(text) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/m3u8/byte_range.rb', line 12 def self.parse(text) values = text.split '@' length_value = values[0].to_i start_value = values[1].to_i unless values[1].nil? = { length: length_value, start: start_value } ByteRange.new end |
Instance Method Details
#to_s ⇒ Object
20 21 22 |
# File 'lib/m3u8/byte_range.rb', line 20 def to_s "#{length}#{start_format}" end |