Class: AsciiDataTools::Filter::Diffing::DiffFormattingFilter
- Inherits:
-
FormattingFilter
- Object
- Filter
- FormattingFilter
- AsciiDataTools::Filter::Diffing::DiffFormattingFilter
- Defined in:
- lib/ascii-data-tools/filter/diffing.rb
Constant Summary collapse
- DIFF_DELIMITER =
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type_determiner) ⇒ DiffFormattingFilter
constructor
A new instance of DiffFormattingFilter.
- #write(*streams) ⇒ Object
Methods inherited from FormattingFilter
Methods inherited from Filter
Constructor Details
#initialize(type_determiner) ⇒ DiffFormattingFilter
Returns a new instance of DiffFormattingFilter.
9 10 11 12 13 14 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 9 def initialize(type_determiner) super(nil, type_determiner) def @formatter.formattable(record_type) record_type.extend(Formatting::UnnumberedFormatableType) unless record_type.instance_of?(Formatting::UnnumberedFormatableType) end end |
Class Method Details
.formattable(record_type) ⇒ Object
11 12 13 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 11 def @formatter.formattable(record_type) record_type.extend(Formatting::UnnumberedFormatableType) unless record_type.instance_of?(Formatting::UnnumberedFormatableType) end |
Instance Method Details
#write(*streams) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ascii-data-tools/filter/diffing.rb', line 16 def write(*streams) while upstream.has_records? difference = upstream.read difference.left_contents.each {|rec| streams[0] << filter(rec)} difference.right_contents.each {|rec| streams[1] << filter(rec)} if upstream.has_records? streams[0] << DIFF_DELIMITER streams[1] << DIFF_DELIMITER end end end |