Class: Multipart::MultipartPost

Inherits:
Object
  • Object
show all
Defined in:
lib/tinder/multipart.rb

Overview

:nodoc:

Constant Summary collapse

BOUNDARY =
'campfire-is-awesome'
HEADER =
{"Content-type" => "multipart/form-data, boundary=" + BOUNDARY + " "}
TIMEOUT_SECONDS =
30

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ MultipartPost

Returns a new instance of MultipartPost.



50
51
52
53
54
# File 'lib/tinder/multipart.rb', line 50

def initialize(params)
  @params = params
  @query = {}
  self.prepare_query
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



49
50
51
# File 'lib/tinder/multipart.rb', line 49

def headers
  @headers
end

#paramsObject

Returns the value of attribute params.



49
50
51
# File 'lib/tinder/multipart.rb', line 49

def params
  @params
end

#queryObject

Returns the value of attribute query.



49
50
51
# File 'lib/tinder/multipart.rb', line 49

def query
  @query
end

Instance Method Details

#prepare_queryObject



56
57
58
59
60
61
# File 'lib/tinder/multipart.rb', line 56

def prepare_query()
  @query = @params.map do |k,v|
    param = v.respond_to?(:read) ? FileParam.new(k, v.path, v.read) : Param.new(k, v)
    "--#{BOUNDARY}\r\n#{param.to_multipart}"
  end.join("") + "--#{BOUNDARY}--"
end