lib/rapid_runty/util.rb in rapid_runty-0.1.2 vs lib/rapid_runty/util.rb in rapid_runty-0.1.3
- old
+ new
@@ -12,6 +12,16 @@
gsub!(/([a-z\d])([A-Z])/, '\1_\2')
tr!('-', '_')
downcase!
self
end
+
+ ##
+ # Returns the CamelCase version of a word
+ #
+ # Example:
+ # "index_controller".camel_case = "IndexController"
+ def camel_case
+ return self if self !~ /_/ && self =~ /[A-Z]+.*/
+ split('_').map(&:capitalize).join
+ end
end