From 10e7f389e26f3903e89d8d67aa5d8522c7da460a Mon Sep 17 00:00:00 2001 From: zzak Date: Sun, 25 May 2014 00:43:14 +0000 Subject: * class.c: [DOC] Fixed grammar and examples of instance_methods. By @alex-frost via documenting-ruby/ruby#31 [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ class.c | 34 +++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65bc83e2c4..cb1ae7650b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun May 25 09:41:56 2014 Zachary Scott + + * class.c: [DOC] Fixed grammar and examples of instance_methods. + By @alex-frost via documenting-ruby/ruby#31 + Sun May 25 09:40:44 2014 Tanaka Akira * test/lib/minitest/unit.rb: Show leakes threads and tempfiles. diff --git a/class.c b/class.c index 02a9e62dfd..be59e68829 100644 --- a/class.c +++ b/class.c @@ -1181,25 +1181,25 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int obj, int (*func * * Returns an array containing the names of the public and protected instance * methods in the receiver. For a module, these are the public and protected methods; - * for a class, they are the instance (not singleton) methods. With no - * argument, or with an argument that is false, the - * instance methods in mod are returned, otherwise the methods - * in mod and mod's superclasses are returned. + * for a class, they are the instance (not singleton) methods. If the optional + * parameter is false, the methods of any ancestors are not included. * * module A * def method1() end * end * class B + * include A * def method2() end * end * class C < B * def method3() end * end * - * A.instance_methods #=> [:method1] - * B.instance_methods(false) #=> [:method2] - * C.instance_methods(false) #=> [:method3] - * C.instance_methods(true).length #=> 43 + * A.instance_methods(false) #=> [:method1] + * B.instance_methods(false) #=> [:method2] + * B.instance_methods(true).include?(:method1) #=> true + * C.instance_methods(false) #=> [:method3] + * C.instance_methods.include?(:method2) #=> true */ VALUE @@ -1213,8 +1213,8 @@ rb_class_instance_methods(int argc, VALUE *argv, VALUE mod) * mod.protected_instance_methods(include_super=true) -> array * * Returns a list of the protected instance methods defined in - * mod. If the optional parameter is not false, the - * methods of any ancestors are included. + * mod. If the optional parameter is false, the + * methods of any ancestors are not included. */ VALUE @@ -1228,8 +1228,8 @@ rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod) * mod.private_instance_methods(include_super=true) -> array * * Returns a list of the private instance methods defined in - * mod. If the optional parameter is not false, the - * methods of any ancestors are included. + * mod. If the optional parameter is false, the + * methods of any ancestors are not included. * * module Mod * def method1() end @@ -1251,8 +1251,8 @@ rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod) * mod.public_instance_methods(include_super=true) -> array * * Returns a list of the public instance methods defined in mod. - * If the optional parameter is not false, the methods of - * any ancestors are included. + * If the optional parameter is false, the methods of + * any ancestors are not included. */ VALUE @@ -1268,8 +1268,8 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod) * Returns a list of the names of public and protected methods of * obj. This will include all the methods accessible in * obj's ancestors. - * If the regular parameter is set to false, - * Returns an array of obj's public and protected singleton methods, + * If the optional parameter is false, it + * returns an array of obj's public and protected singleton methods, * the array will not include methods in modules included in obj. * * class Klass @@ -1280,7 +1280,7 @@ rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod) * k.methods[0..9] #=> [:klass_method, :nil?, :===, * # :==~, :!, :eql? * # :hash, :<=>, :class, :singleton_class] - * k.methods.length #=> 57 + * k.methods.length #=> 56 * * k.methods(false) #=> [] * def k.singleton_method; end -- cgit v1.2.3