class Vte::Regex

Public Class Methods

new(pattern, compile_flags, options) click to toggle source
# File lib/vte3/regex.rb, line 21
def initialize(pattern, compile_flags, options)
  flags = parse_compile_flags(compile_flags)
  if options[:for_match]
    initialize_new_for_match(pattern, pattern.bytesize, flags)
  elsif options[:for_search]
    initialize_new_for_search(pattern, pattern.bytesize, flags)
  else
    raise(ArgumentError,
          "must specify usage :for_match or :for_search: #{options.inspect}")
  end
end
Also aliased as: initialize_raw

Public Instance Methods

initialize_raw(pattern, compile_flags, options)
Alias for: new

Private Instance Methods

parse_compile_flags(compile_flags) click to toggle source
# File lib/vte3/regex.rb, line 34
def parse_compile_flags(compile_flags)
  return compile_flags if compile_flags.is_a?(Integer)
  return compile_flags unless compile_flags.is_a?(Array)

  flags = 0
  compile_flags.each do |flag|
    flags |= GLib::RegexCompileFlags.new(flag).to_i
  end
  flags
end