Class: DamerauLevenshtein::Differ
- Inherits:
-
Object
- Object
- DamerauLevenshtein::Differ
- 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
-
#format ⇒ Object
Returns the value of attribute format.
Instance Method Summary collapse
-
#initialize ⇒ Differ
constructor
A new instance of Differ.
- #run(str1, str2) ⇒ Object
Constructor Details
#initialize ⇒ Differ
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
#format ⇒ Object
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 |