Module: ZohoInvoiceStringExt
- Included in:
- String
- Defined in:
- lib/zoho_invoice/core_ext/string.rb
Instance Method Summary collapse
Instance Method Details
#camelcase ⇒ Object
2 3 4 5 |
# File 'lib/zoho_invoice/core_ext/string.rb', line 2 def camelcase return self if self !~ /_/ && self =~ /[A-Z]+.*/ split('_').map{|e| e.capitalize}.join end |
#to_underscore ⇒ Object
12 13 14 |
# File 'lib/zoho_invoice/core_ext/string.rb', line 12 def to_underscore dup.tap { |s| s.to_underscore! } end |
#to_underscore! ⇒ Object
7 8 9 10 |
# File 'lib/zoho_invoice/core_ext/string.rb', line 7 def to_underscore! g = gsub!(/(.)([A-Z])/,'\1_\2'); d = downcase! g || d end |