Class: Flickr::Uploader::FormPart

Inherits:
Object
  • Object
show all
Defined in:
lib/flickr/uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, data, mime_type = nil, filename = nil) ⇒ FormPart

Returns a new instance of FormPart.



96
97
98
99
100
101
102
# File 'lib/flickr/uploader.rb', line 96

def initialize(name, data, mime_type = nil, filename = nil)
	@attributes = {}
	@attributes['name'] = name
	@data = data
	@mime_type = mime_type
	@filename = filename
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



94
95
96
# File 'lib/flickr/uploader.rb', line 94

def attributes
  @attributes
end

#dataObject (readonly)

Returns the value of attribute data.



94
95
96
# File 'lib/flickr/uploader.rb', line 94

def data
  @data
end

#filenameObject (readonly)

Returns the value of attribute filename.



94
95
96
# File 'lib/flickr/uploader.rb', line 94

def filename
  @filename
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



94
95
96
# File 'lib/flickr/uploader.rb', line 94

def mime_type
  @mime_type
end

Instance Method Details

#to_sObject



104
105
106
107
108
109
110
# File 'lib/flickr/uploader.rb', line 104

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