Class: Sycsvpro::RowFilter
- Includes:
- Dsl
- Defined in:
- lib/sycsvpro/row_filter.rb
Overview
Filters rows based on provided patterns
Constant Summary
Constants included from Dsl
Instance Attribute Summary
Attributes inherited from Filter
#boolean_filter, #date_format, #filter, #pattern, #pivot, #types
Instance Method Summary collapse
-
#process(object, options = {}) ⇒ Object
Processes the filter on the given row.
Methods included from Dsl
#clean_up, #params, #rows, #split_by_comma_regex, #str2utf8, #unstring, #write_to
Methods inherited from Filter
#has_filter?, #initialize, #match_boolean_filter?, #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 22 |
# 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 = (filtered or match_boolean_filter?(object.split(';'))) filtered ? object : nil end |