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.
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 |
#id ⇒ string
Returns a version of the string that can be safely used as a folder name.
50 51 52 |
# File 'lib/dgit/core.rb', line 50 def id gsub(/[^[\w-]]+/, "_") end |
#underscore ⇒ String
Returns a underscore cased version of the string.
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 |