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:



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

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)


49
50
51
# File 'lib/dgit/core.rb', line 49

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

#underscoreString

Returns a underscore cased version of the string.

Returns:



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

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