Class: MultipartParser::Reader::Part
- Inherits:
-
Object
- Object
- MultipartParser::Reader::Part
- Defined in:
- lib/multipart_parser/reader.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#mime ⇒ Object
Returns the value of attribute mime.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#emit_data(data) ⇒ Object
Calls the data callback with the given data.
-
#emit_end ⇒ Object
Calls the end callback.
-
#initialize ⇒ Part
constructor
A new instance of Part.
-
#on_data(&callback) ⇒ Object
Sets a block to be called when part data is read.
-
#on_end(&callback) ⇒ Object
Sets a block to be called when all data for the part has been read.
Constructor Details
#initialize ⇒ Part
Returns a new instance of Part.
69 70 71 72 73 |
# File 'lib/multipart_parser/reader.rb', line 69 def initialize @headers = {} @data_callback = nil @end_callback = nil end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
67 68 69 |
# File 'lib/multipart_parser/reader.rb', line 67 def filename @filename end |
#headers ⇒ Object
Returns the value of attribute headers.
67 68 69 |
# File 'lib/multipart_parser/reader.rb', line 67 def headers @headers end |
#mime ⇒ Object
Returns the value of attribute mime.
67 68 69 |
# File 'lib/multipart_parser/reader.rb', line 67 def mime @mime end |
#name ⇒ Object
Returns the value of attribute name.
67 68 69 |
# File 'lib/multipart_parser/reader.rb', line 67 def name @name end |
Instance Method Details
#emit_data(data) ⇒ Object
Calls the data callback with the given data
76 77 78 |
# File 'lib/multipart_parser/reader.rb', line 76 def emit_data(data) @data_callback.call(data) unless @data_callback.nil? end |
#emit_end ⇒ Object
Calls the end callback
81 82 83 |
# File 'lib/multipart_parser/reader.rb', line 81 def emit_end @end_callback.call unless @end_callback.nil? end |
#on_data(&callback) ⇒ Object
Sets a block to be called when part data is read. The block should take one parameter, namely the read data.
88 89 90 |
# File 'lib/multipart_parser/reader.rb', line 88 def on_data(&callback) @data_callback = callback end |
#on_end(&callback) ⇒ Object
Sets a block to be called when all data for the part has been read.
94 95 96 |
# File 'lib/multipart_parser/reader.rb', line 94 def on_end(&callback) @end_callback = callback end |