diff options
author | Wael M. Nasreddine <wael.nasreddine@gmail.com> | 2014-05-10 14:40:11 -0700 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-05-18 06:39:58 +0900 |
commit | 0629afeb2668ce2f60e8efe65cdab868a1e1b257 (patch) | |
tree | 39c75c983cc81bd8f0694d6d4ea34fa596fc1c6e /bindings | |
parent | c67587f003db32a60aca93fc12f7e82204ee55f6 (diff) |
ruby: Add wrapper for notmuch_query_count_threads
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/ruby/defs.h | 3 | ||||
-rw-r--r-- | bindings/ruby/init.c | 1 | ||||
-rw-r--r-- | bindings/ruby/query.c | 19 |
3 files changed, 23 insertions, 0 deletions
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 5b44585a..f4901a04 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -231,6 +231,9 @@ notmuch_rb_query_search_messages (VALUE self); VALUE notmuch_rb_query_count_messages (VALUE self); +VALUE +notmuch_rb_query_count_threads (VALUE self); + /* threads.c */ VALUE notmuch_rb_threads_destroy (VALUE self); diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index 663271d4..ab3f22df 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -271,6 +271,7 @@ Init_notmuch (void) rb_define_method (notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "count_messages", notmuch_rb_query_count_messages, 0); /* in query.c */ + rb_define_method (notmuch_rb_cQuery, "count_threads", notmuch_rb_query_count_threads, 0); /* in query.c */ /* * Document-class: Notmuch::Threads diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 1658edee..a7dacba3 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -182,3 +182,22 @@ notmuch_rb_query_count_messages (VALUE self) */ return UINT2NUM(notmuch_query_count_messages(query)); } + +/* + * call-seq: QUERY.count_threads => Fixnum + * + * Return an estimate of the number of threads matching a search + */ +VALUE +notmuch_rb_query_count_threads (VALUE self) +{ + notmuch_query_t *query; + + Data_Get_Notmuch_Query (self, query); + + /* Xapian exceptions are not handled properly. + * (function may return 0 after printing a message) + * Thus there is nothing we can do here... + */ + return UINT2NUM(notmuch_query_count_threads(query)); +} |