Sha256: a93b6466bffbd272910d02fc18aaa15159744c04164a9fd9278d8726ac4063c3

Contents?: true

Size: 374 Bytes

Versions: 15

Compression:

Stored size: 374 Bytes

Contents

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

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
axtro-acts-as-taggable-on-2.0.6 lib/acts_as_taggable_on/tags_helper.rb
axtro-acts-as-taggable-on-2.0.5 lib/acts_as_taggable_on/tags_helper.rb
axtro-acts-as-taggable-on-2.0.4 lib/acts_as_taggable_on/tags_helper.rb
litmus-acts-as-taggable-on-2.0.4 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.4 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.3 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.2 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.1 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0.rc2 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0.rc1 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0.pre5 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-0.0.0 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0.pre4 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0.pre3 lib/acts_as_taggable_on/tags_helper.rb