Class: CDMDEXER::RegexFilterCallback
- Inherits:
-
Object
- Object
- CDMDEXER::RegexFilterCallback
- Defined in:
- lib/cdmdexer/regex_filter_callback.rb
Overview
Search an OAI ListSets field using a regular expression
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#inclusive ⇒ Object
readonly
Returns the value of attribute inclusive.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(field: 'setName', pattern: /.*/, inclusive: true) ⇒ RegexFilterCallback
constructor
A new instance of RegexFilterCallback.
- #matches?(set) ⇒ Boolean
- #valid?(set: {}) ⇒ Boolean
Constructor Details
#initialize(field: 'setName', pattern: /.*/, inclusive: true) ⇒ RegexFilterCallback
Returns a new instance of RegexFilterCallback.
5 6 7 8 9 |
# File 'lib/cdmdexer/regex_filter_callback.rb', line 5 def initialize(field: 'setName', pattern: /.*/, inclusive: true) @field = field @pattern = pattern @inclusive = inclusive end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
4 5 6 |
# File 'lib/cdmdexer/regex_filter_callback.rb', line 4 def field @field end |
#inclusive ⇒ Object (readonly)
Returns the value of attribute inclusive.
4 5 6 |
# File 'lib/cdmdexer/regex_filter_callback.rb', line 4 def inclusive @inclusive end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
4 5 6 |
# File 'lib/cdmdexer/regex_filter_callback.rb', line 4 def pattern @pattern end |
Instance Method Details
#matches?(set) ⇒ Boolean
15 16 17 |
# File 'lib/cdmdexer/regex_filter_callback.rb', line 15 def matches?(set) pattern.match?(set[field]) end |
#valid?(set: {}) ⇒ Boolean
11 12 13 |
# File 'lib/cdmdexer/regex_filter_callback.rb', line 11 def valid?(set: {}) inclusive ? matches?(set) : !matches?(set) end |