lib/metoffice_datapoint/mash.rb
def convert_key(key)
      case key
        when '$'
          'text'
        when 'D', 'Dm', 'F', 'FDm', 'FNm', 'G', 'Gm', 'Gn', 'H', 'Hm', 'Hn', 'Nm', 'P', 'Pp', 'PPd', 'PPn', 'S', 'T', 'U', 'V', 'W'
          key
        else
          key.to_s.strip.
              gsub('@', '').
              gsub(' ', '_').
              gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
              gsub(/([a-z\d])([A-Z])/,'\1_\2').
              tr("-", "_").
              squeeze("_").
              downcase
      end
    end
def convert_key(key)
      case key
        when '$'
          'text'
        when 'D', 'Dm', 'F', 'FDm', 'FNm', 'G', 'Gm', 'Gn', 'H', 'Hm', 'Hn', 'Nm', 'P', 'Pp', 'PPd', 'PPn', 'S', 'T', 'U', 'V', 'W'
          key
        else
          key.to_s.strip.
              gsub('@', '').
              gsub(' ', '_').
              gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
              gsub(/([a-z\d])([A-Z])/,'\1_\2').
              tr("-", "_").
              squeeze("_").
              downcase
      end
    end
Protected: Convert keys to a more rubyesque style (underscroce, lowercase). Excludes keys with specific meanings.
 Overloads the the convert_key Mash method.

 key - String, possibly containing CamelCase words and/or dash-es

 Examples:
   convert_key("CamelCase") => camel_case
   convert_key("dash-es") => dash_es

 Returns String based on lowercase letters and an underscore for separation.