Class: SFML::InputStream
- Inherits:
-
Object
- Object
- SFML::InputStream
- Defined in:
- ext/system/input_stream.c,
ext/system/input_stream.c
Overview
Adapts any Ruby object that responds to #read into the stream interface
SFML's loaders expect, so resources can be loaded from something other
than a filesystem path (e.g. an in-memory StringIO, or a custom source).
Instance Method Summary collapse
-
#new(io) ⇒ InputStream
constructor
Wraps a Ruby object that responds to
#read(and ideally +#seek+/+#tell+ or#pos, and#sizeor#length) so it can be passed anywhere the library accepts a stream-based data source. -
#io ⇒ Object
Returns the IO-like object the stream was created from.
Constructor Details
#new(io) ⇒ InputStream
Wraps a Ruby object that responds to #read (and ideally +#seek+/+#tell+
or #pos, and #size or #length) so it can be passed anywhere the
library accepts a stream-based data source.
220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'ext/system/input_stream.c', line 220
static VALUE InputStream_initialize(VALUE self, VALUE rb_io) {
InputStream* stream;
if (!rb_respond_to(rb_io, rb_intern("read"))) {
rb_raise(rb_eArgError, "stream object must respond to #read");
}
TypedData_Get_Struct(self, InputStream, &InputStream_data_type, stream);
stream->rb_io = rb_io;
return self;
}
|
Instance Method Details
#io ⇒ Object
Returns the IO-like object the stream was created from.
240 241 242 |
# File 'ext/system/input_stream.c', line 240
static VALUE InputStream_get_io(VALUE self) {
return ((InputStream*)Get_InputStream_Struct(self))->rb_io;
}
|