Module: CloudCrowd::Inflector
- Defined in:
- lib/cloud_crowd/inflector.rb
Overview
Pilfered in parts from the ActiveSupport::Inflector.
Class Method Summary collapse
Class Method Details
.camelize(word) ⇒ Object
6 7 8 |
# File 'lib/cloud_crowd/inflector.rb', line 6
def self.camelize(word)
word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
|
.underscore(word) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cloud_crowd/inflector.rb', line 10
def self.underscore(word)
word.to_s.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
|