4 # Created by Toshi Nagata.
5 # Copyright 2008 Toshi Nagata. All rights reserved.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
19 Deg2Rad = Math::PI / 180.0
20 Rad2Deg = 180.0 / Math::PI
22 $startup_dir = Dir.pwd
24 when /mswin|mingw|cygwin|bccwin/
38 print $backtrace.join("\n")
46 self.inject(0) { |sum, v| sum + block.call(v) }
48 self.inject(0) { |sum, v| sum + v }
52 sum(&block) / Float(self.length)
57 def filecopy(src, dst)
58 fpin = File.open(src, "rb")
59 return nil if fpin == nil
60 fpout = File.open(dst, "wb")
66 while fpin.read(4096, a)