diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-01-17 08:37:53 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-01-17 08:37:53 +0000 |
commit | dde62bcd2efbb3825d982326896ab774e73e4218 (patch) | |
tree | 6a421d3818dd390cf8f6b2c5544726a8950e1401 /lib | |
parent | e43877719bd4bbd12e493e896a0f98c5b349937b (diff) |
2000-01-17
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/complex.rb | 32 | ||||
-rw-r--r-- | lib/parsedate.rb | 2 | ||||
-rw-r--r-- | lib/timeout.rb | 2 |
3 files changed, 20 insertions, 16 deletions
diff --git a/lib/complex.rb b/lib/complex.rb index 0af8c20b89..56dd040ac1 100644 --- a/lib/complex.rb +++ b/lib/complex.rb @@ -20,7 +20,7 @@ # Complex::/ # Complex::** # Complex::% -# Complex::divmod +# Complex::divmod -- obsolete # Complex::abs # Complex::abs2 # Complex::arg @@ -51,6 +51,12 @@ def Complex(a, b = 0) if a.kind_of?(Complex) and b == 0 a + elsif b.kind_of?(Complex) + if a.kind_of?(Complex) + Complex(a.real-b.image, a.image + b.real) + else + Complex(a-b.image, b.real) + end elsif b == 0 and defined? Complex::Unify a else @@ -181,18 +187,18 @@ class Complex < Numeric end end - def divmod(other) - if other.kind_of?(Complex) - rdiv, rmod = @real.divmod(other.real) - idiv, imod = @image.divmod(other.image) - return Complex(rdiv, idiv), Complex(rmod, rdiv) - elsif Complex.generic?(other) - Complex(@real.divmod(other), @image.divmod(other)) - else - x , y = other.coerce(self) - x.divmod(y) - end - end +# def divmod(other) +# if other.kind_of?(Complex) +# rdiv, rmod = @real.divmod(other.real) +# idiv, imod = @image.divmod(other.image) +# return Complex(rdiv, idiv), Complex(rmod, rmod) +# elsif Complex.generic?(other) +# Complex(@real.divmod(other), @image.divmod(other)) +# else +# x , y = other.coerce(self) +# x.divmod(y) +# end +# end def abs Math.sqrt!((@real*@real + @image*@image).to_f) diff --git a/lib/parsedate.rb b/lib/parsedate.rb index 29b3fa43b9..7bf1affb42 100644 --- a/lib/parsedate.rb +++ b/lib/parsedate.rb @@ -27,7 +27,7 @@ module ParseDate if date.sub!(/(#{DAYPAT})[a-z]*,?/i, ' ') wday = DAYS[$1.downcase] end - if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4})?|[-+]\d{4}))?/i, ' ') + if date.sub!(/(\d+):(\d+)(?::(\d+))?(?:\s*(am|pm))?(?:\s+([a-z]{1,4}(?:\s+[a-z]{1,4}|[-+]\d{4})?))?/i, ' ') hour = $1.to_i min = $2.to_i if $3 diff --git a/lib/timeout.rb b/lib/timeout.rb index 75340d52dd..b6bda6cece 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -25,8 +25,6 @@ class TimeoutError<StandardError end -Thread.abort_on_exception = true - def timeout(sec) begin x = Thread.current |