class FilterRename::FilterBase

Public Class Methods

new(obj, options) click to toggle source
Calls superclass method
# File lib/filter_rename/filter_base.rb, line 42
def initialize(obj, options)
  super obj
  @dest = obj # useful for macros
  @cfg = options[:cfg]
  @words = options[:words]
end

Public Instance Methods

filter(value) click to toggle source
# File lib/filter_rename/filter_base.rb, line 65
def filter(value)
  set_string value
end
get_config(name) click to toggle source
# File lib/filter_rename/filter_base.rb, line 59
def get_config(name)
  raise InvalidFilterSetting, name unless @cfg.instance_variables.include?("@#{name}".to_sym)

  @cfg.instance_variable_get '@' + name.to_s
end
get_string(target = nil) click to toggle source
Calls superclass method
# File lib/filter_rename/filter_base.rb, line 77
def get_string(target = nil)
  if target.nil?
    super @cfg.target
  else
    super target
  end
end
get_words(name, section, idx = nil) click to toggle source
# File lib/filter_rename/filter_base.rb, line 49
def get_words(name, section, idx = nil)
  @words.get_words name, section, idx
end
match?(mask) click to toggle source
# File lib/filter_rename/filter_base.rb, line 85
def match?(mask)
  get_string =~ Regexp.new(mask)
end
set_config(name, value) click to toggle source
# File lib/filter_rename/filter_base.rb, line 53
def set_config(name, value)
  raise InvalidFilterSetting, name unless @cfg.instance_variables.include?("@#{name}".to_sym)

  @cfg.instance_variable_set ('@' + name.to_s), value
end
set_string(value, target = nil) click to toggle source
Calls superclass method
# File lib/filter_rename/filter_base.rb, line 69
def set_string(value, target = nil)
  if target.nil?
    super @cfg.target, value
  else
    super target, value
  end
end
wrap_regex(str) click to toggle source
# File lib/filter_rename/filter_base.rb, line 89
def wrap_regex(str)
  str = "(#{str})" unless str =~ /\(.*\)/
  str
end