class String

Public Instance Methods

ext(suffix) click to toggle source

Return a string with the new suffix. If the suffix is illegal, nil is returned. Be careful that the suffix begins with a period.

It redefines itself if it has been defined. For example, rake defines ext method.

# File lib/lbt/utils.rb, line 15
def ext(suffix)
  return nil unless suffix.is_a?(String) && /^\.\w+$/ =~ suffix
  s = File.extname(self)
  self.sub(/#{s}$/, suffix)
end
remove_tex_comment() click to toggle source

Remove verbatim environments and comments (including the following new line) from self (LaTeX source).

# File lib/lbt/utils.rb, line 7
def remove_tex_comment
  gsub(/\\begin\{verbatim\}.*\\end\{verbatim\}/m, '').gsub(/%.*\n/,'')
end