Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/transcode/utils.rb
Overview
Adds natural sort method. This converts something like “Filename 10” into a simple array with floats in place of numbers [ “Filename”, 10.0 ]. See:
https://stackoverflow.com/q/4078906
Instance Method Summary collapse
Instance Method Details
#naturalized ⇒ Object
60 61 62 |
# File 'lib/transcode/utils.rb', line 60 def naturalized scan(/[^\d.]+|[\d.]+/).collect { |f| f.match(/\d+(\.\d+)?/) ? f.to_f : f } end |