module Mexico::Util
This module contains various helper methods.
Constants
- UMLAUTS
A list of umlauts and other special characters that are word characters in German.
Public Class Methods
strip_quotes(string)
click to toggle source
Simple helper that strips away double quotes around a string. @param string [String] The string to be unquoted. @return [String] The unquoted string.
# File lib/mexico/util.rb, line 34 def self.strip_quotes(string) return string.gsub(/^"/, '').gsub(/"$/, '') end
to_xml_id(string)
click to toggle source
Helper method that takes a name and sanitizes it for use as an XML/FiESTA id. @param string [String] The string to be converted to an ID. @return [String] The resulting ID.
# File lib/mexico/util.rb, line 41 def self.to_xml_id(string) return nil if string.nil? # @todo auto-assign IDs result = string.downcase UMLAUTS.each_pair do |u,v| result.gsub!(/#{u}/, v) end result.gsub!(/[^\w\d]/, '_') return result.gsub(/_+/, '_') end