classifier 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/rdoctask'
5
5
  require 'rake/gempackagetask'
6
6
  require 'rake/contrib/rubyforgepublisher'
7
7
 
8
- PKG_VERSION = "1.3.1"
8
+ PKG_VERSION = "1.3.2"
9
9
 
10
10
  PKG_FILES = FileList[
11
11
  "lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "html/**/*"
@@ -7,9 +7,15 @@ require 'matrix'
7
7
  require 'mathn'
8
8
 
9
9
  class Array
10
- def sum
11
- inject(0) { |sum,term| sum += term }.to_f
12
- end
10
+ def sum(identity = 0, &block)
11
+ return identity unless size > 0
12
+
13
+ if block_given?
14
+ map(&block).sum
15
+ else
16
+ inject { |sum, element| sum + element }.to_f
17
+ end
18
+ end
13
19
  end
14
20
 
15
21
  class Vector
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
@@ -9,7 +9,7 @@ autorequire: classifier
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-10 00:00:00 -07:00
12
+ date: 2010-07-06 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency