module BoyerMoore
Constants
- VERSION
Public Class Methods
search(haystack, needle_string)
click to toggle source
# File lib/boyer_moore.rb, line 4 def self.search(haystack, needle_string) needle = Needle.new(needle_string) haystack_index = 0 while haystack_index <= haystack.size - needle.size if skip_by = needle.match_or_skip_by(haystack, haystack_index) haystack_index += skip_by else break haystack_index # Found a match at haystack_index! end end end