Class: Ace::Review::Atoms::PriorityFilter
- Inherits:
-
Object
- Object
- Ace::Review::Atoms::PriorityFilter
- Defined in:
- lib/ace/review/atoms/priority_filter.rb
Overview
Filters feedback items by priority level with optional range support.
Supports exact matching (“high”) and inclusive range matching (“high+”). Range matching includes the specified priority and all higher priorities.
Priority hierarchy (highest to lowest): critical > high > medium > low
Constant Summary collapse
- PRIORITY_ORDER =
Priority levels in descending order (highest first)
{ "critical" => 4, "high" => 3, "medium" => 2, "low" => 1 }.freeze
- VALID_PRIORITIES =
PRIORITY_ORDER.keys.freeze
Class Method Summary collapse
-
.matches?(item_priority, filter_string) ⇒ Boolean
Check if an item priority matches a filter string.
-
.parse(filter_string) ⇒ Hash?
Parse a priority filter string into its components.
Class Method Details
.matches?(item_priority, filter_string) ⇒ Boolean
Check if an item priority matches a filter string
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ace/review/atoms/priority_filter.rb', line 92 def self.matches?(item_priority, filter_string) return false if item_priority.nil? || filter_string.nil? parsed = parse(filter_string) return false if parsed.nil? item_level = PRIORITY_ORDER[item_priority] filter_level = PRIORITY_ORDER[parsed[:priority]] # Unknown item priority doesn't match return false if item_level.nil? if parsed[:inclusive] # Range match: item priority must be >= filter priority item_level >= filter_level else # Exact match item_priority == parsed[:priority] end end |
.parse(filter_string) ⇒ Hash?
Parse a priority filter string into its components
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ace/review/atoms/priority_filter.rb', line 57 def self.parse(filter_string) return nil if filter_string.nil? || filter_string.empty? # Check for + suffix (inclusive range) inclusive = filter_string.end_with?("+") priority = inclusive ? filter_string.chomp("+") : filter_string # Validate priority return nil unless VALID_PRIORITIES.include?(priority) {priority: priority, inclusive: inclusive} end |