зеркало из https://github.com/github/ruby.git
* lib/optparse.rb (Numeric): accept rationals.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d0cb5c71ce
Коммит
b1b3e13570
|
@ -1,3 +1,7 @@
|
|||
Mon Mar 29 18:10:03 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/optparse.rb (Numeric): accept rationals.
|
||||
|
||||
Mon Mar 29 15:10:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/tempfile.rb (Tempfile#open): re-open with same mode and
|
||||
|
|
|
@ -1531,9 +1531,16 @@ class OptionParser
|
|||
|
||||
#
|
||||
# Generic numeric format, converts to Integer for integer format, Float
|
||||
# for float format.
|
||||
# for float format, and Rational for rational format.
|
||||
#
|
||||
accept(Numeric, %r"\A[-+]?(?:#{octal}|#{float})"io) {|s,| eval(s) if s}
|
||||
real = "[-+]?(?:#{octal}|#{float})"
|
||||
accept(Numeric, /\A(#{real})(?:\/(#{real}))?/io) {|s, d, n|
|
||||
if n
|
||||
Rational(d, n)
|
||||
elsif s
|
||||
eval(s)
|
||||
end
|
||||
}
|
||||
|
||||
#
|
||||
# Decimal integer format, to be converted to Integer.
|
||||
|
|
Загрузка…
Ссылка в новой задаче