Module: Typhoeus::EasyFu::FFIHelper
- Included in:
- Typhoeus::Easy
- Defined in:
- lib/typhoeus/easy/ffi_helper.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #body_write_callback ⇒ Object
- #double_ptr ⇒ Object
- #handle ⇒ Object
- #header_write_callback ⇒ Object
- #long_ptr ⇒ Object
- #read_callback ⇒ Object
- #string_ptr ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#body_write_callback ⇒ Object
21 22 23 24 25 26 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 21 def body_write_callback @body_write_callback ||= proc {|stream, size, num, object| response_body << stream.read_string(size * num) size * num } end |
#double_ptr ⇒ Object
56 57 58 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 56 def double_ptr @double_ptr ||= ::FFI::MemoryPointer.new(:double) end |
#handle ⇒ Object
17 18 19 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 17 def handle @handle ||= Curl.easy_init end |
#header_write_callback ⇒ Object
28 29 30 31 32 33 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 28 def header_write_callback @header_write_callback ||= proc {|stream, size, num, object| response_header << stream.read_string(size * num) size * num } end |
#long_ptr ⇒ Object
52 53 54 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 52 def long_ptr @long_ptr ||= ::FFI::MemoryPointer.new(:long) end |
#read_callback ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 35 def read_callback @read_callback ||= proc {|stream, size, num, object| size = size * num left = Utils.bytesize(@request_body) - @request_body_read size = left if size > left if size > 0 stream.write_string(Utils.byteslice(@request_body, @request_body_read, size), size) @request_body_read += size end size } end |
#string_ptr ⇒ Object
48 49 50 |
# File 'lib/typhoeus/easy/ffi_helper.rb', line 48 def string_ptr @string_ptr ||= ::FFI::MemoryPointer.new(:pointer) end |