Class: Caper::ErrorBuffer
- Inherits:
-
FFI::MemoryPointer
- Object
- FFI::MemoryPointer
- Caper::ErrorBuffer
- Defined in:
- lib/caper/error_buffer.rb
Constant Summary collapse
- SIZE =
Size of the error buffers
256
Class Method Summary collapse
-
.create ⇒ Object
Creates a new ErrorBuffer object.
Instance Method Summary collapse
-
#initialize(arg = nil) ⇒ ErrorBuffer
constructor
Creates a new ErrorBuffer object.
-
#size ⇒ Object
Older JRuby/ffi versions of MemoryPointer and Buffer don’t have a size method.
-
#to_s ⇒ Object
Returns the error message within the error buffer.
Constructor Details
#initialize(arg = nil) ⇒ ErrorBuffer
Creates a new ErrorBuffer object. The argument is nil and is only present for compatability with JRuby.
21 22 23 |
# File 'lib/caper/error_buffer.rb', line 21 def initialize(arg=nil) super(SIZE) end |
Class Method Details
.create ⇒ Object
Creates a new ErrorBuffer object. Because of wierdness in JRuby
when trying to subclass FFI::Buffer, always use this instead of
'new()'
See http://github.com/ffi/ffi/issues#issue/27
12 13 14 |
# File 'lib/caper/error_buffer.rb', line 12 def self.create() new(SIZE) end |
Instance Method Details
#size ⇒ Object
Older JRuby/ffi versions of MemoryPointer and Buffer don’t have a size method. We override it here to ensure we can use it.
34 35 36 37 38 39 40 |
# File 'lib/caper/error_buffer.rb', line 34 def size begin super() rescue NoMethodError SIZE end end |
#to_s ⇒ Object
Returns the error message within the error buffer.
28 29 30 |
# File 'lib/caper/error_buffer.rb', line 28 def to_s get_string(0) end |