Sha256: 1e92a09d091d21f18aab28acf7c174b1f31e6e5c3394ace27b750a8755b28316
Contents?: true
Size: 509 Bytes
Versions: 3
Compression:
Stored size: 509 Bytes
Contents
# String class class String def normalize_attribute gsub(/^.*::/, '') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .downcase end end # Hash class class Hash def normalize h = {} each_pair do |k, v| attr = k.to_s.normalize_attribute case v when Hash h[attr] = v.normalize when Array h[attr] = v.map { |o| o.is_a?(Hash) ? o.normalize : o } else h[attr] = v end end h end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grooveshark-0.2.14 | lib/grooveshark/utils.rb |
grooveshark-0.2.13 | lib/grooveshark/utils.rb |
grooveshark-0.2.12 | lib/grooveshark/utils.rb |