Sha256: 01d840e4b8ba3dea1ffaaf5fe1f988aa67ae7cec019367b81848f5372afb6534

Contents?: true

Size: 416 Bytes

Versions: 6

Compression:

Stored size: 416 Bytes

Contents

require 'rabbit/utils'

module Rabbit
  class Searcher
    def initialize(canvas)
      @canvas = canvas
    end

    def regexp(text)
      unless text == @text
        @text = text
        @regexp = nil
      end
      @regexp ||= internal_regexp
    end

    private
    def internal_regexp
      begin
        /#{@text}/iu
      rescue RegexpError
        /#{Regexp.escape(@text)}/iu
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rabbit-3.0.3 lib/rabbit/searcher.rb
rabbit-3.0.2 lib/rabbit/searcher.rb
rabbit-3.0.1 lib/rabbit/searcher.rb
rabbit-3.0.0 lib/rabbit/searcher.rb
rabbit-2.2.1 lib/rabbit/searcher.rb
rabbit-2.2.0 lib/rabbit/searcher.rb