Class: JSE::RegexpFilter
- Inherits:
-
Object
- Object
- JSE::RegexpFilter
- Defined in:
- lib/jse/regexp_filter.rb
Instance Method Summary collapse
-
#initialize(field, regexp, options = []) ⇒ RegexpFilter
constructor
A new instance of RegexpFilter.
- #match?(json) ⇒ Boolean
Constructor Details
#initialize(field, regexp, options = []) ⇒ RegexpFilter
Returns a new instance of RegexpFilter.
3 4 5 6 7 |
# File 'lib/jse/regexp_filter.rb', line 3 def initialize(field, regexp, = []) @field = field # regexp should have leading and trailing '/' @regexp = Regexp.new(regexp[1,regexp.size-2], ) end |
Instance Method Details
#match?(json) ⇒ Boolean
9 10 11 |
# File 'lib/jse/regexp_filter.rb', line 9 def match?(json) json[@field] =~ @regexp end |