Sha256: dca3d6c9f922db6c58196ef6b281db638d5d92bcb5771c8633afddcd1550e3fa

Contents?: true

Size: 423 Bytes

Versions: 10

Compression:

Stored size: 423 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)).round
        yield tag, classes[index]
      end
    end
  end
end

Version data entries

10 entries across 9 versions & 4 rubygems

Version Path
acts-as-taggable-on-2.2.0 lib/acts_as_taggable_on/tags_helper.rb
rylwin-acts-as-taggable-on-2.1.1a lib/acts_as_taggable_on/tags_helper.rb
rylwin-acts-as-taggable-on-2.1.1a lib/acts_as_taggable_on/taggable/tags_helper.rb
acts-as-taggable-on-2.1.1 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.1.0 lib/acts_as_taggable_on/tags_helper.rb
yetanothernguyen-acts-as-taggable-on-0.0.5 lib/acts_as_taggable_on/tags_helper.rb
yetanothernguyen-acts-as-taggable-on-0.0.4 lib/acts_as_taggable_on/tags_helper.rb
ghazel-acts-as-taggable-on-2.0.6.1 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.6 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.5 lib/acts_as_taggable_on/tags_helper.rb