Sha256: 225a90924043bfdb7ac7dc572cc1439be93c72ff4cc0cede512c185574f4be05

Contents?: true

Size: 356 Bytes

Versions: 1

Compression:

Stored size: 356 Bytes

Contents

module SmartAleck
  class CategoryIndexer
    attr_reader :category_hash

    def self.index(categories)
      new(categories).category_hash
    end

    def initialize(categories)
      @category_hash =
        categories.map {|category|
          2 ** (category.respond_to?(:id) ? category.id : category).to_i
        }.inject(:|).to_i
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_aleck-0.0.1 lib/smart_aleck/category_indexer.rb