Sha256: d9976b8d4304fc1d9e7098332836152d078ab4a75471d30cf3ae21223fb6b9ac

Contents?: true

Size: 328 Bytes

Versions: 20

Compression:

Stored size: 328 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

20 entries across 20 versions & 3 rubygems

Version Path
taxonomy-0.0.1 lib/taxonomy/tags_helper.rb
acts-as-taggable-on-1.1.9 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.8 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.7 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.6 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.5 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.4 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.3 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.2 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.1 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.1.0 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.0.19 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.0.18 lib/acts_as_taggable_on/tags_helper.rb
bbenezech-acts-as-taggable-on-0.0.4 lib/acts_as_taggable_on/tags_helper.rb
bbenezech-acts-as-taggable-on-0.0.3 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.0.17 lib/acts_as_taggable_on/tags_helper.rb
bbenezech-acts-as-taggable-on-0.0.2 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.0.16 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.0.15 lib/acts_as_taggable_on/tags_helper.rb
acts-as-taggable-on-1.0.14 lib/acts_as_taggable_on/tags_helper.rb