Class: String

Inherits:
Object
  • Object
show all
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/questions/4078906/is-there-a-natural-sort-by-method-for-ruby

Instance Method Summary collapse

Instance Method Details

#naturalizedObject



53
54
55
# File 'lib/transcode/utils.rb', line 53

def naturalized
  scan(/[^\d\.]+|[\d\.]+/).collect { |f| f.match(/\d+(\.\d+)?/) ? f.to_f : f }
end