class Amatch::Hamming
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.
Public Class Methods
Creates a new Amatch::Hamming
instance from pattern
.
static VALUE rb_Hamming_initialize(VALUE self, VALUE pattern) { GET_STRUCT(General) General_pattern_set(amatch, pattern); return self; }
Public Instance Methods
Uses this Amatch::Hamming
instance to match Amatch::Hamming#pattern
against strings
, that is compute the hamming distance between pattern
and strings
. strings
has to be either a String
or an Array of Strings. The returned results
is either a Fixnum or an Array of Fixnums respectively.
static VALUE rb_Hamming_match(VALUE self, VALUE strings) { GET_STRUCT(General) return General_iterate_strings(amatch, strings, Hamming_match); }
Returns the current pattern string of this Amatch::Sellers
instance.
Sets the current pattern string of this Amatch::Sellers
instance to pattern
.
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
is either a Fixnum or an Array of Fixnums respectively.
static VALUE rb_Hamming_similar(VALUE self, VALUE strings) { GET_STRUCT(General) return General_iterate_strings(amatch, strings, Hamming_similar); }