Class: ActsAsIndexed::TokenNormalizer
- Inherits:
-
Object
- Object
- ActsAsIndexed::TokenNormalizer
- Defined in:
- lib/acts_as_indexed/token_normalizer.rb
Class Method Summary collapse
-
.process(arr, options = {}) ⇒ Object
Takes an array of tokens.
Class Method Details
.process(arr, options = {}) ⇒ Object
Takes an array of tokens.
-
Downcases the tokens when :normalize_case option is passed.
-
Removes tokens of :min_token_length when option is passed.
Returns the resulting array of tokens.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/acts_as_indexed/token_normalizer.rb', line 8 def self.process(arr, ={}) if [:normalize_case] arr = arr.map{ |t| t.downcase } end if [:min_token_length] arr = arr.reject{ |w| w.size < [:min_token_length] } end arr end |