Class: IntervalResponse::Full

Inherits:
Abstract
  • Object
show all
Defined in:
lib/interval_response/full.rb

Overview

Serves out a response that contains the entire resource

Instance Method Summary collapse

Methods inherited from Abstract

#etag, #to_rack_response_triplet

Constructor Details

#initializeFull

Returns a new instance of Full.



3
4
5
6
# File 'lib/interval_response/full.rb', line 3

def initialize(*)
  super
  @http_range_for_entire_resource = 0..(@interval_sequence.size - 1)
end

Instance Method Details

#content_lengthObject



18
19
20
# File 'lib/interval_response/full.rb', line 18

def content_length
  @interval_sequence.size
end

#eachObject



8
9
10
11
12
# File 'lib/interval_response/full.rb', line 8

def each
  @interval_sequence.each_in_range(@http_range_for_entire_resource) do |segment, range_in_segment|
    yield(segment, range_in_segment)
  end
end

#headersObject



30
31
32
33
34
35
36
37
# File 'lib/interval_response/full.rb', line 30

def headers
  {
    'Accept-Ranges' => 'bytes',
    'Content-Length' => @interval_sequence.size.to_s,
    'Content-Type' => 'binary/octet-stream',
    'ETag' => etag,
  }
end

#multiple_ranges?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/interval_response/full.rb', line 26

def multiple_ranges?
  false
end

#satisfied_with_first_interval?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/interval_response/full.rb', line 22

def satisfied_with_first_interval?
  @interval_sequence.first_interval_only?(@http_range_for_entire_resource)
end

#status_codeObject



14
15
16
# File 'lib/interval_response/full.rb', line 14

def status_code
  200
end