Class: RbSDL2::RWFile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RWOps

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

Constructor Details

#initialize(path, mode = "r") ⇒ RWFile

Returns a new instance of RWFile.

Raises:



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

def initialize(path, mode = "r")
  @path = path
  ptr = ::SDL.RWFromFile(SDL.str_to_sdl(path), SDL.str_to_sdl(mode))
  raise RbSDL2Error if ptr.null?
  super(RWOpsPointer.new(ptr))
end

Instance Attribute Details

#pathObject (readonly) Also known as: to_path

Returns the value of attribute path.



16
17
18
# File 'lib/rb_sdl2/rw_ops/rw_file.rb', line 16

def path
  @path
end

Instance Method Details

#inspectObject



12
13
14
# File 'lib/rb_sdl2/rw_ops/rw_file.rb', line 12

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