Class: Telegem::API::MultipartForm
- Inherits:
-
Object
- Object
- Telegem::API::MultipartForm
- Defined in:
- lib/api/client.rb
Constant Summary collapse
- CRLF =
"\r\n"
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
- #add(name, value) ⇒ Object
- #body ⇒ Object
-
#initialize ⇒ MultipartForm
constructor
A new instance of MultipartForm.
Constructor Details
#initialize ⇒ MultipartForm
Returns a new instance of MultipartForm.
15 16 17 18 19 |
# File 'lib/api/client.rb', line 15 def initialize @boundary = "----telegem#{SecureRandom.hex(16)}" @content_type = "multipart/form-data; boundary=#{@boundary}" @parts = [] end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
13 14 15 |
# File 'lib/api/client.rb', line 13 def content_type @content_type end |
Instance Method Details
#add(name, value) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/api/client.rb', line 21 def add(name, value) if file?(value) append_file(name, value) else append_field(name, value.to_s) end end |