summaryrefslogtreecommitdiff
path: root/ext/io/console/console.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-25 18:24:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-25 18:24:09 +0000
commit8335ce7065be10565e0c1fb8971df2b43d9d4d95 (patch)
treea0a9a8ab282bf416e8a4e8cff9bb1c125407f159 /ext/io/console/console.c
parent97f0b0f55818420b4c7a7002c92c08ad78a7e579 (diff)
* ext/io/console/console.c (io_getch): default delegating method
for StringIO. https://github.com/nobu/io-console/issues/4 * ext/stringio/stringio.c: moved some methods to hidden modules. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/io/console/console.c')
-rw-r--r--ext/io/console/console.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 5b6705d45b4..228ac80fef5 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -718,6 +718,12 @@ console_dev(VALUE klass)
return con;
}
+static VALUE
+io_getch(int argc, VALUE *argv, VALUE io)
+{
+ return rb_funcall2(io, rb_intern("getc"), argc, argv);
+}
+
/*
* IO console methods
*/
@@ -746,4 +752,8 @@ InitVM_console(void)
rb_define_method(rb_cIO, "oflush", console_oflush, 0);
rb_define_method(rb_cIO, "ioflush", console_ioflush, 0);
rb_define_singleton_method(rb_cIO, "console", console_dev, 0);
+ {
+ VALUE mReadable = rb_define_module_under(rb_cIO, "readable");
+ rb_define_method(mReadable, "getch", io_getch, -1);
+ }
}