class String
Public Instance Methods
camel()
click to toggle source
# File lib/kamelcase.rb, line 2 def camel return self if self !~ /_| / && self =~ /[A-Z]+.*/ split(/_| /).map{|e| e.capitalize}.join end
camel_lower()
click to toggle source
# File lib/kamelcase.rb, line 7 def camel_lower self.split(/_| /).inject([]){ |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join end
nuke(chars)
click to toggle source
# File lib/kamelcase.rb, line 22 def nuke chars self.tr(chars, '') end
snake()
click to toggle source
# File lib/kamelcase.rb, line 13 def snake self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). tr(' ', '_'). downcase end