Class: Flickr::FormPart

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FormPart.



29
30
31
32
33
34
# File 'lib/flickr/upload.rb', line 29

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



27
28
29
# File 'lib/flickr/upload.rb', line 27

def attributes
  @attributes
end

#dataObject (readonly)

Returns the value of attribute data.



27
28
29
# File 'lib/flickr/upload.rb', line 27

def data
  @data
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



27
28
29
# File 'lib/flickr/upload.rb', line 27

def mime_type
  @mime_type
end

Instance Method Details

#to_sObject



36
37
38
39
40
41
42
# File 'lib/flickr/upload.rb', line 36

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