Class: LooseTightDictionary::T
- Inherits:
-
Object
- Object
- LooseTightDictionary::T
- Defined in:
- lib/loose_tight_dictionary.rb
Instance Attribute Summary collapse
-
#str ⇒ Object
readonly
Returns the value of attribute str.
-
#tightened_str ⇒ Object
readonly
Returns the value of attribute tightened_str.
Instance Method Summary collapse
-
#initialize(str, tightened_str) ⇒ T
constructor
A new instance of T.
- #prefix_and_score(other) ⇒ Object
- #tightened? ⇒ Boolean
Constructor Details
#initialize(str, tightened_str) ⇒ T
Returns a new instance of T.
23 24 25 26 |
# File 'lib/loose_tight_dictionary.rb', line 23 def initialize(str, tightened_str) @str = str @tightened_str = tightened_str end |
Instance Attribute Details
#str ⇒ Object (readonly)
Returns the value of attribute str.
22 23 24 |
# File 'lib/loose_tight_dictionary.rb', line 22 def str @str end |
#tightened_str ⇒ Object (readonly)
Returns the value of attribute tightened_str.
22 23 24 |
# File 'lib/loose_tight_dictionary.rb', line 22 def tightened_str @tightened_str end |
Instance Method Details
#prefix_and_score(other) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/loose_tight_dictionary.rb', line 32 def prefix_and_score(other) prefix = [ tightened_str.length, other.tightened_str.length ].min if tightened? and other.tightened? score = if prefix tightened_str.first(prefix).pair_distance_similar other.tightened_str.first(prefix) else tightened_str.pair_distance_similar other.tightened_str end [ prefix, score ] end |
#tightened? ⇒ Boolean
28 29 30 |
# File 'lib/loose_tight_dictionary.rb', line 28 def tightened? str != tightened_str end |