Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/dgit/core.rb

Instance Method Summary collapse

Instance Method Details

#camel_caseString

Returns a camel cased version of the string.

Returns:



36
37
38
39
# File 'lib/dgit/core.rb', line 36

def camel_case
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
  split('_').map(&:capitalize).join
end

#idstring

Returns a version of the string that can be safely used as a folder name.

Returns:

  • (string)


43
44
45
# File 'lib/dgit/core.rb', line 43

def id
  gsub(/[^[\w-]]+/, "_")
end

#underscoreString

Returns a underscore cased version of the string.

Returns:



29
30
31
32
# File 'lib/dgit/core.rb', line 29

def underscore
  gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_").downcase
end