Class: Hurley::Multipart::FilePart
- Inherits:
-
Object
- Object
- Hurley::Multipart::FilePart
- Includes:
- Part
- Defined in:
- lib/hurley/multipart.rb
Overview
Represents a part to be filled from file IO.
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
-
#initialize(boundary, name, io, header) ⇒ FilePart
constructor
A new instance of FilePart.
Methods included from Part
Constructor Details
#initialize(boundary, name, io, header) ⇒ FilePart
120 121 122 123 124 125 126 127 128 |
# File 'lib/hurley/multipart.rb', line 120 def initialize(boundary, name, io, header) file_length = io.respond_to?(:length) ? io.length : File.size(io.local_path) @head = build_head(boundary, name, io.original_filename, io.content_type, file_length, io.respond_to?(:opts) ? io.opts.merge(header) : header) @length = @head.bytesize + file_length + FOOT.length @io = CompositeReadIO.new(@length, StringIO.new(@head), io, StringIO.new(FOOT)) end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
118 119 120 |
# File 'lib/hurley/multipart.rb', line 118 def length @length end |