Module: WsdlMapper::Naming::Inflector
- Extended by:
- Inflector
- Included in:
- Inflector, NamerBase
- Defined in:
- lib/wsdl_mapper/naming/inflector.rb
Overview
Module with inflection helper methods. As a permanent dependency on Rails' ActiveSupport library is not feasible, here are some quick re-implementations.
Constant Summary
- FIRST_CHAR =
/^./
- NON_WORD =
/[^a-zA-Z]/
- NON_AN =
/[^a-zA-Z0-9]/
- NON_WORD_FOLLOWED_BY_WORD =
/[^a-zA-Z0-9]+([a-zA-Z0-9])/
- CAPITALS =
/([A-Z])/
- DOWN_FOLLOWED_BY_UP =
/([a-z0-9])([A-Z])/
Instance Method Summary (collapse)
-
- (String) camelize(source)
Camelize a string.
-
- (String) underscore(source)
Snake-cases a string.
Instance Method Details
- (String) camelize(source)
Camelize a string.
20 21 22 23 24 25 |
# File 'lib/wsdl_mapper/naming/inflector.rb', line 20 def camelize(source) source. strip. gsub(NON_WORD_FOLLOWED_BY_WORD) { |s| $1.upcase }. sub(FIRST_CHAR) { |s| s.upcase } end |
- (String) underscore(source)
Snake-cases a string.
32 33 34 35 36 37 38 39 |
# File 'lib/wsdl_mapper/naming/inflector.rb', line 32 def underscore(source) source. strip. gsub(DOWN_FOLLOWED_BY_UP) { |s| "#{$1}_#{$2.downcase}" }. downcase. gsub(NON_AN, '_'). gsub(/_+/, '_') end |