Class: Toast::HttpRange
- Inherits:
-
Object
- Object
- Toast::HttpRange
- Defined in:
- lib/toast/http_range.rb
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(range) ⇒ HttpRange
constructor
A new instance of HttpRange.
Constructor Details
#initialize(range) ⇒ HttpRange
Returns a new instance of HttpRange.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/toast/http_range.rb', line 4 def initialize range if range.nil? @start = 0 @end = nil @size = nil else range =~ /\Aitems=(\d*)-(\d*)/ @start = Integer($1) rescue 0 @end = Integer($2) rescue nil @end = nil if (@end and (@end < @start)) @size = @end - @start + 1 rescue nil end end |
Instance Attribute Details
#end ⇒ Object (readonly)
Returns the value of attribute end.
2 3 4 |
# File 'lib/toast/http_range.rb', line 2 def end @end end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
2 3 4 |
# File 'lib/toast/http_range.rb', line 2 def size @size end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
2 3 4 |
# File 'lib/toast/http_range.rb', line 2 def start @start end |