about summary refs log tree commit diff stats
path: root/app/helpers/tags_helper.rb
blob: 9643834d470fba43a4853aeeb843aaccebdfc486 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
module TagsHelper

  def tag_cloud(tags, classes)
    max = tags.sort_by(&:taggings_count).last
    tags.each do |tag|
      index = tag.taggings_count.to_f / max.taggings_count * (classes.size - 1)
      yield(tag, classes[index.round])
    end
  end

end