Sha256: 06c654a0f734213af612faf3f5e68a0a9c1ed9c8d5d48b8d47ae0466b75128ad
Contents?: true
Size: 678 Bytes
Versions: 1
Compression:
Stored size: 678 Bytes
Contents
module Geokit module Inflector require 'cgi' extend self def titleize(word) humanize(underscore(word)).gsub(/\b([a-z])/u) { $1.capitalize } end def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/u, '\1_\2'). gsub(/([a-z\d])([A-Z])/u, '\1_\2'). tr('-', '_'). downcase end def humanize(lower_case_and_underscored_word) lower_case_and_underscored_word.to_s.gsub(/_id$/, '').gsub(/_/, ' ').capitalize end def url_escape(s) CGI.escape(s) end def camelize(str) str.split('_').map {|w| w.capitalize}.join end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geokit-1.9.0 | lib/geokit/inflectors.rb |