Class: Typhoeus::Form

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoeus/form.rb,
ext/typhoeus/typhoeus_form.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Form

Returns a new instance of Form.



8
9
10
# File 'lib/typhoeus/form.rb', line 8

def initialize(params = {})
  @params = params
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/typhoeus/form.rb', line 5

def params
  @params
end

#traversalObject (readonly)

Returns the value of attribute traversal.



6
7
8
# File 'lib/typhoeus/form.rb', line 6

def traversal
  @traversal
end

Instance Method Details

#multipart?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/typhoeus/form.rb', line 24

def multipart?
  !traversal[:files].empty?
end

#process!Object



16
17
18
19
20
21
22
# File 'lib/typhoeus/form.rb', line 16

def process!
  # add params
  traversal[:params].each { |p| formadd_param(p[0], p[1]) }

  # add files
  traversal[:files].each { |file_args| formadd_file(*file_args) }
end

#to_sObject



28
29
30
# File 'lib/typhoeus/form.rb', line 28

def to_s
  Typhoeus::Utils.traversal_to_param_string(traversal, false)
end