module Komonjo::Model::Filter::Base

Public Instance Methods

match(text) click to toggle source
# File lib/komonjo/models/filters/base.rb, line 5
def match(text)
  return false unless text
  text.match(pattern)
end
parse(text) click to toggle source
# File lib/komonjo/models/filters/base.rb, line 10
def parse(text)
  m = text.match(pattern)
  if text.index(pattern) == 0
    _, b = text.split(pattern, 2)
    return [
      { text: m[0], matched: true },
      { text: b, matched: false },
    ].delete_if { |e| e[:text].nil? || e[:text] == "" }
  end
  a, c = text.split(pattern, 2)
  return [
    { text: a, matched: false },
    { text: m[0], matched: true },
    { text: c, matched: false },
  ].delete_if { |e| e[:text].nil? || e[:text] == "" }
end
pattern() click to toggle source
# File lib/komonjo/models/filters/base.rb, line 27
def pattern
  //
end