Sha256: 603976b40bff913b54bb0a371723ff88717c68802187a56632c3c65943fc5033

Contents?: true

Size: 440 Bytes

Versions: 1

Compression:

Stored size: 440 Bytes

Contents

module ActsAsTaggableOnPadrino
  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 {|tag| tag.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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts-as-taggable-on-padrino-0.1.2 lib/acts_as_taggable_on_padrino/tags_helper.rb