lib/csv/table/table.rb in smart_csv-0.0.5 vs lib/csv/table/table.rb in smart_csv-0.0.6
- old
+ new
@@ -24,9 +24,21 @@
result << record if counter == conditions.size
end
result
end
+ # select all records which have attribute greater than starter
+ def gt(attribute, starter)
+ result = CSV::Table.new([])
+ result.ancestor = self.ancestor || self
+
+ self.each do |record|
+ result << record if record[attribute].to_i > starter
+ end
+
+ result
+ end
+
def create(*conditions)
headers = self.headers
row = headers.inject({}){|result, value| result[value] = nil; result}
conditions.first.each do |key, value|
raise "In headers: '#{headers}' don't have key: '#{key}'" unless headers.include?(key)