ruby: Add wrappers for query_get_s{ort,tring}
authorAli Polatel <alip@exherbo.org>
Mon, 10 Jan 2011 13:59:18 +0000 (15:59 +0200)
committerAli Polatel <alip@exherbo.org>
Tue, 25 Jan 2011 10:03:32 +0000 (12:03 +0200)
New wrappers:
notmuch_query_get_sort(): QUERY.sort
notmuch_query_get_query_string(): QUERY.to_s

bindings/ruby/defs.h
bindings/ruby/init.c
bindings/ruby/query.c

index b1be5a30865f3c5e42de40d0c8d014168dfa6012..db53096850e471cfe33cf7815f93cb069aa0897d 100644 (file)
@@ -189,9 +189,15 @@ notmuch_rb_filenames_each(VALUE self);
 VALUE
 notmuch_rb_query_destroy(VALUE self);
 
+VALUE
+notmuch_rb_query_get_sort(VALUE self);
+
 VALUE
 notmuch_rb_query_set_sort(VALUE self, VALUE sortv);
 
+VALUE
+notmuch_rb_query_get_string(VALUE self);
+
 VALUE
 notmuch_rb_query_search_threads(VALUE self);
 
index e19b0356ffc08c874f009a257608beb09d95e36b..63ab205e701da16096f644bb3dc90bf7902be9de 100644 (file)
@@ -224,7 +224,9 @@ Init_notmuch(void)
     notmuch_rb_cQuery = rb_define_class_under(mod, "Query", rb_cData);
     rb_undef_method(notmuch_rb_cQuery, "initialize");
     rb_define_method(notmuch_rb_cQuery, "destroy", notmuch_rb_query_destroy, 0);
+    rb_define_method(notmuch_rb_cQuery, "sort", notmuch_rb_query_get_sort, 0);
     rb_define_method(notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1);
+    rb_define_method(notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0);
     rb_define_method(notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0);
     rb_define_method(notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0);
 
index c5b8a4cc324f278ed6ff0ec17007c8eb90c01538..ef9e1a077b28ddbbb31e33fde16fe1e584b40e3d 100644 (file)
@@ -38,6 +38,21 @@ notmuch_rb_query_destroy(VALUE self)
     return Qnil;
 }
 
+/*
+ * call-seq: QUERY.sort => fixnum
+ *
+ * Get sort type of the +QUERY+
+ */
+VALUE
+notmuch_rb_query_get_sort(VALUE self)
+{
+    notmuch_query_t *query;
+
+    Data_Get_Notmuch_Query(self, query);
+
+    return FIX2INT(notmuch_query_get_sort(query));
+}
+
 /*
  * call-seq: QUERY.sort=(fixnum) => nil
  *
@@ -58,6 +73,21 @@ notmuch_rb_query_set_sort(VALUE self, VALUE sortv)
     return Qnil;
 }
 
+/*
+ * call-seq: QUERY.to_s => string
+ *
+ * Get query string of the +QUERY+
+ */
+VALUE
+notmuch_rb_query_get_string(VALUE self)
+{
+    notmuch_query_t *query;
+
+    Data_Get_Notmuch_Query(self, query);
+
+    return rb_str_new2(notmuch_query_get_query_string(query));
+}
+
 /*
  * call-seq: QUERY.search_threads => THREADS
  *