Class: FilterRename::Filters::SetWhen

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

#current_target, #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



903
904
905
# File 'lib/filter_rename/filters.rb', line 903

def self.hint
  "Set the current or given TARGET to TEXT when REGEX is matched"
end

.paramsObject



907
908
909
# File 'lib/filter_rename/filters.rb', line 907

def self.params
  "REGEX,TEXT[,TARGET]"
end

Instance Method Details

#filter(params) ⇒ Object



911
912
913
914
915
# File 'lib/filter_rename/filters.rb', line 911

def filter(params)
  target = params[-1] if params.length.odd?
  set_string(params[1], target) if get_string =~ Regexp.new(params[0], get_config(:ignore_case).to_boolean)
  super(get_string)
end