class MemDB::Field::Pattern::Pattern
Constants
- WILDCARD
Public Class Methods
new(source, rx_engine:)
click to toggle source
# File lib/mem_db/field/pattern.rb, line 58 def initialize(source, rx_engine:) wildcard_count = source.count(WILDCARD) @pat = if wildcard_count.zero? Exact.new(source) elsif wildcard_count > 1 Rx.new(source, rx_engine) elsif source.end_with?(WILDCARD) Prefix.new(source[0..-2]) elsif source.start_with?(WILDCARD) Suffix.new(source[1..-1]) else # rubocop:disable Lint/DuplicateBranch Rx.new(source, rx_engine) end end
Public Instance Methods
match?(str)
click to toggle source
# File lib/mem_db/field/pattern.rb, line 74 def match?(str) @pat.match?(str) end