Class: CurlFFI::Easy
- Inherits:
-
Object
- Object
- CurlFFI::Easy
- Defined in:
- lib/curl_ffi/easy.rb
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
Instance Method Summary collapse
- #error_string(error_code) ⇒ Object
- #escape(string) ⇒ Object
- #getinfo(info) ⇒ Object
-
#initialize ⇒ Easy
constructor
A new instance of Easy.
- #initialize_copy(other) ⇒ Object
- #perform ⇒ Object
- #reset ⇒ Object
- #setopt(option, value) ⇒ Object
- #setopt_handler(option, value) ⇒ Object
- #setopt_str_handler(option, value) ⇒ Object
- #unescape(string) ⇒ Object
Constructor Details
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
6 7 8 |
# File 'lib/curl_ffi/easy.rb', line 6 def pointer @pointer end |
Instance Method Details
#error_string(error_code) ⇒ Object
35 36 37 |
# File 'lib/curl_ffi/easy.rb', line 35 def error_string(error_code) CurlFFI.easy_strerror(error_code) end |
#escape(string) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/curl_ffi/easy.rb', line 20 def escape(string) str_pointer = CurlFFI.easy_escape(@pointer, string, string.length) result = str_pointer.null? ? nil : str_pointer.read_string CurlFFI.free(str_pointer) result end |
#getinfo(info) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/curl_ffi/easy.rb', line 55 def getinfo(info) info = INFO[info] if info.is_a?(Symbol) if info > CurlFFI::INFO_SLIST raise "Not implemented yet" elsif info > CurlFFI::INFO_DOUBLE getinfo_double(info) elsif info > CurlFFI::INFO_LONG getinfo_long(info) elsif info > CurlFFI::INFO_STRING getinfo_string(info) end end |
#initialize_copy(other) ⇒ Object
16 17 18 |
# File 'lib/curl_ffi/easy.rb', line 16 def initialize_copy(other) @pointer = FFI::AutoPointer.new(CurlFFI.easy_duphandle(other.pointer), CurlFFI.method(:easy_cleanup)) end |
#perform ⇒ Object
39 40 41 |
# File 'lib/curl_ffi/easy.rb', line 39 def perform check_code(CurlFFI.easy_perform(@pointer)) end |
#reset ⇒ Object
12 13 14 |
# File 'lib/curl_ffi/easy.rb', line 12 def reset CurlFFI.easy_reset(@pointer) end |
#setopt(option, value) ⇒ Object
43 44 45 |
# File 'lib/curl_ffi/easy.rb', line 43 def setopt(option, value) check_code(CurlFFI.easy_setopt(@pointer, option, value)) end |
#setopt_handler(option, value) ⇒ Object
47 48 49 |
# File 'lib/curl_ffi/easy.rb', line 47 def setopt_handler(option, value) check_code(CurlFFI.easy_setopt_handler(@pointer, option, value)) end |
#setopt_str_handler(option, value) ⇒ Object
51 52 53 |
# File 'lib/curl_ffi/easy.rb', line 51 def setopt_str_handler(option, value) check_code(CurlFFI.easy_setopt_handler_string(@pointer, option, value)) end |
#unescape(string) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/curl_ffi/easy.rb', line 27 def unescape(string) int_pointer = FFI::MemoryPointer.new(:int) str_pointer = CurlFFI.easy_unescape(@pointer, string, string.length, int_pointer) result = str_pointer.read_string(int_pointer.read_int) CurlFFI.free(str_pointer) result end |