]> git.cworth.org Git - notmuch/blobdiff - bindings/ruby/tags.c
ruby: tags: return string array directly
[notmuch] / bindings / ruby / tags.c
index db8b4cfc86f0b3eaa818ce0d7876862158826862..955d790f3bb79e7e0a100aec758fdf9d2b443a8b 100644 (file)
 
 #include "defs.h"
 
+VALUE
+notmuch_rb_tags_get (notmuch_tags_t *tags)
+{
+    VALUE rb_array = rb_ary_new ();
+
+    for (; notmuch_tags_valid (tags); notmuch_tags_move_to_next (tags)) {
+       const char *tag = notmuch_tags_get (tags);
+       rb_ary_push (rb_array, rb_str_new2 (tag));
+    }
+    return rb_array;
+}
+
 /*
  * call-seq: TAGS.destroy! => nil
  *
 VALUE
 notmuch_rb_tags_destroy (VALUE self)
 {
-    notmuch_tags_t *tags;
-
-    Data_Get_Notmuch_Tags (self, tags);
-
-    notmuch_tags_destroy (tags);
-    DATA_PTR (self) = NULL;
+    notmuch_rb_object_destroy (self, &notmuch_rb_tags_type);
 
     return Qnil;
 }