Skip to content

Commit

Permalink
Add #frequencies, #frequency_groups and #frequency_counts
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Oct 17, 2012
1 parent 0f9017a commit bd11064
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/pacer/route/mixin/route_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ def group_count(*props)
end
result
end
alias frequencies group_count

def frequency_groups(*props)
result = Hash.new { |h, k| h[k] = [] }
group_count(*props).each { |k, v| result[v] << k }
result
end

def frequency_counts(*props)
result = Hash.new 0
group_count(*props).each { |k, v| result[v] += 1 }
result
end

def most_frequent(range = 0, include_counts = false)
if include_counts
Expand Down

0 comments on commit bd11064

Please sign in to comment.