Sha256: 20d82ab8cfe186f006fb4365837e2d4aedcf6d8a246d31f4af7ad8e7bf1e8f29
Contents?: true
Size: 392 Bytes
Versions: 2
Compression:
Stored size: 392 Bytes
Contents
class String # returns snake_case representation of string def snake_case gsub(/([a-z])([A-Z0-9])/, '\1_\2').downcase end # returns camel_case representation of string def camel_case if self.include? '_' self.split('_').map { |e| e.capitalize }.join else unless self =~ (/^[A-Z]/) self.capitalize else self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
p2ruby-0.1.5 | lib/extension.rb |
p2ruby-0.1.4 | lib/extension.rb |