Module: Fixnames::Helpers

Included in:
Engine
Defined in:
lib/fixnames/helpers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) match_bracket_close



25
26
27
# File 'lib/fixnames/helpers.rb', line 25

def match_bracket_close
  "[#{Regexp.escape(option.bracket_characters_close)}]"
end

- (Object) match_bracket_open



21
22
23
# File 'lib/fixnames/helpers.rb', line 21

def match_bracket_open
  "[#{Regexp.escape(option.bracket_characters_open)}]"
end

- (Object) remove(re)



10
11
12
13
14
# File 'lib/fixnames/helpers.rb', line 10

def remove(re)
  re_str = bold "/#{re}/"
  debug "\t<expunge>  #{re_str}"
  fixed.gsub! Regexp.new(re), ''
end

- (Object) remove_bracket_characters_from(str)



37
38
39
# File 'lib/fixnames/helpers.rb', line 37

def remove_bracket_characters_from(str)
  str.gsub /(#{match_bracket_open}|#{match_bracket_close})/, ''
end

- (Object) remove_bracket_ranges(re)



33
34
35
# File 'lib/fixnames/helpers.rb', line 33

def remove_bracket_ranges(re)
  remove wrap_brackets(".*?#{re}.*?")
end

- (Object) replace(re, replacement)



3
4
5
6
7
8
# File 'lib/fixnames/helpers.rb', line 3

def replace(re, replacement)
  re_str = bold "/#{re}/"
  replacement_str = bold "\"#{replacement}\""
  debug "\t<replace>  #{re_str}  ->  #{replacement_str}"
  fixed.gsub! Regexp.new(re), replacement
end

- (Object) translate(src, dst)



16
17
18
19
# File 'lib/fixnames/helpers.rb', line 16

def translate(src, dst)
  debug "\t<translate>  #{bold src.inspect}  ->  #{bold dst.inspect}"
  fixed.tr! src, dst
end

- (Object) wrap_brackets(re)



29
30
31
# File 'lib/fixnames/helpers.rb', line 29

def wrap_brackets(re)
  "#{match_bracket_open}#{re}#{match_bracket_close}"
end