forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsort.rb
More file actions
37 lines (34 loc) · 896 Bytes
/
sort.rb
File metadata and controls
37 lines (34 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::Filter::Sort
# Author:: 774 <http://id774.net>
# Created:: Mar 23, 2012
# Updated:: Jan 23, 2013
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
module Automatic::Plugin
class FilterSort
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
@return_feeds = []
@pipeline.each { |feeds|
return_feed_items = []
unless feeds.nil?
if @config['sort'] == "asc"
feeds.items.sort!{|a,b|
a.date <=> b.date
}
else
feeds.items.sort!{|a,b|
- (a.date <=> b.date)
}
end
@return_feeds << feeds
end
}
@return_feeds
end
end
end