Class: FilterRename::Filters::Wrap

Inherits:
FilterRename::FilterBase show all
Defined in:
lib/filter_rename/filters.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FilterRename::FilterBase

#get_config, #get_string, #get_words, #initialize, #match?, #set_config, #set_string, #wrap_regex

Constructor Details

This class inherits a constructor from FilterRename::FilterBase

Class Method Details

.hintObject



631
# File 'lib/filter_rename/filters.rb', line 631

def self.hint; 'Wrap the text matching REGEX with SEPARATOR1 and SEPARATOR2'; end

.paramsObject



632
# File 'lib/filter_rename/filters.rb', line 632

def self.params; 'REGEX,SEPARATOR1,SEPARATOR2'; end

Instance Method Details

#filter(params) ⇒ Object



634
635
636
637
638
# File 'lib/filter_rename/filters.rb', line 634

def filter(params)
  params[0] = "(#{params[0]})" unless params[0] =~ /[()]+/
  regexp = Regexp.new("(#{params[0]})", get_config(:ignore_case).to_boolean)
  super get_string.gsub(regexp, "#{params[1]}\\1#{params[2]}")
end