@@ -1218,7 +1218,44 @@ def instance(data = $stdout, **options)
12181218 # * Argument +in_string_or_io+ must be a \String or an \IO stream.
12191219 # * Argument +out_string_or_io+ must be a \String or an \IO stream.
12201220 # * Arguments <tt>**options</tt> must be keyword options.
1221- # See {Options for Parsing}[#class-CSV-label-Options+for+Parsing].
1221+ #
1222+ # - Each option defined as an {option for parsing}[#class-CSV-label-Options+for+Parsing]
1223+ # is used for parsing the filter input.
1224+ # - Each option defined as an {option for generating}[#class-CSV-label-Options+for+Generating]
1225+ # is used for generator the filter input.
1226+ #
1227+ # However, there are three options that may be used for both parsing and generating:
1228+ # +col_sep+, +quote_char+, and +row_sep+.
1229+ #
1230+ # Therefore for method +filter+ (and method +filter+ only),
1231+ # there are special options that allow these parsing and generating options
1232+ # to be specified separately:
1233+ #
1234+ # - Options +input_col_sep+ and +output_col_sep+
1235+ # (and their aliases +in_col_sep+ and +out_col_sep+)
1236+ # specify the column separators for parsing and generating.
1237+ # - Options +input_quote_char+ and +output_quote_char+
1238+ # (and their aliases +in_quote_char+ and +out_quote_char+)
1239+ # specify the quote characters for parsing and generting.
1240+ # - Options +input_row_sep+ and +output_row_sep+
1241+ # (and their aliases +in_row_sep+ and +out_row_sep+)
1242+ # specify the row separators for parsing and generating.
1243+ #
1244+ # Example options (for column separators):
1245+ #
1246+ # CSV.filter # Default for both parsing and generating.
1247+ # CSV.filter(in_col_sep: ';') # ';' for parsing, default for generating.
1248+ # CSV.filter(out_col_sep: '|') # Default for parsing, '|' for generating.
1249+ # CSV.filter(in_col_sep: ';', out_col_sep: '|') # ';' for parsing, '|' for generating.
1250+ #
1251+ # Note that for a special option (e.g., +input_col_sep+)
1252+ # and its corresponding "regular" option (e.g., +col_sep+),
1253+ # the two are mutually overriding.
1254+ #
1255+ # Another example (possibly surprising):
1256+ #
1257+ # CSV.filter(in_col_sep: ';', col_sep: '|') # '|' for both parsing(!) and generating.
1258+ #
12221259 def filter ( input = nil , output = nil , **options )
12231260 # parse options for input, output, or both
12241261 in_options , out_options = Hash . new , { row_sep : InputRecordSeparator . value }
0 commit comments