Class: MigemoRegex::RegexEmacsRenderer

Inherits:
RegexRenderer show all
Defined in:
lib/migemo-regex.rb

Instance Attribute Summary

Attributes inherited from RegexRenderer

#with_paren

Instance Method Summary collapse

Methods inherited from RegexRenderer

#join_regexes, #render

Constructor Details

#initialize(regex, insertion) ⇒ RegexEmacsRenderer

Returns a new instance of RegexEmacsRenderer.



277
278
279
280
# File 'lib/migemo-regex.rb', line 277

def initialize (regex, insertion)
  super(regex, insertion)
  @meta = RegexEmacsMetachars.new
end

Instance Method Details

#escape_charclass(string) ⇒ Object



296
297
298
# File 'lib/migemo-regex.rb', line 296

def escape_charclass (string)
  string
end

#escape_string(string) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/migemo-regex.rb', line 282

def escape_string (string)
  str = Regexp.quote(string)
  str.gsub!(/\\\(/, "(")
  str.gsub!(/\\\)/, ")")
  str.gsub!(/\\\|/, "|")
  str.gsub!(/\\\</, "<")
  str.gsub!(/\\\>/, ">")
  str.gsub!(/\\\=/, "=")
  str.gsub!(/\\\'/, "'")
  str.gsub!(/\\\`/, "`")
  str.gsub!(/\\\{/, "{")
  str
end