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