Module: SashimiTanpopo::DiffHelper

Defined in:
lib/sashimi_tanpopo/diff_helper.rb

Class Method Summary collapse

Class Method Details

.generate_diff(str1, str2, is_colored:) ⇒ String

Generate diff between 2 strings

Parameters:

  • str1 (String)
  • str2 (String)
  • is_colored (Boolean)

Returns:

  • (String)


12
13
14
15
# File 'lib/sashimi_tanpopo/diff_helper.rb', line 12

def self.generate_diff(str1, str2, is_colored:)
  format = is_colored ? :color : :text
  Diffy::Diff.new(str1, str2, context: 3).to_s(format)
end