From 23fc4ad70d0816f97e30d908f0a9074be9dca362 Mon Sep 17 00:00:00 2001 From: sandal Date: Tue, 28 Aug 2007 16:06:27 +0000 Subject: [PATCH] sort_rows_by doc patch from Stefan Mahlitz. git-svn-id: http://stonecode.svnrepository.com/svn/ruport/ruport/trunk@1168 bb2e8eb0-7117-0410-aac4-c024b40ed5f7 --- lib/ruport/data/table.rb | 21 ++++++++++++++++----- test/acts_as_reportable_test.rb | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ruport/data/table.rb b/lib/ruport/data/table.rb index e5fe2cb6..23aaa366 100644 --- a/lib/ruport/data/table.rb +++ b/lib/ruport/data/table.rb @@ -597,9 +597,11 @@ def sigma(column=nil) alias_method :sum, :sigma # Returns a sorted table. If col_names is specified, - # the block is ignored and the table is sorted by the named columns. All - # options are used in constructing the new Table (see Array#to_table - # for details). + # the block is ignored and the table is sorted by the named columns. + # + # The second argument specifies sorting options. Currently only + # :order is supported. Default order is ascending, to sort decending + # use :order => :descending # # Example: # @@ -608,11 +610,20 @@ def sigma(column=nil) # # returns a new table sorted by col1 # table.sort_rows_by {|r| r["col1"]} # + # # returns a new table sorted by col1, in descending order + # table.sort_rows_by(nil, :order => :descending) {|r| r["col1"]} + # # # returns a new table sorted by col2 - # table.sort_rows_by ["col2"] + # table.sort_rows_by(["col2"]) + # + # # returns a new table sorted by col2, descending order + # table.sort_rows_by("col2", :order => :descending) # # # returns a new table sorted by col1, then col2 - # table.sort_rows_by ["col1", "col2"] + # table.sort_rows_by(["col1", "col2"]) + # + # # returns a new table sorted by col1, then col2, in descending order + # table.sort_rows_by(["col1", "col2"], :order => descending) # def sort_rows_by(col_names=nil, options={}, &block) # stabilizer is needed because of diff --git a/test/acts_as_reportable_test.rb b/test/acts_as_reportable_test.rb index e2cf1c6e..2c9b4d78 100644 --- a/test/acts_as_reportable_test.rb +++ b/test/acts_as_reportable_test.rb @@ -4,7 +4,7 @@ begin require "mocha" require "stubba" - require "active_record" + Ruport.quiet { require "active_record" } rescue LoadError nil end