module Gemsupport::StringInteractions

Public Instance Methods

camelize() click to toggle source
# File lib/gemsupport/refinements/string_interactions.rb, line 12
def camelize
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
  split('/').map do |e|
    e.split('_').map { |w| w.capitalize }.join
  end.join('::')
end
underscore() click to toggle source
# File lib/gemsupport/refinements/string_interactions.rb, line 4
def underscore
  gsub(/::/, '/')
  .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
  .gsub(/([a-z\d])([A-Z])/, '\1_\2')
  .tr('-', '_')
  .downcase
end
unindent() click to toggle source

Remove indentation spaces for multilines string From: | Anonymous Coward | - Community Guest To: |Anonymous Coward | - Community Guest

# File lib/gemsupport/refinements/string_interactions.rb, line 26
def unindent
  gsub(/^#{scan(/^[ \t]+(?=\S)/).min}/, '')
end
unindent!() click to toggle source
# File lib/gemsupport/refinements/string_interactions.rb, line 30
def unindent!
  replace(unindent)
end