summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2021-09-27 18:17:47 -0500
committer<[email protected]>2021-09-27 18:17:47 -0500
commit2cf101436202c72278926a9d2593f9c26b8e83ce ()
treed60a66f88ad8243a60874a44cdc0cf3534456dba /struct.c
parent1147136b8a2fd40b2c2a60c00aa47ad514dd934e (diff)
Enhanced RDoc for Struct (#4895)
Revises introductory material. Adds section "What's Here". Adds previously missing documentation for method #deconstruct_keys.
Notes: Merged-By: BurdetteLamar <[email protected]>
-rw-r--r--struct.c129
1 files changed, 111 insertions, 18 deletions
@@ -1076,6 +1076,23 @@ rb_struct_to_h(VALUE s)
return h;
}
static VALUE
rb_struct_deconstruct_keys(VALUE s, VALUE keys)
{
@@ -1544,29 +1561,105 @@ rb_struct_dig(int argc, VALUE *argv, VALUE self)
/*
* Document-class: Struct
*
- * A Struct is a convenient way to bundle a number of attributes together,
- * using accessor methods, without having to write an explicit class.
*
- * The Struct class generates new subclasses that hold a set of members and
- * their values. For each member a reader and writer method is created
- * similar to Module#attr_accessor.
*
- * Customer = Struct.new(:name, :address) do
- * def greeting
- * "Hello #{name}!"
- * end
- * end
*
- * dave = Customer.new("Dave", "123 Main")
- * dave.name #=> "Dave"
- * dave.greeting #=> "Hello Dave!"
*
- * See Struct::new for further examples of creating struct subclasses and
- * instances.
*
- * In the method descriptions that follow, a "member" parameter refers to a
- * struct member which is either a quoted string (<code>"name"</code>) or a
- * Symbol (<code>:name</code>).
*/
void
InitVM_Struct(void)