Class: JSE::RegexpFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/jse/regexp_filter.rb

Instance Method Summary collapse

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, options = [])
  @field = field
  # regexp should have leading and trailing '/'
  @regexp = Regexp.new(regexp[1,regexp.size-2], options)
end

Instance Method Details

#match?(json) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/jse/regexp_filter.rb', line 9

def match?(json)
  json[@field] =~ @regexp
end