201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/cnote/commands.rb', line 201
def list_tags
tags = Hash.new(0)
longest = 0
sorted = []
@notes.each do |num, note|
note.tags.each do |tag|
tags[tag] += 1;
end
end
tags.each do |tag, count|
longest = tag.length if tag.length > longest
sorted << [tag, count]
end
sorted.sort_by! { |item| item[0] }
puts
puts "#{indent}All Tags".bold
puts "#{indent}--------"
puts
sorted.each do |entry|
tag, count = entry
puts "#{indent}#{tag.bold} #{"." * (longest + 3 - tag.length)} #{count} notes"
end
puts
end
|