Method: Struct#to_h
- Defined in:
- struct.c
#to_h ⇒ Hash
686 687 688 689 690 691 692 693 694 695 696 697 |
# File 'struct.c', line 686
static VALUE
rb_struct_to_h(VALUE s)
{
VALUE h = rb_hash_new();
VALUE members = rb_struct_members(s);
long i;
for (i=0; i<RSTRUCT_LEN(s); i++) {
rb_hash_aset(h, rb_ary_entry(members, i), RSTRUCT_GET(s, i));
}
return h;
}
|