Class: Rack::Multipart::Parser::Collector
- Inherits:
-
Object
- Object
- Rack::Multipart::Parser::Collector
show all
- Includes:
- Enumerable
- Defined in:
- lib/rack/multipart/parser.rb
Defined Under Namespace
Classes: BufferPart, MimePart, TempfilePart
Instance Method Summary
collapse
Constructor Details
#initialize(tempfile) ⇒ Collector
Returns a new instance of Collector.
157
158
159
160
161
|
# File 'lib/rack/multipart/parser.rb', line 157
def initialize(tempfile)
@tempfile = tempfile
@mime_parts = []
@open_files = 0
end
|
Instance Method Details
#each ⇒ Object
163
164
165
|
# File 'lib/rack/multipart/parser.rb', line 163
def each
@mime_parts.each { |part| yield part }
end
|
#on_mime_body(mime_index, content) ⇒ Object
183
184
185
|
# File 'lib/rack/multipart/parser.rb', line 183
def on_mime_body(mime_index, content)
@mime_parts[mime_index].body << content
end
|
#on_mime_finish(mime_index) ⇒ Object
187
188
|
# File 'lib/rack/multipart/parser.rb', line 187
def on_mime_finish(mime_index)
end
|
#on_mime_head(mime_index, head, filename, content_type, name) ⇒ Object
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/rack/multipart/parser.rb', line 167
def on_mime_head(mime_index, head, filename, content_type, name)
if filename
body = @tempfile.call(filename, content_type)
body.binmode if body.respond_to?(:binmode)
klass = TempfilePart
@open_files += 1
else
body = String.new
klass = BufferPart
end
@mime_parts[mime_index] = klass.new(body, head, filename, content_type, name)
check_part_limits
end
|