Method: FatCore::String#as_sym
- Defined in:
- lib/fat_core/string.rb
#as_sym ⇒ Symbol
Convert to a lower-case symbol with all white space converted to a single '_' and all non-alphanumerics deleted, such that the string will work as an unquoted Symbol.
31 32 33 34 35 36 |
# File 'lib/fat_core/string.rb', line 31 def as_sym clean .gsub(/\s+/, '_') .gsub(/[^_A-Za-z0-9]/, '') .downcase.to_sym end |