Class: Compass::SassExtensions::Sprites::Images
- Inherits:
-
Array
- Object
- Array
- Compass::SassExtensions::Sprites::Images
- Defined in:
- lib/compass/sass_extensions/sprites/images.rb
Instance Method Summary collapse
Instance Method Details
#sort_by!(method) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/compass/sass_extensions/sprites/images.rb', line 6 def sort_by!(method) invert = false if method.to_s[0] == '!'[0] # have todo this for 1.8.7 compat method = method.to_s[1..-1] invert = true end method = method.to_sym self.sort! do |a, b| unless a.send(method) == b.send(method) a.send(method) <=> b.send(method) else other = ([:size, :name] - [method]).first a.send(other) <=> b.send(other) end end self.reverse! if invert end |