Sha256: ad292e82957a13707386eb58e18b2f9f6c59fde065930f61d48b8dd85ca04778
Contents?: true
Size: 417 Bytes
Versions: 18
Compression:
Stored size: 417 Bytes
Contents
module ActsAsTaggableOn module TagsHelper # See the wiki for an example using tag_cloud. def tag_cloud(tags, classes) return [] if tags.empty? max_count = tags.sort_by(&:taggings_count).last.taggings_count.to_f tags.each do |tag| index = ((tag.taggings_count / max_count) * (classes.size - 1)) yield tag, classes[index.nan? ? 0 : index.round] end end end end
Version data entries
18 entries across 18 versions & 3 rubygems