Class: RbSDL2::RWObject::WriteCallback
- Inherits:
-
FFI::Function
- Object
- FFI::Function
- RbSDL2::RWObject::WriteCallback
- Defined in:
- lib/rb_sdl2/rw_ops/rw_object.rb
Instance Method Summary collapse
-
#initialize ⇒ WriteCallback
constructor
A new instance of WriteCallback.
Constructor Details
#initialize ⇒ WriteCallback
Returns a new instance of WriteCallback.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rb_sdl2/rw_ops/rw_object.rb', line 71 def initialize # size_t (* write) (struct RWops * context, const void *ptr, size_t size, size_t num); super(:size_t, [:pointer, :pointer, :size_t, :size_t]) do |_context, ptr, size, max_num| str = ptr.read_bytes(size * max_num) yield(str) / size rescue => e raise e if $DEBUG Error. = e. 0 end end |