forked from id774/automaticruby
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathimage.rb
More file actions
42 lines (38 loc) · 997 Bytes
/
image.rb
File metadata and controls
42 lines (38 loc) · 997 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
38
39
40
41
42
# -*- coding: utf-8 -*-
# Name:: Automatic::Plugin::Filter::Image
# Author:: 774 <http://id774.net>
# Created:: Sep 18, 2012
# Updated:: Apr 5, 2013
# Copyright:: Copyright (c) 2012-2013 Automatic Ruby Developers.
# License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
module Automatic::Plugin
class FilterImage
def initialize(config, pipeline=[])
@config = config
@pipeline = pipeline
end
def run
@return_feeds = []
@pipeline.each {|feeds|
return_feed_items = []
unless feeds.nil?
feeds.items.each {|feed|
feed.link = image?(feed.link) unless feed.link.nil?
}
@return_feeds << feeds
end
}
@return_feeds
end
private
def image?(link)
case link
when /\.jpe?g\Z/i then link
when /\.gif\Z/i then link
when /\.png\Z/i then link
when /\.tiff\Z/i then link
else nil
end
end
end
end