summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-13 05:00:03 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-13 05:00:03 +0000
commit6bc16a119834f4d496c527c19b4dcdb2430e26ab (patch)
treeaca2c8d107644e6d0717c41f22330f6ff5ac41aa /numeric.c
parent9bb7c219702f282ae139c0f149c9249c10626ccc (diff)
* numeric.c (numeric.c): Integer#ord implemented. [ruby-dev:32206]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index 93f569fd40..38a99f8283 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1807,6 +1807,26 @@ int_chr(num)
return rb_str_new(&c, 1);
}
+/*
+ * call-seq:
+ * int.ord => int
+ *
+ * Returns the int itself.
+ *
+ * ?a.ord #=> 97
+ *
+ * This method is intended for compatibility to
+ * character constant in Ruby 1.9.
+ * For example, ?a.ord returns 97 both in 1.8 and 1.9.
+ */
+
+static VALUE
+int_ord(num)
+ VALUE num;
+{
+ return num;
+}
+
/********************************************************************
*
* Document-class: Fixnum
@@ -2924,6 +2944,7 @@ Init_Numeric()
rb_define_method(rb_cInteger, "succ", int_succ, 0);
rb_define_method(rb_cInteger, "next", int_succ, 0);
rb_define_method(rb_cInteger, "chr", int_chr, 0);
+ rb_define_method(rb_cInteger, "ord", int_ord, 0);
rb_define_method(rb_cInteger, "to_i", int_to_i, 0);
rb_define_method(rb_cInteger, "to_int", int_to_i, 0);
rb_define_method(rb_cInteger, "floor", int_to_i, 0);