aboutsummaryrefslogtreecommitdiffhomepage
path: root/bindings/ruby
diff options
context:
space:
mode:
authorGravatar Ali Polatel <alip@exherbo.org>2011-01-10 15:59:18 +0200
committerGravatar Ali Polatel <alip@exherbo.org>2011-01-25 12:03:32 +0200
commited38940323ba80d0136688405cbd923fa088d706 (patch)
treef6981f16a16e26b79421ee5356abfb19cabc8c45 /bindings/ruby
parent3863e88e965f37e316de90978071c985fb4e5701 (diff)
ruby: Add wrappers for query_get_s{ort,tring}
New wrappers: notmuch_query_get_sort(): QUERY.sort notmuch_query_get_query_string(): QUERY.to_s
Diffstat (limited to 'bindings/ruby')
-rw-r--r--bindings/ruby/defs.h6
-rw-r--r--bindings/ruby/init.c2
-rw-r--r--bindings/ruby/query.c30
3 files changed, 38 insertions, 0 deletions
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index b1be5a30..db530968 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -190,9 +190,15 @@ 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);
VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index e19b0356..63ab205e 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -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);
diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index c5b8a4cc..ef9e1a07 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -39,6 +39,21 @@ notmuch_rb_query_destroy(VALUE self)
}
/*
+ * 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
*
* Set sort type of the +QUERY+
@@ -59,6 +74,21 @@ notmuch_rb_query_set_sort(VALUE self, VALUE sortv)
}
/*
+ * 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
*
* Search for threads