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
- #unescape(string) ⇒ Object
Constructor Details
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
5 6 7 |
# File 'lib/curl_ffi/easy.rb', line 5 def pointer @pointer end |
Instance Method Details
#error_string(error_code) ⇒ Object
34 35 36 |
# File 'lib/curl_ffi/easy.rb', line 34 def error_string(error_code) CurlFFI.easy_strerror(error_code) end |
#escape(string) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/curl_ffi/easy.rb', line 19 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
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/curl_ffi/easy.rb', line 46 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
15 16 17 |
# File 'lib/curl_ffi/easy.rb', line 15 def initialize_copy(other) @pointer = FFI::AutoPointer.new(CurlFFI.easy_duphandle(other.pointer), CurlFFI.method(:easy_cleanup)) end |
#perform ⇒ Object
38 39 40 |
# File 'lib/curl_ffi/easy.rb', line 38 def perform check_code(CurlFFI.easy_perform(@pointer)) end |
#reset ⇒ Object
11 12 13 |
# File 'lib/curl_ffi/easy.rb', line 11 def reset CurlFFI.easy_reset(@pointer) end |
#setopt(option, value) ⇒ Object
42 43 44 |
# File 'lib/curl_ffi/easy.rb', line 42 def setopt(option, value) check_code(CurlFFI.easy_setopt(@pointer, option, value)) end |
#unescape(string) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/curl_ffi/easy.rb', line 26 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 |