module Tk::CoreExtensions::Regexp

Public Instance Methods

to_tcl() click to toggle source
# File lib/ffi-tk/core_extensions.rb, line 84
def to_tcl
  embed = []
  embed << 'i' if options & ::Regexp::IGNORECASE != 0
  embed << 'x' if options & ::Regexp::EXTENDED != 0
  embed << 'n' if options & ::Regexp::MULTILINE != 0

  if embed.empty?
    pattern = source
  else
    pattern = "(?#{embed.join})#{source}"
  end

  TclString.new(%({#{pattern.gsub(/([^\\])(?=[{}])/, '\1\\\\\2')}}))
end