Geokit::Inflector

Public Instance Methods

camelize(str) click to toggle source
# File lib/geokit/inflectors.rb, line 33
def camelize(str)
  str.split('_').map {|w| w.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
snake_case(s) click to toggle source
# File lib/geokit/inflectors.rb, line 23
def snake_case(s)
  return s.downcase if s =~ /^[A-Z]+$/
  s.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/
  $+.downcase
end
titleize(word) click to toggle source
# File lib/geokit/inflectors.rb, line 7
def titleize(word)
  humanize(underscore(word)).gsub(/\b([a-z])/) { $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])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end
url_escape(s) click to toggle source
# File lib/geokit/inflectors.rb, line 29
def url_escape(s)
  CGI.escape(s)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.