summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/complex.rb32
-rw-r--r--lib/parsedate.rb2
-rw-r--r--lib/timeout.rb2
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