Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/templates/string_extensions.rb

Instance Method Summary collapse

Instance Method Details

#capitalize_wordsObject



3
4
5
# File 'lib/generators/templates/string_extensions.rb', line 3

def capitalize_words
 return self.gsub(/\w+/u) { |word| word.capitalize } #gsub(/^[a-z]|\s+[a-z]/) { |a| a.upcase }
end

#escape_filenameObject

Turns a string like “Devil’s Cave.xml” into “Devil's\ Cave.xml”, i.e. escapes spaces and these: ‘&



9
10
11
# File 'lib/generators/templates/string_extensions.rb', line 9

def escape_filename
  self.split("'").join("\\'").gsub(/(\s)/, '\\\\\1').gsub("&", '\\\\&')
end