Class: TagCloudBase
- Inherits:
-
Object
- Object
- TagCloudBase
- Defined in:
- lib/tagcloudbase.rb
Instance Attribute Summary collapse
-
#to_dynarex ⇒ Object
readonly
Returns the value of attribute to_dynarex.
-
#xsl ⇒ Object
Returns the value of attribute xsl.
Instance Method Summary collapse
-
#initialize(all_tags = {}) ⇒ TagCloudBase
constructor
A new instance of TagCloudBase.
- #to_webpage ⇒ Object
Constructor Details
#initialize(all_tags = {}) ⇒ TagCloudBase
Returns a new instance of TagCloudBase.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tagcloudbase.rb', line 13 def initialize(={}) = .sort_by {|x| -x[-1][-1].to_i} biggest_tag = .first[-1][-1].to_i # sort in alphabetical order = .sort_by &:first @to_dynarex = Dynarex.new('tags/tag(word,href,gauge,count)') .each do |word, v| href, word_size = v weight = 100 / (biggest_tag / word_size.to_i) gauge = (weight / 10).to_i gauge = 8 if gauge > 8 @to_dynarex.create word: word, href: href, gauge: gauge.to_s, count: word_size end end |
Instance Attribute Details
#to_dynarex ⇒ Object (readonly)
Returns the value of attribute to_dynarex.
10 11 12 |
# File 'lib/tagcloudbase.rb', line 10 def to_dynarex @to_dynarex end |
#xsl ⇒ Object
Returns the value of attribute xsl.
11 12 13 |
# File 'lib/tagcloudbase.rb', line 11 def xsl @xsl end |
Instance Method Details
#to_webpage ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/tagcloudbase.rb', line 29 def to_webpage() lib = File.dirname(__FILE__) xsl = open(lib + '/tagcloud.xsl','UserAgent' => 'TagCloudBase').read css = open(lib + '/tagcloud.css','UserAgent' => 'TagCloudBase').read html = Rexslt.new(@xsl || xsl, @to_dynarex.to_xml).to_s return {html: html, css: css} end |