From 8f96c404824edf2013c4377ee041e0800283307b Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 24 Mar 2013 17:02:39 +0000 Subject: merge revision(s) 39677,39695: [Backport #8068] * complex.c: described syntax of string form. * rational.c: ditto. * complex.c: edited rdoc. * rational.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@39918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'rational.c') diff --git a/rational.c b/rational.c index a78b3202ec..e009ff2314 100644 --- a/rational.c +++ b/rational.c @@ -571,6 +571,22 @@ f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y) * * Rational(1, 2) #=> (1/2) * Rational('1/2') #=> (1/2) + * + * Syntax of string form: + * + * string form = extra spaces , rational , extra spaces ; + * rational = [ sign ] , unsigned rational ; + * unsigned rational = numerator | numerator , "/" , denominator ; + * numerator = integer part | fractional part | integer part , fractional part ; + * denominator = digits ; + * integer part = digits ; + * fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ; + * sign = "-" | "+" ; + * digits = digit , { digit | "_" , digit } ; + * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; + * extra spaces = ? \s* ? ; + * + * See String#to_r. */ static VALUE nurat_f_rational(int argc, VALUE *argv, VALUE klass) @@ -2256,6 +2272,8 @@ string_to_r_strict(VALUE self) * '21 june 09'.to_r #=> (21/1) * '21/06/09'.to_r #=> (7/2) * 'bwv 1079'.to_r #=> (0/1) + * + * See Kernel.Rational. */ static VALUE string_to_r(VALUE self) -- cgit v1.2.3