Sha256: 8b1cd6a0fa310ade861547ebe69f3954af59c9e6de5387c74637b640804c20fe
Contents?: true
Size: 845 Bytes
Versions: 9
Compression:
Stored size: 845 Bytes
Contents
require 'cgi' module Seahorse module Util class << self # @api private def irregular_inflections(hash) @irregular_inflections.update(hash) @irregular_regex = Regexp.new(@irregular_inflections.keys.join('|')) end # @param [String] string # @return [String] Returns the underscored version of the given string. def underscore(string) string. gsub(@irregular_regex) { |word| '_' + @irregular_inflections[word] }. gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). scan(/[a-z0-9]+|\d+|[A-Z0-9]+[a-z]*/). join('_').downcase end def uri_escape(string) CGI::escape(string.encode('UTF-8')).gsub('+', '%20').gsub('%7E', '~') end end @irregular_inflections = {} irregular_inflections('ETag' => 'etag') end end
Version data entries
9 entries across 9 versions & 1 rubygems