Commit 6cfe41d5 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Simplify pattern lexeme fabrication and matcher

parent 2929a2de53a6
...@@ -6,7 +6,7 @@ module Lexeme ...@@ -6,7 +6,7 @@ module Lexeme
require_dependency 're2' require_dependency 're2'
class Pattern < Lexeme::Value class Pattern < Lexeme::Value
PATTERN = %r{^(?<regexp>/.+/[ismU]*)$}.freeze PATTERN = %r{^/.+/[ismU]*$}.freeze
def initialize(regexp) def initialize(regexp)
@value = regexp @value = regexp
...@@ -23,7 +23,7 @@ def evaluate(variables = {}) ...@@ -23,7 +23,7 @@ def evaluate(variables = {})
end end
def self.build(string) def self.build(string)
new(string.match(PATTERN)[:regexp]) new(string)
end end
end end
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment