Sha256: 2f25bd1d18711d9b80779a330451af9f5d10d811fdaf2041afb2777ea9d5da54

Contents?: true

Size: 209 Bytes

Versions: 5

Compression:

Stored size: 209 Bytes

Contents

class String

  # Title case.
  #
  #   "this is a string".titlecase
  #   => "This Is A String"
  #
  # CREDIT: Eliazar Parra

  def titlecase
    gsub(/\b\w/){ $`[-1,1] == "'" ? $& : $&.upcase }
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/string/titlecase.rb
facets-2.8.3 lib/core/facets/string/titlecase.rb
facets-2.8.2 lib/core/facets/string/titlecase.rb
facets-2.8.1 lib/core/facets/string/titlecase.rb
facets-2.8.0 lib/core/facets/string/titlecase.rb