module Prettys::Matcher

Public Class Methods

marked_strings(string, pattern) click to toggle source
# File lib/matcher.rb, line 4
def Matcher.marked_strings(string, pattern)
  matched =  string.scan(pattern).map { |s| { string: s, marked: true } }
  not_matched = string.split(pattern).map { |s| { string: s, marked: false } }
  if (string.match(pattern).begin(0))
    not_matched.zip(matched)
  else
    matched.zip(not_matched)
  end.flatten.compact
end