aboutsummaryrefslogtreecommitdiffhomepage
path: root/bindings/ruby
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2012-11-24 23:57:07 -0500
committerGravatar David Bremner <bremner@debian.org>2013-02-18 20:23:40 -0400
commitc4f96d09312532d378c51b2a0e0128108fba4a2c (patch)
tree864cad35e705f7bb9d9bced61ed2c9425d71a23d /bindings/ruby
parentf29bcc59df128e7ca37ed324846ebb760ee13be8 (diff)
ruby: Add bindings for notmuch_thread_get_messages
Diffstat (limited to 'bindings/ruby')
-rw-r--r--bindings/ruby/defs.h3
-rw-r--r--bindings/ruby/init.c1
-rw-r--r--bindings/ruby/thread.c20
3 files changed, 24 insertions, 0 deletions
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index fe81b3f9..5b44585a 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -262,6 +262,9 @@ VALUE
notmuch_rb_thread_get_toplevel_messages (VALUE self);
VALUE
+notmuch_rb_thread_get_messages (VALUE self);
+
+VALUE
notmuch_rb_thread_get_matched_messages (VALUE self);
VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index f4931d34..663271d4 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -306,6 +306,7 @@ Init_notmuch (void)
rb_define_method (notmuch_rb_cThread, "thread_id", notmuch_rb_thread_get_thread_id, 0); /* in thread.c */
rb_define_method (notmuch_rb_cThread, "total_messages", notmuch_rb_thread_get_total_messages, 0); /* in thread.c */
rb_define_method (notmuch_rb_cThread, "toplevel_messages", notmuch_rb_thread_get_toplevel_messages, 0); /* in thread.c */
+ rb_define_method (notmuch_rb_cThread, "messages", notmuch_rb_thread_get_messages, 0); /* in thread.c */
rb_define_method (notmuch_rb_cThread, "matched_messages", notmuch_rb_thread_get_matched_messages, 0); /* in thread.c */
rb_define_method (notmuch_rb_cThread, "authors", notmuch_rb_thread_get_authors, 0); /* in thread.c */
rb_define_method (notmuch_rb_cThread, "subject", notmuch_rb_thread_get_subject, 0); /* in thread.c */
diff --git a/bindings/ruby/thread.c b/bindings/ruby/thread.c
index efe5aaf7..56616d9f 100644
--- a/bindings/ruby/thread.c
+++ b/bindings/ruby/thread.c
@@ -92,6 +92,26 @@ notmuch_rb_thread_get_toplevel_messages (VALUE self)
}
/*
+ * call-seq: THREAD.messages => MESSAGES
+ *
+ * Get a Notmuch::Messages iterator for the all messages in thread.
+ */
+VALUE
+notmuch_rb_thread_get_messages (VALUE self)
+{
+ notmuch_messages_t *messages;
+ notmuch_thread_t *thread;
+
+ Data_Get_Notmuch_Thread (self, thread);
+
+ messages = notmuch_thread_get_messages (thread);
+ if (!messages)
+ rb_raise (notmuch_rb_eMemoryError, "Out of memory");
+
+ return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
+}
+
+/*
* call-seq: THREAD.matched_messages => fixnum
*
* Get the number of messages in thread that matched the search