Sha256: 1a642f2ba031f3c3ba1d49f3960c71d368e8f5ec63635c2bae871687021b5a66
Contents?: true
Size: 728 Bytes
Versions: 1
Compression:
Stored size: 728 Bytes
Contents
module Monologue module TagsHelper #Number of sizes defined in the css NUMBER_OF_LABEL_SIZES = 5 def tag_url(tag) "#{Monologue::Engine.routes.url_helpers.root_path}tags/#{tag.name.downcase}" end def label_for_tag(tag, min, max) "label-size-#{size_for_tag(tag, min, max)}" end def size_for_tag(tag, min, max) #logarithmic scaling based on the number of occurrences of each tag if min<max && tag.frequency>0 1 + ((NUMBER_OF_LABEL_SIZES-1)*(log_distance_to_min(tag.frequency, min))/log_distance_to_min(max, min)).round else 1 end end private def log_distance_to_min(value, min) Math.log(value)-Math.log(min) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
monologue-0.3.0 | app/helpers/monologue/tags_helper.rb |