Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/amex/utils.rb
Instance Method Summary collapse
-
#underscore ⇒ String
Converts a String object into a simple as used on an Amex::CardAccount object - the XML uses camelCase attributes, we want underscored ones which we can convert to symbol (e.g. cardProduct to card_product).
Instance Method Details
#underscore ⇒ String
Converts a String object into a simple as used on an Amex::CardAccount object - the XML uses camelCase attributes, we want underscored ones which we can convert to symbol (e.g. cardProduct to card_product)
9 10 11 12 13 14 15 |
# File 'lib/amex/utils.rb', line 9 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |