Class: Contraption::TagCloud

Inherits:
Object
  • Object
show all
Defined in:
lib/contraption/tag_cloud.rb

Instance Method Summary collapse

Constructor Details

#initialize(posts) ⇒ TagCloud

Returns a new instance of TagCloud.



3
4
5
# File 'lib/contraption/tag_cloud.rb', line 3

def initialize posts
  @posts = posts
end

Instance Method Details

#to_sObject



7
8
9
10
11
12
13
# File 'lib/contraption/tag_cloud.rb', line 7

def to_s
  @posts.by_tag
        .each_pair
        .map {|k, v| [tag_link(k), tag_size(v.length)]}
        .map {|el| scale el}
        .join "\n"
end