Class: Forematter::Commands::Count

Inherits:
Forematter::CommandRunner show all
Defined in:
lib/forematter/commands/count.rb

Instance Method Summary collapse

Methods inherited from Forematter::CommandRunner

#call

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
# File 'lib/forematter/commands/count.rb', line 11

def run
  counts = tags.reduce({}) { |a, e| a.merge(e => (a[e] || 0) + 1) }
  fmt    = format(counts)

  counts.sort_by { |tag, count| count }.each do |tag, count|
    puts sprintf(fmt, count, tag)
  end
end