Class: CurlFFI::Easy
- Inherits:
-
Object
- Object
- CurlFFI::Easy
- Defined in:
- lib/curl_ffi/easy.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#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
- #reset_options ⇒ Object
- #setopt(option, value) ⇒ Object
- #unescape(string) ⇒ Object
Constructor Details
#initialize ⇒ Easy
Returns a new instance of Easy.
8 9 10 11 |
# File 'lib/curl_ffi/easy.rb', line 8 def initialize @pointer = FFI::AutoPointer.new(CurlFFI.easy_init, CurlFFI.method(:easy_cleanup)) = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/curl_ffi/easy.rb', line 6 def end |
#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
41 42 43 |
# File 'lib/curl_ffi/easy.rb', line 41 def error_string(error_code) CurlFFI.easy_strerror(error_code) end |
#escape(_string) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/curl_ffi/easy.rb', line 26 def escape(_string) str_pointer = CurlFFI.easy_escape(@pointer, _string, _string.length) @escaped = str_pointer.null? ? nil : str_pointer.read_string.dup CurlFFI.free(str_pointer) return(@escaped) end |
#getinfo(info) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/curl_ffi/easy.rb', line 58 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
22 23 24 |
# File 'lib/curl_ffi/easy.rb', line 22 def initialize_copy(other) @pointer = FFI::AutoPointer.new(CurlFFI.easy_duphandle(other.pointer), CurlFFI.method(:easy_cleanup)) end |
#perform ⇒ Object
45 46 47 |
# File 'lib/curl_ffi/easy.rb', line 45 def perform check_code(@_code = CurlFFI.easy_perform(@pointer)) end |
#reset ⇒ Object
17 18 19 20 |
# File 'lib/curl_ffi/easy.rb', line 17 def reset CurlFFI.easy_reset(@pointer) = {} end |
#reset_options ⇒ Object
13 14 15 |
# File 'lib/curl_ffi/easy.rb', line 13 def = {} end |
#setopt(option, value) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/curl_ffi/easy.rb', line 49 def setopt(option, value) @_option = option @_value = value check_code(@_code = CurlFFI.easy_setopt(@pointer, @_option, @_value)) [@_option] = @_value end |
#unescape(string) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/curl_ffi/easy.rb', line 33 def unescape(string) int_pointer = FFI::MemoryPointer.new(:int) str_pointer = CurlFFI.easy_unescape(@pointer, string, string.length, int_pointer) @unescaped = str_pointer.read_string(int_pointer.read_int).dup CurlFFI.free(str_pointer) @unescaped end |