Class: Scripref::Sorter

Inherits:
Object
  • Object
show all
Includes:
SortUpDown
Defined in:
lib/scripref/sorter.rb

Defined Under Namespace

Modules: SortUpDown, SortUpUp

Instance Method Summary collapse

Methods included from SortUpDown

#signum

Constructor Details

#initialize(*mods) ⇒ Sorter

Returns a new instance of Sorter.



8
9
10
11
# File 'lib/scripref/sorter.rb', line 8

def initialize *mods
  @mods = mods
  mods.each {|m| extend m}
end

Instance Method Details

#sort(*references) ⇒ Object Also known as: <<



13
14
15
16
17
18
# File 'lib/scripref/sorter.rb', line 13

def sort *references
  passages = references.flatten.select {|e| e.kind_of? Scripref::Passage}
  passages.sort do |p1, p2|
    signum(p1, p2)
  end
end