Class: SmartAleck::CategoryIndexer
- Inherits:
-
Object
- Object
- SmartAleck::CategoryIndexer
- Defined in:
- lib/smart_aleck/category_indexer.rb
Instance Attribute Summary collapse
-
#category_hash ⇒ Object
readonly
Returns the value of attribute category_hash.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(categories) ⇒ CategoryIndexer
constructor
A new instance of CategoryIndexer.
Constructor Details
#initialize(categories) ⇒ CategoryIndexer
Returns a new instance of CategoryIndexer.
11 12 13 14 15 16 17 18 |
# File 'lib/smart_aleck/category_indexer.rb', line 11 def initialize(categories) @category_hash = Base58.encode( categories.map {|category| 2 ** (category.respond_to?(:id) ? category.id : category).to_i }.inject(:|).to_i ) end |
Instance Attribute Details
#category_hash ⇒ Object (readonly)
Returns the value of attribute category_hash.
5 6 7 |
# File 'lib/smart_aleck/category_indexer.rb', line 5 def category_hash @category_hash end |
Class Method Details
.index(categories) ⇒ Object
7 8 9 |
# File 'lib/smart_aleck/category_indexer.rb', line 7 def self.index(categories) new(categories).category_hash end |