Class: RuboCop::StringUtil::Jaro
- Inherits:
-
Object
- Object
- RuboCop::StringUtil::Jaro
- Defined in:
- lib/rubocop/string_util.rb
Overview
This class computes Jaro distance, which is a measure of similarity between two strings.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#longer ⇒ Object
readonly
Returns the value of attribute longer.
-
#shorter ⇒ Object
readonly
Returns the value of attribute shorter.
Class Method Summary collapse
Instance Method Summary collapse
- #distance ⇒ Object
-
#initialize(a, b) ⇒ Jaro
constructor
A new instance of Jaro.
Constructor Details
#initialize(a, b) ⇒ Jaro
Returns a new instance of Jaro.
21 22 23 24 25 26 27 |
# File 'lib/rubocop/string_util.rb', line 21 def initialize(a, b) if a.size < b.size @shorter, @longer = a, b else @shorter, @longer = b, a end end |
Instance Attribute Details
#longer ⇒ Object (readonly)
Returns the value of attribute longer.
15 16 17 |
# File 'lib/rubocop/string_util.rb', line 15 def longer @longer end |
#shorter ⇒ Object (readonly)
Returns the value of attribute shorter.
15 16 17 |
# File 'lib/rubocop/string_util.rb', line 15 def shorter @shorter end |
Class Method Details
.distance(*args) ⇒ Object
17 18 19 |
# File 'lib/rubocop/string_util.rb', line 17 def self.distance(*args) new(*args).distance end |
Instance Method Details
#distance ⇒ Object
29 30 31 |
# File 'lib/rubocop/string_util.rb', line 29 def distance @distance ||= compute_distance end |