class Array

Public Instance Methods

analyze() click to toggle source
# File lib/ptj/ext/datamapper_collection.rb, line 45
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 51
def analyze_and_sort
  b = Hash.new(0)
  self.each { | v | b.store(v, b[v]+1) }
  b = b.sort_by { |k,v| -1*v }
  b
end
analyze_and_sort_key() click to toggle source
# File lib/ptj/ext/datamapper_collection.rb, line 58
def analyze_and_sort_key
  b = Hash.new(0)
  self.each { | v | b.store(v, b[v]+1) }
  b = b.sort_by { |k,v| k }
  b
end