Class: Toast::HttpRange

Inherits:
Object
  • Object
show all
Defined in:
lib/toast/http_range.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#endObject (readonly)

Returns the value of attribute end.



2
3
4
# File 'lib/toast/http_range.rb', line 2

def end
  @end
end

#sizeObject (readonly)

Returns the value of attribute size.



2
3
4
# File 'lib/toast/http_range.rb', line 2

def size
  @size
end

#startObject (readonly)

Returns the value of attribute start.



2
3
4
# File 'lib/toast/http_range.rb', line 2

def start
  @start
end