[macruby-changes] [2203] MacRuby/branches/experimental/numeric.c

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 3 19:07:48 PDT 2009


Revision: 2203
          http://trac.macosforge.org/projects/ruby/changeset/2203
Author:   lsansonetti at apple.com
Date:     2009-08-03 19:07:48 -0700 (Mon, 03 Aug 2009)
Log Message:
-----------
add Integer#ord (patch by Dan Sinclair)

Modified Paths:
--------------
    MacRuby/branches/experimental/numeric.c

Modified: MacRuby/branches/experimental/numeric.c
===================================================================
--- MacRuby/branches/experimental/numeric.c	2009-08-04 01:40:07 UTC (rev 2202)
+++ MacRuby/branches/experimental/numeric.c	2009-08-04 02:07:48 UTC (rev 2203)
@@ -1980,6 +1980,25 @@
     return INT2FIX(1);
 }
 
+/*
+ *  call-seq:
+ *     int.ord  ->  self
+ *
+ *  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(VALUE num, SEL sel)
+{
+    return num;
+}
+
 /********************************************************************
  *
  * Document-class: Fixnum
@@ -3321,6 +3340,7 @@
     rb_objc_define_method(rb_cInteger, "next", int_succ, 0);
     rb_objc_define_method(rb_cInteger, "pred", int_pred, 0);
     rb_objc_define_method(rb_cInteger, "chr", int_chr, -1);
+    rb_objc_define_method(rb_cInteger, "ord", int_ord, 0);
     rb_objc_define_method(rb_cInteger, "to_i", int_to_i, 0);
     rb_objc_define_method(rb_cInteger, "to_int", int_to_i, 0);
     rb_objc_define_method(rb_cInteger, "floor", int_to_i, 0);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090803/3c2d555e/attachment.html>


More information about the macruby-changes mailing list