module Notes::Stats
Public Instance Methods
compute(tasks)
click to toggle source
# File lib/notes-cli/stats.rb, line 7 def compute(tasks) { flag_counts: flag_counts(tasks), found_flags: found_flags(tasks) } end
flag_counts(tasks)
click to toggle source
Take in a set of tasks and compute aggregate stats such as counts per flag. Intended to augment a JSON set
tasks: Array
Returns Hash
# File lib/notes-cli/stats.rb, line 20 def flag_counts(tasks) counts = Hash.new(0) tasks.each do |task| task.flags.each { |flag| counts[flag] += 1 } end counts end