Class: Flickr::Uploader::FormPart
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
Instance Method Summary collapse
-
#initialize(name, data, mime_type = nil, filename = nil) ⇒ FormPart
constructor
A new instance of FormPart.
- #to_s ⇒ Object
Constructor Details
#initialize(name, data, mime_type = nil, filename = nil) ⇒ FormPart
Returns a new instance of FormPart.
130 131 132 133 134 135 136 137 |
# File 'lib/flickr/uploader.rb', line 130 def initialize(name, data, mime_type = nil, filename = nil) @attributes = {} @attributes['name'] = name @attributes['filename'] = filename if filename @data = data @mime_type = mime_type @filename = filename end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
128 129 130 |
# File 'lib/flickr/uploader.rb', line 128 def attributes @attributes end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
128 129 130 |
# File 'lib/flickr/uploader.rb', line 128 def data @data end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
128 129 130 |
# File 'lib/flickr/uploader.rb', line 128 def filename @filename end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
128 129 130 |
# File 'lib/flickr/uploader.rb', line 128 def mime_type @mime_type end |
Instance Method Details
#to_s ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/flickr/uploader.rb', line 139 def to_s ([ "Content-Disposition: form-data" ] + attributes.map{|k,v| "#{k}=\"#{v}\""}). join('; ') + "\r\n"+ (@mime_type ? "Content-Type: #{@mime_type}\r\n" : '')+ "\r\n#{data}" end |