Class: Typhoeus::Form
- Inherits:
-
Object
- Object
- Typhoeus::Form
- Defined in:
- lib/typhoeus/form.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#params ⇒ Object
Returns the value of attribute params.
-
#traversal ⇒ Object
readonly
Returns the value of attribute traversal.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Form
constructor
A new instance of Form.
- #multipart? ⇒ Boolean
- #process! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Form
Returns a new instance of Form.
8 9 10 11 12 13 14 |
# File 'lib/typhoeus/form.rb', line 8 def initialize(params = {}) @params = params @first = ::FFI::MemoryPointer.new(:pointer) @last = ::FFI::MemoryPointer.new(:pointer) ObjectSpace.define_finalizer(self, self.class.finalizer(self)) end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
6 7 8 |
# File 'lib/typhoeus/form.rb', line 6 def first @first end |
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/typhoeus/form.rb', line 5 def params @params end |
#traversal ⇒ Object (readonly)
Returns the value of attribute traversal.
6 7 8 |
# File 'lib/typhoeus/form.rb', line 6 def traversal @traversal end |
Class Method Details
.finalizer(form) ⇒ Object
16 17 18 |
# File 'lib/typhoeus/form.rb', line 16 def self.finalizer(form) proc { Curl.formfree(form.first) } end |
Instance Method Details
#multipart? ⇒ Boolean
53 54 55 |
# File 'lib/typhoeus/form.rb', line 53 def multipart? !traversal[:files].empty? end |
#process! ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/typhoeus/form.rb', line 45 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_s ⇒ Object
57 58 59 |
# File 'lib/typhoeus/form.rb', line 57 def to_s Typhoeus::Utils.traversal_to_param_string(traversal, false) end |