Class: Uniword::Diff::Formatter
- Inherits:
-
Object
- Object
- Uniword::Diff::Formatter
- Defined in:
- lib/uniword/diff/formatter.rb
Overview
Formats DiffResult for terminal and JSON output.
Instance Method Summary collapse
-
#json(result) ⇒ String
Format a DiffResult as JSON string.
-
#terminal(result, verbose: false) ⇒ String
Format a DiffResult for terminal display.
Instance Method Details
#json(result) ⇒ String
Format a DiffResult as JSON string.
20 21 22 |
# File 'lib/uniword/diff/formatter.rb', line 20 def json(result) result.to_json end |
#terminal(result, verbose: false) ⇒ String
Format a DiffResult for terminal display.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/uniword/diff/formatter.rb', line 29 def terminal(result, verbose: false) return "No differences found.\n" if result.empty? lines = [] lines << "Differences found:\n" lines << " #{result.summary}\n" if verbose lines.concat(format_text_changes(result.text_changes)) lines.concat(format_format_changes(result.format_changes)) lines.concat(format_structure(result.structure_changes)) lines.concat((result.)) lines.concat(format_styles(result.style_changes)) end lines.join end |