Class: TintedTags::TagTinter

Inherits:
Object
  • Object
show all
Defined in:
lib/tinted_tags/tag_tinter.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass, opts = {}) ⇒ TagTinter

Returns a new instance of TagTinter.



5
6
7
8
9
10
# File 'lib/tinted_tags/tag_tinter.rb', line 5

def initialize(klass, opts={})
  @base = opts[:base]
  @tint = opts[:tint]
  @strategy = opts[:strategy]
  @klass = klass
end

Instance Method Details

#update_tintsObject



12
13
14
15
16
17
18
# File 'lib/tinted_tags/tag_tinter.rb', line 12

def update_tints
  @klass.tag_counts_on(:tags).each do |tag|
    percent = percentage(tag.count)
    tag.tint = evaluate("mix(#{@base}, #{@tint}, #{percent})")
    tag.save
  end
end