class DataMapper::Collection
Public Instance Methods
analyze()
click to toggle source
# File lib/ptj/ext/datamapper_collection.rb, line 26 def analyze h = Hash.new(0) self.each { | v | h.store(v, h[v]+1) } h end
analyze_and_sort()
click to toggle source
# File lib/ptj/ext/datamapper_collection.rb, line 16 def analyze_and_sort b = Hash.new(0) self.each do |item| meth = item.method(entry) b[meth.call()] += 1 end b = b.sort_by { |k,v| -1*v } b end
get_value(entry)
click to toggle source
# File lib/ptj/ext/datamapper_collection.rb, line 7 def get_value(entry) returned_array = [] self.each do |item| meth = item.method(entry) returned_array << meth.call() end returned_array end
sort_by_occurance(entry)
click to toggle source
# File lib/ptj/ext/datamapper_collection.rb, line 32 def sort_by_occurance(entry) returned_array = [] sorted_array = self.analyze_and_sort(entry) sorted_array.each do |smaller_array| returned_array << smaller_array[0] end returned_array end