Sha256: e4b48ccebc028e608d670f1251fa76a6a17bf0b2e5a269758054e98e51ce78c5

Contents?: true

Size: 385 Bytes

Versions: 3

Compression:

Stored size: 385 Bytes

Contents

module TagsHelper

  # See the README for an example using tag_cloud.
  def tag_cloud(tags, classes)
    tags = tags.all if tags.is_a? ActiveRecord::Relation

    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

3 entries across 3 versions & 3 rubygems

Version Path
acts-as-taggable-on-simonwh-2.0.0.pre1 lib/acts_as_taggable_on/tags_helper.rb
simonwh-acts-as-taggable-on-2.0.0.pre1 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-2.0.0.pre1 lib/acts_as_taggable_on/tags_helper.rb