Class: DamerauLevenshtein::Differ

Inherits:
Object
  • Object
show all
Defined in:
lib/damerau-levenshtein/differ.rb

Overview

Shows the difference between two strings in character by character resolution

Constant Summary collapse

FORMATS =
%i[raw tag].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDiffer

Returns a new instance of Differ.



10
11
12
13
# File 'lib/damerau-levenshtein/differ.rb', line 10

def initialize
  @format = :tag
  @matrix = []
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



8
9
10
# File 'lib/damerau-levenshtein/differ.rb', line 8

def format
  @format
end

Instance Method Details

#run(str1, str2) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/damerau-levenshtein/differ.rb', line 20

def run(str1, str2)
  @len1 = str1.size.freeze
  @len2 = str2.size.freeze
  prepare_matrix
  edit_distance(str1, str2)
  raw = trace_back
  formatter_factory.show(raw, str1, str2)
end