Class: FixedWidthColumns::PreProcessor
- Inherits:
-
Aduki::Initializable
- Object
- Aduki::Initializable
- FixedWidthColumns::PreProcessor
- Defined in:
- lib/fixed_width_columns/preprocessor.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#library ⇒ Object
Returns the value of attribute library.
-
#transform ⇒ Object
Returns the value of attribute transform.
Instance Method Summary collapse
- #apply(items) ⇒ Object
- #do_filter(items) ⇒ Object
- #do_transform(items) ⇒ Object
- #filter_sym ⇒ Object
- #maybe_transform(items) ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#filter ⇒ Object
Returns the value of attribute filter.
5 6 7 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 5 def filter @filter end |
#library ⇒ Object
Returns the value of attribute library.
5 6 7 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 5 def library @library end |
#transform ⇒ Object
Returns the value of attribute transform.
5 6 7 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 5 def transform @transform end |
Instance Method Details
#apply(items) ⇒ Object
11 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 11 def apply items ; maybe_transform do_filter items ; end |
#do_filter(items) ⇒ Object
8 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 8 def do_filter items ; items.select &(FixedWidthColumns::FILTERS[filter_sym]) ; end |
#do_transform(items) ⇒ Object
10 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 10 def do_transform items ; FixedWidthColumns::TRANSFORMS[@transform.to_sym].call items ; end |
#filter_sym ⇒ Object
7 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 7 def filter_sym ; (@filter || "true").to_sym ; end |
#maybe_transform(items) ⇒ Object
9 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 9 def maybe_transform items ; @transform ? do_transform(items) : items ; end |
#to_s ⇒ Object
12 |
# File 'lib/fixed_width_columns/preprocessor.rb', line 12 def to_s ; "filter:#{@filter};transform:#{@transform}" ; end |