Sha256: 947d26285f7dd6fb9bafcc4c512849816a988c6b597fa7fde1f0a8335460afe4

Contents?: true

Size: 397 Bytes

Versions: 1

Compression:

Stored size: 397 Bytes

Contents

# frozen_string_literal: true
class Arugula
  require 'arugula/version'

  autoload :Parser, 'arugula/parser'

  def initialize(pattern)
    @root = Parser.new(pattern).parse!
  end

  def match?(str)
    index = 0
    loop do
      match, = @root.match(str, index)
      return index if match
      index += 1
      return if index > str.size
    end
  end

  def to_s
    "/#{@root}/"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arugula-0.2.0 lib/arugula.rb