Sha256: df6f0b4ac805005ce7775f4b7208b143a51c6e231a3ca6f07653a2af5513a7ad

Contents?: true

Size: 228 Bytes

Versions: 22

Compression:

Stored size: 228 Bytes

Contents

class String

  # Prepend an "@" to the beginning of a string
  # to make a instance variable name. This also replaces
  # non-valid characters with underscores.

  def variablize
    v = gsub(/\W/, '_')
    "@#{v}"
  end

end

Version data entries

22 entries across 21 versions & 3 rubygems

Version Path
facets-2.5.2 lib/core/facets/string/variablize.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/core/facets/string/variablize.rb