ruby-changes:70498
From: zverok <ko1@a...>
Date: Fri, 24 Dec 2021 10:29:45 +0900 (JST)
Subject: [ruby-changes:70498] fed1629ada (master): Fix StructClass:: class method docs
https://git.ruby-lang.org/ruby.git/commit/?id=fed1629ada From fed1629adab07f99b00316cb3ce3ae1ab17f99b5 Mon Sep 17 00:00:00 2001 From: zverok <zverok.offline@g...> Date: Wed, 15 Dec 2021 23:59:33 +0200 Subject: Fix StructClass:: class method docs --- struct.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/struct.c b/struct.c index d1a7d1db8c7..fc9cbc78cc1 100644 --- a/struct.c +++ b/struct.c @@ -187,6 +187,17 @@ struct_member_pos(VALUE s, VALUE name) https://github.com/ruby/ruby/blob/trunk/struct.c#L187 } } +/* + * call-seq: + * StructClass::members -> array_of_symbols + * + * Returns the member names of the Struct decendant as an array: + * + * Customer = Struct.new(:name, :address, :zip) + * Customer.members # => [:name, :address, :zip] + * + */ + static VALUE rb_struct_s_members_m(VALUE klass) { @@ -285,12 +296,14 @@ rb_struct_s_inspect(VALUE klass) https://github.com/ruby/ruby/blob/trunk/struct.c#L296 return inspect; } +#if 0 /* for RDoc */ + /* * call-seq: - * StructClass.keyword_init? -> true or false + * StructClass::keyword_init? -> true or falsy value * - * Returns true if the class was initialized with +keyword_init: true+. - * Otherwise returns false. + * Returns +true+ if the class was initialized with <tt>keyword_init: true</tt>. + * Otherwise returns +nil+ or +false+. * * Examples: * Foo = Struct.new(:a) @@ -300,6 +313,11 @@ rb_struct_s_inspect(VALUE klass) https://github.com/ruby/ruby/blob/trunk/struct.c#L313 * Baz = Struct.new(:a, keyword_init: false) * Baz.keyword_init? # => false */ +static VALUE +rb_struct_s_keyword_init_p(VALUE obj) +{ +} +#endif #define rb_struct_s_keyword_init_p rb_struct_s_keyword_init @@ -1601,6 +1619,10 @@ InitVM_Struct(void) https://github.com/ruby/ruby/blob/trunk/struct.c#L1619 rb_undef_alloc_func(rb_cStruct); rb_define_singleton_method(rb_cStruct, "new", rb_struct_s_def, -1); +#if 0 /* for RDoc */ + rb_define_singleton_method(rb_cStruct, "keyword_init?", rb_struct_s_keyword_init_p, 0); + rb_define_singleton_method(rb_cStruct, "members", rb_struct_s_members_m, 0); +#endif rb_define_method(rb_cStruct, "initialize", rb_struct_initialize_m, -1); rb_define_method(rb_cStruct, "initialize_copy", rb_struct_init_copy, 1); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/