Sha256: 14302db63dc8af5dd64fcad5fa26dfb848b49cbe01d67a5b3338671fea78f94f
Contents?: true
Size: 407 Bytes
Versions: 10
Compression:
Stored size: 407 Bytes
Contents
module MakeTaggable module TagsHelper # See the wiki for an example using tag_cloud. def tag_cloud(tags, classes) return [] if tags.empty? max_count = tags.max_by(&:taggings_count).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
10 entries across 10 versions & 1 rubygems