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.



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

#attributesObject (readonly)

Returns the value of attribute attributes.



128
129
130
# File 'lib/flickr/uploader.rb', line 128

def attributes
  @attributes
end

#dataObject (readonly)

Returns the value of attribute data.



128
129
130
# File 'lib/flickr/uploader.rb', line 128

def data
  @data
end

#filenameObject (readonly)

Returns the value of attribute filename.



128
129
130
# File 'lib/flickr/uploader.rb', line 128

def filename
  @filename
end

#mime_typeObject (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_sObject



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