Module: Linner::Order

Included in:
Array
Defined in:
lib/linner/helper.rb

Instance Method Summary collapse

Instance Method Details

#order_by(ary) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/linner/helper.rb', line 11

def order_by(ary)
  ary << "..." if not ary.include? "..."
  order_ary = ary.inject([[]]) do |a, x|
    x != "..." ? a.last << x : a<< []; a
  end
  order_by_direction(order_ary.first, :before)
  order_by_direction(order_ary.last, :after)
  self
end