Sha256: a562133e01dc67856c8be63fada7d7f8fb97cc4a3cdea4c7638033bb973c677f

Contents?: true

Size: 347 Bytes

Versions: 6

Compression:

Stored size: 347 Bytes

Contents

module TagsHelper
  # See the README for an example using tag_cloud.
  def tag_cloud(tags, classes)
    return if tags.all.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

6 entries across 6 versions & 3 rubygems

Version Path
protolif-acts_as_taggable_on_steroids-2.1.2 app/helpers/tags_helper.rb
protolif-acts_as_taggable_on_steroids-2.1.1 app/helpers/tags_helper.rb
bborn-acts_as_taggable_on_steroids-2.1 app/helpers/tags_helper.rb
bborn-acts_as_taggable_on_steroids-2.0.beta3 lib/tags_helper.rb
bborn-acts_as_taggable_on_steroids-2.0.beta2 lib/tags_helper.rb
acts_as_taggable3-2.0.beta2 lib/tags_helper.rb