Module: TieredCategoryExpressions::Generator
- Defined in:
- lib/tiered_category_expressions/generator.rb
Class Method Summary collapse
-
.call(category, strict: false) ⇒ Expression?
Generates a basic TCE that matches the given category.
Class Method Details
.call(category, strict: false) ⇒ Expression?
Generates a basic TCE that matches the given category. Returns nil if no valid TCE can be generated.
18 19 20 21 22 23 24 25 26 |
# File 'lib/tiered_category_expressions/generator.rb', line 18 def call(category, strict: false) return if category.empty? tiers = category.map { |t| sanitize_name(t) or return nil } expression = tiers.join(">") expression << "." if strict TieredCategoryExpressions::TCE(expression) end |