[Groonga-commit] ranguba/rroonga at 105d772 [master] Add Groonga::Operator#to_s

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Apr 14 15:28:04 JST 2015


Kouhei Sutou	2015-04-14 15:28:04 +0900 (Tue, 14 Apr 2015)

  New Revision: 105d772a81bc98732c3a2c80279aed435d7e1344
  https://github.com/ranguba/rroonga/commit/105d772a81bc98732c3a2c80279aed435d7e1344

  Message:
    Add Groonga::Operator#to_s

  Modified files:
    ext/groonga/rb-grn-operator.c
    test/test-operator.rb

  Modified: ext/groonga/rb-grn-operator.c (+11 -0)
===================================================================
--- ext/groonga/rb-grn-operator.c    2015-04-14 15:23:54 +0900 (07be4c3)
+++ ext/groonga/rb-grn-operator.c    2015-04-14 15:28:04 +0900 (752fc88)
@@ -285,6 +285,15 @@ rb_grn_operator_to_i (VALUE self)
     return rb_iv_get(self, "@value");
 }
 
+static VALUE
+rb_grn_operator_to_s (VALUE self)
+{
+    grn_operator operator;
+
+    operator = rb_grn_operator_from_ruby_object(self);
+    return rb_str_new_cstr(grn_operator_to_string(operator));
+}
+
 void
 rb_grn_init_operator (VALUE mGrn)
 {
@@ -300,6 +309,8 @@ rb_grn_init_operator (VALUE mGrn)
     rb_define_method(rb_cGrnOperator, "to_i",
                      rb_grn_operator_to_i, 0);
     rb_define_alias(rb_cGrnOperator, "to_int", "to_i");
+    rb_define_method(rb_cGrnOperator, "to_s",
+                     rb_grn_operator_to_s, 0);
 
     rb_grn_init_equal_operator(mGrn);
     rb_grn_init_not_equal_operator(mGrn);

  Modified: test/test-operator.rb (+6 -0)
===================================================================
--- test/test-operator.rb    2015-04-14 15:23:54 +0900 (8d3df4c)
+++ test/test-operator.rb    2015-04-14 15:28:04 +0900 (ce6c78a)
@@ -21,6 +21,12 @@ class OperatorTest < Test::Unit::TestCase
 
   setup :setup_database
 
+  sub_test_case "#to_s" do
+    test "equal" do
+      assert_equal("equal", Groonga::Operator::EQUAL.to_s)
+    end
+  end
+
   sub_test_case "equal" do
     sub_test_case "#exec" do
       test "equal" do
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index