lib/quality_extensions/array/classify.rb in quality_extensions-0.1.4 vs lib/quality_extensions/array/classify.rb in quality_extensions-1.0.0
- old
+ new
@@ -8,13 +8,14 @@
# * Compare to Array#group_by (quality_extensions), which assumes all elements are arrays (making a "table") and only
# allows you to do simple classification by the value of a "column". On the other hand, it adds the option to delete that
# column from the array, which can be nice, since the classification key in the hash makes it somewhat redundant.
#++
+$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..')
require 'rubygems'
gem 'facets'
-require 'facet/array/to_hash'
+require 'facets/to_hash'
class Array
=begin rdoc
Classifies the array by the return value of the given block and returns a hash of {value => array of elements} pairs.
The block is called once for each element of the array, passing the element as parameter.
@@ -49,9 +50,10 @@
# | |/ _ \/ __| __|
# | | __/\__ \ |_
# |_|\___||___/\__|
#
=begin test
+require 'test/unit'
require 'set'
class TheTest < Test::Unit::TestCase
def test_classify
input = [