module EbayTrading::Inflections
Constants
- DOWNCASE_TOKENS
- NAME_MAPPINGS
- UPCASE_TOKENS
Public Instance Methods
downcase_first_character(string)
click to toggle source
# File lib/ebay_trading/inflections.rb, line 17 def downcase_first_character(string) string.sub(/^(.)/) { $1.downcase } end
ebay_camelize(lower_case_and_underscored_word)
click to toggle source
# File lib/ebay_trading/inflections.rb, line 29 def ebay_camelize(lower_case_and_underscored_word) lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }. gsub(/(^|_)(.)/) { $2.upcase }. gsub(/(#{NAME_MAPPINGS.keys.collect{|k| k.capitalize}.join('|')})/){ NAME_MAPPINGS[$1.downcase] }. gsub(UPCASE_TOKENS) { $1.upcase } end
ebay_underscore(camel_cased_word)
click to toggle source
# File lib/ebay_trading/inflections.rb, line 36 def ebay_underscore(camel_cased_word) underscore(camel_cased_word.to_s.gsub(/(#{NAME_MAPPINGS.values.join('|')})/i){ upcase_first_character($1.downcase) }. gsub(DOWNCASE_TOKENS){ $1.downcase }. gsub(/(ids$)/i) { $1.upcase } ) end
underscore(camel_cased_word)
click to toggle source
# File lib/ebay_trading/inflections.rb, line 21 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
upcase_first_character(string)
click to toggle source
# File lib/ebay_trading/inflections.rb, line 13 def upcase_first_character(string) string.sub(/^(.)/) { $1.upcase } end