Class: RbSDL2::RWMemory

Inherits:
RWOps
  • Object
show all
Defined in:
lib/rb_sdl2/rw_ops/rw_memory.rb

Instance Method Summary collapse

Methods inherited from RWOps

#close, #closed?, open, #pos=, #read, #seek, #size, #tell, #to_ptr, #write

Constructor Details

#initialize(obj, readonly: false, size: nil) ⇒ RWMemory

Returns a new instance of RWMemory.

Raises:

  • (TypeError)


5
6
7
8
9
10
11
12
# File 'lib/rb_sdl2/rw_ops/rw_memory.rb', line 5

def initialize(obj, readonly: false, size: nil)
  raise TypeError, "obj is NULL" if obj.nil? || obj.null?
  size = size || obj.size
  ptr = readonly ? ::SDL.RWFromConstMem(obj, size) : ::SDL.RWFromMem(obj, size)
  raise RbSDL2Error if ptr.null?
  super(RWOpsPointer.new(ptr))
  @obj = obj
end

Instance Method Details

#inspectObject



14
15
16
# File 'lib/rb_sdl2/rw_ops/rw_memory.rb', line 14

def inspect
  "#<#{self.class.name}:memory#{closed? ? " (closed)" : nil}>"
end