Class: HTTP::FormData::Part
- Inherits:
-
Object
- Object
- HTTP::FormData::Part
- Defined in:
- lib/http/form_data/part.rb
Overview
Represents a body part of multipart/form-data request.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#initialize(body, opts = {}) ⇒ Part
constructor
A new instance of Part.
-
#size ⇒ Integer
Returns content size.
-
#to_s ⇒ String
Returns content of a file of IO.
Constructor Details
#initialize(body, opts = {}) ⇒ Part
Returns a new instance of Part.
18 19 20 21 22 |
# File 'lib/http/form_data/part.rb', line 18 def initialize(body, opts = {}) @body = body.to_s @content_type = opts[:content_type] @filename = opts[:filename] end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
12 13 14 |
# File 'lib/http/form_data/part.rb', line 12 def content_type @content_type end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
12 13 14 |
# File 'lib/http/form_data/part.rb', line 12 def filename @filename end |
Instance Method Details
#size ⇒ Integer
Returns content size.
27 28 29 |
# File 'lib/http/form_data/part.rb', line 27 def size @body.bytesize end |
#to_s ⇒ String
Returns content of a file of IO.
34 35 36 |
# File 'lib/http/form_data/part.rb', line 34 def to_s @body end |