Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/freesound/core_ext/string.rb
Instance Method Summary collapse
Instance Method Details
#numberize ⇒ Object
2 3 4 5 6 |
# File 'lib/freesound/core_ext/string.rb', line 2 def numberize if numberizeable? float? ? to_f : to_i end end |
#numberizeable? ⇒ Boolean
8 9 10 |
# File 'lib/freesound/core_ext/string.rb', line 8 def numberizeable? !scan(/^\-?\d*\.?\d*$/).empty? end |
#underscore ⇒ Object
12 13 14 |
# File 'lib/freesound/core_ext/string.rb', line 12 def underscore gsub(/\W/, '_') end |