Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/dgit/core.rb
Instance Method Summary collapse
-
#camel_case ⇒ String
Returns a camel cased version of the string.
-
#id ⇒ string
Returns a version of the string that can be safely used as a folder name.
-
#underscore ⇒ String
Returns a underscore cased version of the string.
Instance Method Details
#camel_case ⇒ String
Returns a camel cased version of the string.
37 38 39 40 |
# File 'lib/dgit/core.rb', line 37 def camel_case return self if self !~ /_/ && self =~ /[A-Z]+.*/ split('_').map(&:capitalize).join end |
#id ⇒ string
Returns a version of the string that can be safely used as a folder name.
44 45 46 |
# File 'lib/dgit/core.rb', line 44 def id gsub(/[^[\w-]]+/, "_") end |
#underscore ⇒ String
Returns a underscore cased version of the string.
31 32 33 |
# File 'lib/dgit/core.rb', line 31 def underscore gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_").downcase end |