Class: TransmissionRSS::Feed
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#regexp ⇒ Object
readonly
Returns the value of attribute regexp.
-
#seen_by_guid ⇒ Object
readonly
Returns the value of attribute seen_by_guid.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#validate_cert ⇒ Object
readonly
Returns the value of attribute validate_cert.
Instance Method Summary collapse
- #download_path(title = nil) ⇒ Object
- #exclude?(title) ⇒ Boolean
-
#initialize(config = {}) ⇒ Feed
constructor
A new instance of Feed.
- #matches_regexp?(title) ⇒ Boolean
Constructor Details
#initialize(config = {}) ⇒ Feed
Returns a new instance of Feed.
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 |
# File 'lib/transmission-rss/feed.rb', line 5 def initialize(config = {}) @download_paths = {} @excludes = {} case config when Hash @config = config @url = URI.escape(URI.unescape(config['url'] || config.keys.first)) @download_path = config['download_path'] matchers = Array(config['regexp']).map do |e| e.is_a?(String) ? e : e['matcher'] end @regexp = build_regexp(matchers) initialize_download_paths_and_excludes(config['regexp']) else @config = {} @url = config.to_s end @validate_cert = @config['validate_cert'].nil? || !!@config['validate_cert'] @seen_by_guid = !!@config['seen_by_guid'] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def config @config end |
#regexp ⇒ Object (readonly)
Returns the value of attribute regexp.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def regexp @regexp end |
#seen_by_guid ⇒ Object (readonly)
Returns the value of attribute seen_by_guid.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def seen_by_guid @seen_by_guid end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def url @url end |
#validate_cert ⇒ Object (readonly)
Returns the value of attribute validate_cert.
3 4 5 |
# File 'lib/transmission-rss/feed.rb', line 3 def validate_cert @validate_cert end |
Instance Method Details
#download_path(title = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/transmission-rss/feed.rb', line 33 def download_path(title = nil) return @download_path if title.nil? @download_paths.each do |regexp, path| return path if title =~ to_regexp(regexp) end @download_path end |
#exclude?(title) ⇒ Boolean
47 48 49 50 51 52 53 |
# File 'lib/transmission-rss/feed.rb', line 47 def exclude?(title) @excludes.each do |regexp, exclude| return true if title =~ to_regexp(exclude) end return false end |
#matches_regexp?(title) ⇒ Boolean
43 44 45 |
# File 'lib/transmission-rss/feed.rb', line 43 def matches_regexp?(title) @regexp.nil? || !(title =~ @regexp).nil? end |