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:



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

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)


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

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

#underscoreString

Returns a underscore cased version of the string.

Returns:



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

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