Class: Amatch::Hamming

Inherits:
Object
  • Object
show all
Defined in:
ext/amatch.c,
ext/amatch.c

Overview

This class computes the Hamming distance between two strings.

The Hamming distance between two strings is the number of characters, that
are different. Thus a hamming distance of 0 means an exact
match, a hamming distance of 1 means one character is different, and so on.
If one string is longer than the other string, the missing characters are
counted as different characters.

Instance Method Summary collapse

Constructor Details

#initializeObject

Instance Method Details

#matchObject

#patternObject

call-seq: pattern -> pattern string

Returns the current pattern string of this instance.

#pattern=Object

call-seq: pattern=(pattern)

Sets the current pattern string of this instance to pattern.

#similar(strings) ⇒ Object

Uses this Amatch::Hamming instance to match Amatch::Hamming#pattern against strings, and compute a Hamming distance metric number between 0.0 for very unsimilar strings and 1.0 for an exact match. strings has to be either a String or an Array of Strings. The returned results are either a Fixnum or an Array of Fixnums respectively.



1042
1043
1044
1045
1046
# File 'ext/amatch.c', line 1042

static VALUE rb_Hamming_similar(VALUE self, VALUE strings)
{                                                                            
    GET_STRUCT(General)
    return General_iterate_strings(amatch, strings, Hamming_similar);
}