Sha256: c2269315f37b8d842fb5ff55824319b201d238cbc80e815ec87a68604b4d10aa

Contents?: true

Size: 343 Bytes

Versions: 15

Compression:

Stored size: 343 Bytes

Contents

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

Version Path
elight-acts_as_taggable_on_steroids-1.1 lib/tags_helper.rb
ggoodale-acts_as_taggable_on_steroids-1.1.1 lib/tags_helper.rb
ggoodale-acts_as_taggable_on_steroids-1.1 lib/tags_helper.rb
jviney-acts_as_taggable_on_steroids-1.0 lib/tags_helper.rb
jviney-acts_as_taggable_on_steroids-1.1 lib/tags_helper.rb
rotuka-taggable-0.0.1 generators/tags/templates/tags_helper.rb
seamusabshere-acts_as_taggable_on_steroids-1.0 lib/tags_helper.rb
seamusabshere-acts_as_taggable_on_steroids-1.3 lib/tags_helper.rb
enki-engine-0.0.5 lib/tags_helper.rb
enki-engine-0.0.4 lib/tags_helper.rb
enki-engine-0.0.3 lib/tags_helper.rb
enki-engine-0.0.2 lib/tags_helper.rb
acts_as_taggable_on_steroids-1.2 lib/tags_helper.rb
acts_as_taggable_on_steroids-1.1 lib/tags_helper.rb
pictrails-0.5.0 vendor/plugins/acts_as_taggable_on_steroids/lib/tags_helper.rb