Class: DataFilter::PrefixFilter
- Inherits:
-
Object
- Object
- DataFilter::PrefixFilter
- Defined in:
- lib/data_filter/prefix_filter.rb
Overview
Used to filter a data item by a prefix by seeing if the data field value starts with the prefix
Instance Method Summary collapse
-
#call(item) ⇒ Object?
Filters the item.
-
#initialize(field_sym, prefix) ⇒ PrefixFilter
constructor
A new instance of PrefixFilter.
Constructor Details
#initialize(field_sym, prefix) ⇒ PrefixFilter
Returns a new instance of PrefixFilter.
15 16 17 18 |
# File 'lib/data_filter/prefix_filter.rb', line 15 def initialize(field_sym, prefix) @field_sym = field_sym @prefix = prefix end |
Instance Method Details
#call(item) ⇒ Object?
Filters the item
24 25 26 27 28 29 |
# File 'lib/data_filter/prefix_filter.rb', line 24 def call(item) if item.respond_to?(@field_sym) && starts_with?(item.public_send(@field_sym), @prefix) item end end |