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.



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

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.



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

def attributes
  @attributes
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



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

def mime_type
  @mime_type
end

Instance Method Details

#to_sObject



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

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