Skip to content

Commit

Permalink
sort_rows_by doc patch from Stefan Mahlitz.
Browse files Browse the repository at this point in the history
git-svn-id: http://stonecode.svnrepository.com/svn/ruport/ruport/trunk@1168 bb2e8eb0-7117-0410-aac4-c024b40ed5f7
  • Loading branch information
sandal committed Aug 28, 2007
1 parent 8f8c4b2 commit 23fc4ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions lib/ruport/data/table.rb
Expand Up @@ -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:
#
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/acts_as_reportable_test.rb
Expand Up @@ -4,7 +4,7 @@
begin
require "mocha"
require "stubba"
require "active_record"
Ruport.quiet { require "active_record" }
rescue LoadError
nil
end
Expand Down

0 comments on commit 23fc4ad

Please sign in to comment.