Class: Sycsvpro::RowFilter
- Includes:
- Dsl
- Defined in:
- lib/sycsvpro/row_filter.rb
Overview
Filters rows based on provided patterns
Instance Attribute Summary
Attributes inherited from Filter
#date_format, #filter, #pattern, #pivot
Instance Method Summary collapse
-
#process(object, options = {}) ⇒ Object
Processes the filter on the given row.
Methods included from Dsl
Methods inherited from Filter
#has_filter?, #initialize, #method_missing, #pivot_each_column
Constructor Details
This class inherits a constructor from Sycsvpro::Filter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sycsvpro::Filter
Instance Method Details
#process(object, options = {}) ⇒ Object
Processes the filter on the given row
13 14 15 16 17 18 19 20 21 |
# File 'lib/sycsvpro/row_filter.rb', line 13 def process(object, ={}) object = unstring(object) return object unless has_filter? filtered = !filter.flatten.uniq.index([:row]).nil? pattern.each do |p| filtered = (filtered or !(object =~ Regexp.new(p)).nil?) end filtered ? object : nil end |