Module: ZendeskAPI::Helpers
- Defined in:
- lib/zendesk_api/helpers.rb
Class Method Summary collapse
Class Method Details
.modulize_string(string) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/zendesk_api/helpers.rb', line 5 def self.modulize_string(string) #gsub('__','/'). # why was this ever here? string.gsub(/__(.?)/){ "::#{$1.upcase}" }. gsub(/\/(.?)/){ "::#{$1.upcase}" }. gsub(/(?:_+|-+)([a-z])/){ $1.upcase }. gsub(/(\A|\s)([a-z])/){ $1 + $2.upcase } end |
.snakecase_string(string) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/zendesk_api/helpers.rb', line 14 def self.snakecase_string(string) #gsub(/::/, '/'). string.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr('-', '_'). gsub(/\s/, '_'). gsub(/__+/, '_'). downcase end |