Permalink
Browse files

Remove Enumerable#sproduct

  • Loading branch information...
1 parent 64a9479 commit 6f104068ed218b7359be69fec3276893368896ce @bbatsov committed Sep 3, 2013
Showing with 0 additions and 36 deletions.
  1. +0 −1 README.md
  2. +0 −1 lib/powerpack/enumerable.rb
  3. +0 −19 lib/powerpack/enumerable/sproduct.rb
  4. +0 −15 spec/powerpack/enumerable/sproduct_spec.rb
View
@@ -29,7 +29,6 @@ Or install it yourself as:
* [#drop_last_while](http://rdoc.info/github/bbatsov/powerpack/Enumerable#drop_last_while-instance_method)
* [#frequencies](http://rdoc.info/github/bbatsov/powerpack/Enumerable#frequencies-instance_method)
* [#several?](http://rdoc.info/github/bbatsov/powerpack/Enumerable#several?-instance_method)
- * [#sproduct](http://rdoc.info/github/bbatsov/powerpack/Enumerable#sproduct?-instance_method)
* [#sum](http://rdoc.info/github/bbatsov/powerpack/Enumerable#sum-instance_method)
* [#take_last](http://rdoc.info/github/bbatsov/powerpack/Enumerable#take_last-instance_method)
* [#take_last_while](http://rdoc.info/github/bbatsov/powerpack/Enumerable#take_last_while-instance_method)
@@ -2,7 +2,6 @@
require_relative 'enumerable/drop_last_while'
require_relative 'enumerable/frequencies'
require_relative 'enumerable/several'
-require_relative 'enumerable/sproduct'
require_relative 'enumerable/sum'
require_relative 'enumerable/take_last'
require_relative 'enumerable/take_last_while'
@@ -1,19 +0,0 @@
-unless Enumerable.method_defined? :sproduct
- module Enumerable
- # Multiplies the elements of a collection by invoking their `*` method.
- # Most useful for multiplying numbers. sproduct stands for standard product,
- # since Ruby defines Array#product as a Carthesian product.
- #
- # @param default [Object] an optional default return value if there are no elements.
- # It's nil by default.
- # @return [Object] the product of the elements.
- #
- # @example
- # [1, 2, 3, 4].sproduct #=> 6
- # [].sproduct #=> nil
- # [].sproduct(1) #=> 1
- def sproduct(default = nil)
- reduce(&:*) || default
- end
- end
-end
@@ -1,15 +0,0 @@
-require 'spec_helper'
-
-describe 'Enumerable#sproduct' do
- it 'multiply the numbers of an enum' do
- expect((1..4).sproduct).to eq(24)
- end
-
- it 'returns nil when invoked on an empty collection' do
- expect([].sproduct).to be_nil
- end
-
- it 'returns default value when invoked on an empty collection' do
- expect([].sproduct(0)).to be_zero
- end
-end

0 comments on commit 6f10406

Please sign in to comment.