Class: Text::Gen::Filter::Match
- Defined in:
- lib/text/gen/filter/match.rb
Overview
Match returns ‘nil` unless the result metadata includes the given pattern.
Instance Method Summary collapse
Methods inherited from Base
#component_key, filter_key, filter_name, #initialize, #key, #to_s, #type, #value
Constructor Details
This class inherits a constructor from Text::Gen::Filter::Base
Instance Method Details
#result(context, result) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/text/gen/filter/match.rb', line 9 def result(context, result) return result if @depth && context.depth != @depth return nil if result.nil? return result if value == "*" && result..key?(key) return result if key == "*" && result..values.any? { |arr| arr.include?(value) } return result if result.[key]&.include?(value) nil end |