Module: Mexico::Util
- Defined in:
- lib/mexico/util.rb
Overview
This module contains various helper methods.
Defined Under Namespace
Modules: FancyContainer Classes: FancyWriter
Constant Summary collapse
- UMLAUTS =
A list of umlauts and other special characters that are word characters in German.
{ "ä" => "ae", "ö" => "oe", "ü" => "ue", "ß" => "ss" }
Class Method Summary collapse
-
.strip_quotes(string) ⇒ String
Simple helper that strips away double quotes around a string.
-
.to_xml_id(string) ⇒ String
Helper method that takes a name and sanitizes it for use as an XML/FiESTA id.
Class Method Details
.strip_quotes(string) ⇒ String
Simple helper that strips away double quotes around a string.
34 35 36 |
# File 'lib/mexico/util.rb', line 34 def self.strip_quotes(string) return string.gsub(/^"/, '').gsub(/"$/, '') end |
.to_xml_id(string) ⇒ String
Helper method that takes a name and sanitizes it for use as an XML/FiESTA id.
41 42 43 44 45 46 47 48 49 |
# 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 |