module Geokit::Inflector
Public Instance Methods
camelize(str)
click to toggle source
# File lib/geokit/inflectors.rb, line 27 def camelize(str) str.split('_').map(&:capitalize).join end
humanize(lower_case_and_underscored_word)
click to toggle source
# File lib/geokit/inflectors.rb, line 19 def humanize(lower_case_and_underscored_word) lower_case_and_underscored_word.to_s.gsub(/_id$/, '').gsub(/_/, ' ').capitalize end
titleize(word)
click to toggle source
# File lib/geokit/inflectors.rb, line 7 def titleize(word) humanize(underscore(word)).gsub(/\b([a-z])/u) { Regexp.last_match(1).capitalize } end
underscore(camel_cased_word)
click to toggle source
# File lib/geokit/inflectors.rb, line 11 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
url_escape(s)
click to toggle source
# File lib/geokit/inflectors.rb, line 23 def url_escape(s) CGI.escape(s) end