lib/table_fu.rb in table_fu-0.2.1 vs lib/table_fu.rb in table_fu-0.3.0
- old
+ new
@@ -60,11 +60,11 @@
# Returns all the Row objects for this object as a collection
def rows
all_rows = []
@table.each_with_index do |row, index|
all_rows << TableFu::Row.new(row, index, self)
- end
+ end
all_rows.sort
end
# Return the headers defined in column headers or cherry picked from @col_opts
def columns
@@ -207,9 +207,18 @@
else # Return a nil Datum object for non existant column names
TableFu::Datum.new(nil, col_name, self, @spreadsheet)
end
end
alias_method :column_for, :datum_for
+
+ # sugar
+ def [](col)
+ if col.is_a?(String)
+ column_for(col)
+ else
+ super(col)
+ end
+ end
# Comparator for sorting a spreadsheet row.
#
def <=>(b)
if @spreadsheet.sorted_by
\ No newline at end of file