Sha256: 3d22f10bfc00c300886b3ff48e47fbac6261101655c12f1fd58e52195554ac87

Contents?: true

Size: 256 Bytes

Versions: 2

Compression:

Stored size: 256 Bytes

Contents

class String

  def underscore
    gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
  end

  def titleize
    gsub(/([A-Z])/, '_\1').split(/_/).map(&:capitalize).join
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joybox-1.1.1 command/command/string.rb
joybox-1.1.0 command/command/string.rb