X-Git-Url: http://git.code-monkey.de/?p=ruby-vorbistagger.git;a=blobdiff_plain;f=ext%2Fcomments.c;h=f7919dbdac1e20219a8a45dd70d79a1361aa5f95;hp=cdaf576ae7e697571297a7b2a573525a8edf1e02;hb=0ce138263f8bea54e13953167bb1c82794506d02;hpb=397b4a686511cb3fb5fb9a7a82277487f750c86d diff --git a/ext/comments.c b/ext/comments.c index cdaf576..f7919db 100644 --- a/ext/comments.c +++ b/ext/comments.c @@ -357,6 +357,20 @@ c_merge (VALUE self, VALUE hash) return self; } +/* + * call-seq: + * object.shift(hash) -> array or nil + * + * Removes the first key-value pair from *object* and returns it + * as the two-item array [key, value]. + * If *object* is empty, +nil+ is returned. + */ +static VALUE +c_shift (VALUE self) +{ + return rb_ary_shift (rb_iv_get (self, "items")); +} + /* * call-seq: * object <=> other -> -1, 0 or 1 @@ -490,6 +504,7 @@ Init_Comments (VALUE mVorbis) rb_define_method (c, "keys", c_keys, 0); rb_define_method (c, "values", c_values, 0); rb_define_method (c, "merge!", c_merge, 1); + rb_define_method (c, "shift", c_shift, 0); rb_include_module (c, rb_mComparable); rb_define_method (c, "<=>", c_compare, 1);